You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
ENH/REF/SUMM/Design: new or refactored base classes for models #7187
Collecting some problems with and ideas for base Model and Results classes.
This is currently just some ideas for a roadmap, maybe we need a SMEP before making larger changes to base classes.
The basic structure of our base classes has been unchanged for a very long time. It works well overall but has limitations and warts.
semi random list of what I remember and what's bugging me right now (I might not remember all details correctly)
optimization shouldn't require likelihood to support models that are not based on MLE without misusing names of methods
signature of results class could also be made more generic, normalized_cov_params comes mostly from linear model.
MLE results classes in discrete and GenericLikelihoodModel have a signature different from LikelihoodModelResults
more generic base class, includes optimization and wald inference, e.g. separate generic M-estimator or GMM generic features from MLE
add more likelihood features that are only appropriate for non-tsa models, We should be able to add methods without having to worry about inappropriate methods inherited by tsa
related to previous points: DiscreteModel and DiscreteResults have very few "discrete" specific features. They are more like an intermediate MLE class similar to what we might need.
model and results class for rapid development. Currently there is a gap between LikelihoodModel and GenericLikelihoodModel, e.g. I didn't want to move OrderedModel out of miscmodels because it inherits too much from GenericLikelihoodModel
Maybe add/move features GenericLikelihoodModel to (non-tsa) LikelihoodModel, similarly for corresponding Results classes
What I would like right now are improved classes for rapid development.
I could add 5 to 10 models with core features available, but they shouldn't inherit extras from GenericLikelihoodModel. I don't want to put them in miscmodels and I don't want to spend several weeks on each.
my current view is to add a new othermod folder to collect MLE models that don't fit well in any other category.
e.g. BetaRegression, Log-normal, parametric survival models (endog in R+) without censoring and survival extras.
models based on flexible distributions
another wart: stop using df_model and use k_params instead
df_modelwc didn't catch on, but df_model without taking constant into account is just annoying.
e.g. Beta regression and other two part models have in general two constants, multi-parameter distributions might have even more. We need to be more careful in how we count params for comparison to llnull.
aside: Do we have correct LR_null in zero inflated models? I don't see any null/llnull code in count_model. DiscreteResults.llr_pvalue uses df_model: stats.distributions.chi2.sf(self.llr, self.df_model)
which is correct if df_model is interpreted as number of params not in Null model.
outside of linear models we mostly hardcode df_model + 1 anyway, assuming we have a constant.
For many parts we already use df_resid instead of df_model to avoid ambiguity, but aic, bic, ... still use df_model.
backwards compatible way forward:
New model and results classes (in othermod should not use df_model for anything relevant.
Generic, super results classes can check for k_params attribute.
possible unit or unit_interval for models with endog in unit interval, e.g. betareg
This could include other distributions, many are available based on transformation from R+ or R into (0, 1)
e.g. Johnson SB generalized to elliptical/symmetric distributions
after working with GenericLikelihoodModel in #7488 (discretized count), I think it can be cleaned up to be a proper base class.
It works well with still some sharp corners (I needed two fixes to handle the cases in #7488 ), but needs to be cleaned up for things that are outdated.
even simple bootstrap is nice to have
GenericLikelihood classes have or should have all the defaults for easy development, and we should be set all relevant parts with ones that are model specific.
The main problem will be to clean out outdated parts that are essentially duplicates in a backwards compatible way, e.g. nloglike never caught on, and we keep using - loglike.
Activity
josef-pkt commentedon Nov 30, 2020
What I would like right now are improved classes for rapid development.
I could add 5 to 10 models with core features available, but they shouldn't inherit extras from GenericLikelihoodModel. I don't want to put them in miscmodels and I don't want to spend several weeks on each.
josef-pkt commentedon Nov 30, 2020
Checking statespace mle
score_obs, loglikobs are also defined
extras are different methods for information matrix as separate methods, .e.g we could add OPG generically.
score_factor and hessian_factor doesn't apply generically, but it is in most of current cross-section models, especially GLM and discrete
a generic OPG score/LM test only needs score_factor for variable addition tests
josef-pkt commentedon Jan 26, 2021
my current view is to add a new
othermodfolder to collect MLE models that don't fit well in any other category.e.g. BetaRegression, Log-normal, parametric survival models (endog in R+) without censoring and survival extras.
models based on flexible distributions
josef-pkt commentedon Jan 27, 2021
another wart: stop using df_model and use k_params instead
df_modelwc didn't catch on, but df_model without taking constant into account is just annoying.
e.g. Beta regression and other two part models have in general two constants, multi-parameter distributions might have even more. We need to be more careful in how we count params for comparison to llnull.
aside: Do we have correct LR_null in zero inflated models? I don't see any null/llnull code in
count_model.DiscreteResults.llr_pvalueuses df_model:stats.distributions.chi2.sf(self.llr, self.df_model)which is correct if df_model is interpreted as number of params not in Null model.
outside of linear models we mostly hardcode
df_model + 1anyway, assuming we have a constant.For many parts we already use df_resid instead of df_model to avoid ambiguity, but aic, bic, ... still use df_model.
backwards compatible way forward:
New model and results classes (in
othermodshould not use df_model for anything relevant.Generic, super results classes can check for
k_paramsattribute.josef-pkt commentedon Mar 7, 2021
module structure ?
possible
unitorunit_intervalfor models with endog in unit interval, e.g. betaregThis could include other distributions, many are available based on transformation from R+ or R into (0, 1)
e.g. Johnson SB generalized to elliptical/symmetric distributions
Lemonte, Artur J., and Jorge L. Bazán. 2016. “New Class of Johnson SB Distributions and Its Associated Regression Model for Rates and Proportions: SB Distributions and Its Associated Regression Model.” Biometrical Journal 58 (4): 727–46. https://doi.org/10.1002/bimj.201500030.
reparameterized for regression in terms of median and a dispersion parameter
josef-pkt commentedon Jun 16, 2021
after working with GenericLikelihoodModel in #7488 (discretized count), I think it can be cleaned up to be a proper base class.
It works well with still some sharp corners (I needed two fixes to handle the cases in #7488 ), but needs to be cleaned up for things that are outdated.
even simple bootstrap is nice to have
GenericLikelihood classes have or should have all the defaults for easy development, and we should be set all relevant parts with ones that are model specific.
The main problem will be to clean out outdated parts that are essentially duplicates in a backwards compatible way, e.g. nloglike never caught on, and we keep using
- loglike.