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
Should scale and normalized_cov_params be removed from LikelihoodModelResults? #1594
Most likelihood models do not naturally have scale or normalized_cov_params concepts, and these are only applicable to a subset of additive error models.
Some of the applications of these simply fake the result and set normalized_cov_params to the actual covariance of the parameters and scale=1 - it seems to have these as attributes is then misleading.
It would be more natural for the model inheriting from LikelihoodModelResults to provide a covariance estimator if required.
These are only actually used in the following lines,
but then derived classes have the attributes scale and normalized_cov_params.
This also appears to have the side effect that cov_params has to be a function rather than just an attribute property, so that the somewhat awkward situation arises where the unfortunate mixed syntax is required
and then the magic currently in cov_params() will not be required.
The other use of cov_params can be moved to a either a private function or a function that is more appropriately named such as cov_linear_restriction which is what the computational side of cov_params appears to compute.
changed the title [-]Should 'scale` and `normalized_cov_params` be removed from `LikelihoodModelResults`?[/-][+]Should `scale` and `normalized_cov_params` be removed from `LikelihoodModelResults`?[/+]on Apr 16, 2014
I'm not sure yet how this should go. This would be a high impact refactoring because it's used across models.
That cov_params is a method that requires call (), has been bothering me for a long time, but it's a multi-purpose method. My latest thought was to get cov_params_default to store just the covariance_matrix as attribute.
It's not obvious if merging scale into normalized_cov_params is a good idea:
In the linear models, scale is actually estimated in the results instance, the __init__ argument is ignored. For GLM, and discrete_models we have models with scale=1 by definition. However, GLM also has families, e.g. Gaussian, where scale is estimated separately. For pseudo- or quasi-MLE we also have scale different from 1.
for example for my experiments with overdispersed Poisson, I was just adjusting the scale != 1 separately.
Essentially, plain MLE includes the scale in the Hessian (or equivalent), all other estimators estimate the scale separately.
In terms of general names, I'm also unsure about bse. The name of the estimated parameters is params which is very generic and doesn't use any domain-specific naming conventions. I would think that either se, std_err or param_se would be preferred. se is probably too short to be clean. If param_se is used then param_cov would be the natural name for these.
Of it cov_params was kept, then se_params would be a better name.
I have also been experimenting with making f_test a mixin since it isn't appropriate for almost all non-regression-based models.
It's not obvious if merging scale into normalized_cov_params is a good idea:
In the linear models, scale is actually estimated in the results instance, the init argument is ignored. For GLM, and discrete_models we have models with scale=1 by definition. However, GLM also has families, e.g. Gaussian, where scale is estimated separately. For pseudo- or quasi-MLE we also have scale different from 1.
for example for my experiments with overdispersed Poisson, I was just adjusting the scale != 1 separately.
Essentially, plain MLE includes the scale in the Hessian (or equivalent), all other estimators estimate the scale separately.
for example for my experiments with overdispersed Poisson, I was just adjusting the scale != 1 separately.
Couldn't this be done simply by multiplying the covariance by some number !=1 using an existing results (assuming that was refactored to be ignorant of scale)?
I have also been experimenting with making f_test a mixin since it isn't appropriate for almost all non-regression-based models.
Since it's now just delegating to wald_test, we could deprecate it in LikelihoodModelResults and add it only to RegressionResults (and any others that we might get that have use_t=True as default)
I'm against removing the use_t options for all or generic models. Skipper deleted it once, I added it back in. I have seen too many papers that recommend t and F for better small sample properties, than the asymptotic normal, chisquare based statistics.
technical answer:
normalized_cov_params is part of the parameter estimate in fit, i.e. model,
scale is used for inference (possibly ignored nuisance parameter in fit), it's the role of the results instance to combine them.
(at least, that's the way it is for linear models)
What I don't see what value having LikelihoodResults aware of this provides
LikelihoodResults is really a misnomer or a two-in-one class because it covers both MLE and non-MLE (general extremum, M-estimators) models.
I would like to split the likelihood part from the extremum estimator part.
When we add cov_type and a choice of covariance estimator to fit, then the cov_params_default would combine scale and normalized_cov_params.
However, we still should avoid extra calculations in fit, because in some cases we are only interested in the parameter estimates (for example iterative WLS used in GLM and RLM, or cross-validation).
Couldn't this be done simply by multiplying the covariance by some number !=1 using an existing results (assuming that was refactored to be ignorant of scale)?
The relevant part is in parenthesis, currently normalized_cov_params is ignorant of scale, or better it is for a fixed scale=1. Internally, we need to combine cov_params_without_scale and scale somewhere, where this is is open for refactoring.
I fully agree with renaming bse, we just need to agree on a new name and deprecate bse.
it's an early inherited name that was never changed.
I would also be fine with replacing cov_params() by an attribute, but I expect that it will break a lot of code, and I don't see how to do this with a deprecation.
The relevant part is in parenthesis, currently normalized_cov_params is ignorant of scale, or better it is for a fixed scale=1. Internally, we need to combine cov_params_without_scale and scale somewhere, where this is is open for refactoring.
Looking through the calls to this code I don't really see why having the ability to set scale is used inside a results instance. Put another way, the (scaled) covariance can be directly provided. In the case of a LS model, this would just be sigma^2 * (X.T*X)^(-1), or could be HCX. In the case of a MLE model, this could be the covariance of the scores, or the Hessian, or a sandwich form to allow for QMLE.
This refactor is definitely big, and it probably makes sense to start a new results class (mostly copied) with an alternative structure and then deliberately migrate, rather than trying to change the existing.
an update here: cov_params_default is now the main attribute to hold the covariance if cov_type is not nonrobust. normalized_cov_params corresponds to the Hessian, but is not yet unified.
Even for the nonrobust case we might start to use it, maybe during the next cov_type refactoring. cov_params_default is not yet guaranteed to be available. cov_params is still the main interface that uses cov_params_default if that is available.
usage of scale is still has several open issues, with the main problem that we need to fix it in some usages (LR tests) or make it optional (overdispersion)
Activity
[-]Should 'scale` and `normalized_cov_params` be removed from `LikelihoodModelResults`?[/-][+]Should `scale` and `normalized_cov_params` be removed from `LikelihoodModelResults`?[/+]josef-pkt commentedon Apr 16, 2014
I'm not sure yet how this should go. This would be a high impact refactoring because it's used across models.
That cov_params is a method that requires call (), has been bothering me for a long time, but it's a multi-purpose method. My latest thought was to get
cov_params_defaultto store just the covariance_matrix as attribute.It's not obvious if merging
scaleintonormalized_cov_paramsis a good idea:In the linear models, scale is actually estimated in the results instance, the
__init__argument is ignored. For GLM, and discrete_models we have models with scale=1 by definition. However, GLM also has families, e.g. Gaussian, where scale is estimated separately. For pseudo- or quasi-MLE we also have scale different from 1.for example for my experiments with overdispersed Poisson, I was just adjusting the scale != 1 separately.
Essentially, plain MLE includes the scale in the Hessian (or equivalent), all other estimators estimate the scale separately.
bashtage commentedon Apr 16, 2014
In terms of general names, I'm also unsure about
bse. The name of the estimated parameters isparamswhich is very generic and doesn't use any domain-specific naming conventions. I would think that eitherse,std_errorparam_sewould be preferred.seis probably too short to be clean. Ifparam_seis used thenparam_covwould be the natural name for these.Of it
cov_paramswas kept, thense_paramswould be a better name.I have also been experimenting with making
f_testa mixin since it isn't appropriate for almost all non-regression-based models.bashtage commentedon Apr 16, 2014
What I don't see what value having
LikelihoodResultsaware of this provides, other than a lot of complex code that is really handling things that have nothing to do withLikelihoodResults. This seems to violate the separation of concerns (http://en.wikipedia.org/wiki/Separation_of_concerns) since this routine really contains very specific code that ties into a specific class.Couldn't this be done simply by multiplying the covariance by some number !=1 using an existing results (assuming that was refactored to be ignorant of scale)?
josef-pkt commentedon Apr 16, 2014
Since it's now just delegating to
wald_test, we could deprecate it in LikelihoodModelResults and add it only to RegressionResults (and any others that we might get that have use_t=True as default)I'm against removing the
use_toptions for all or generic models. Skipper deleted it once, I added it back in. I have seen too many papers that recommend t and F for better small sample properties, than the asymptotic normal, chisquare based statistics.josef-pkt commentedon Apr 16, 2014
technical answer:
normalized_cov_params is part of the parameter estimate in fit, i.e. model,
scale is used for inference (possibly ignored nuisance parameter in fit), it's the role of the results instance to combine them.
(at least, that's the way it is for linear models)
LikelihoodResultsis really a misnomer or a two-in-one class because it covers both MLE and non-MLE (general extremum, M-estimators) models.I would like to split the likelihood part from the extremum estimator part.
When we add
cov_typeand a choice of covariance estimator tofit, then thecov_params_defaultwould combine scale and normalized_cov_params.However, we still should avoid extra calculations in fit, because in some cases we are only interested in the parameter estimates (for example iterative WLS used in GLM and RLM, or cross-validation).
josef-pkt commentedon Apr 16, 2014
The relevant part is in parenthesis, currently normalized_cov_params is ignorant of scale, or better it is for a fixed scale=1. Internally, we need to combine cov_params_without_scale and scale somewhere, where this is is open for refactoring.
josef-pkt commentedon Apr 16, 2014
I fully agree with renaming
bse, we just need to agree on a new name and deprecate bse.it's an early inherited name that was never changed.
I would also be fine with replacing
cov_params()by an attribute, but I expect that it will break a lot of code, and I don't see how to do this with a deprecation.bashtage commentedon Apr 16, 2014
Looking through the calls to this code I don't really see why having the ability to set scale is used inside a results instance. Put another way, the (scaled) covariance can be directly provided. In the case of a LS model, this would just be sigma^2 * (X.T*X)^(-1), or could be
HCX. In the case of a MLE model, this could be the covariance of the scores, or the Hessian, or a sandwich form to allow for QMLE.This refactor is definitely big, and it probably makes sense to start a new results class (mostly copied) with an alternative structure and then deliberately migrate, rather than trying to change the existing.
josef-pkt commentedon Nov 23, 2015
an update here:
cov_params_defaultis now the main attribute to hold the covariance if cov_type is not nonrobust. normalized_cov_params corresponds to the Hessian, but is not yet unified.Even for the nonrobust case we might start to use it, maybe during the next cov_type refactoring.
cov_params_defaultis not yet guaranteed to be available.cov_paramsis still the main interface that usescov_params_defaultif that is available.usage of
scaleis still has several open issues, with the main problem that we need to fix it in some usages (LR tests) or make it optional (overdispersion)