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
If I set the covariance_type in GEE.fit, then it doesn't seem to be used.
The summary table is the same whatever covariance_type I have chosen.
bse is also the same
summary, confint and similar have a covariance_type argument but the default doesn't depend on the covariance_type set in GEE.fit
other issue: I prefer to standardize covariance_type -> cov_type
aside:
found while comparing GEE and GLM with cluster robust standard errors
naive is over/under dispersed, scale differs compared to GLM naive by pearson_chi2 / df_resid
However, if we call summary right after fit, then the covariance_type get's changed to the default robust, and then the covariance_type is not the one set in fit anymore self.covariance_type = covariance_type
summary cannot choose the covariance_type, i.e. we cannot have it as an argument, because it relies on cached attributes which become inconsistent if some of them are changed.
also I don't see pvalues being set to the default covariance_type (pvalues are inherited), I haven't verified this yet, just based on reading the code.
Similar, other inherited methods like wald_test and conf_int should be using the wrong cov_params (just a guess)
edit conf_int is not inherited, but it uses "robust" as default in the method argument, and does not default to the chosen self.covariance_type
@kshedden I will try to prepare a PR for this so that the inherited methods work correctly.
Essentially, use cov_params_default everywhere if covariance_type/cov_type is not specifically given as argument.
(This would follow mostly my recent changes to the handling of covariance matrices and, I think, avoid the possibility to get inconsistent attributes and results.)
@josef-pkt I can work on this, but it sounds like you have already started.
Let me know if you want me to take this over. I'm fine of course if you
can do it.
On Wed, Aug 20, 2014 at 12:33 AM, Josef Perktold [email protected]
wrote:
Two results instances, one with and one without calling summary()
Yes I already started, mainly to see if fixing summary and adding cov_params_default solves the main problems.
I'm working on top of two other PR's, one not yet pushed.
another tricky piece:
setting cov_params_default in GEEResult.__init__ doesn't actually work because the covariances and covariance_type is added to the results instance after the init has been set.
we would have to set it in the fit method already
However, it's cleaner to add some of the covariance information as arguments in GEEResults.__init__ similar to the way I handle it in the other models.
related to last point OrdinalGEEResults and NominalGEEResults need the same __init__ arguments. Both of those __init__ methods could currently be dropped, they don't do anything except call super.
@kshedden One question, based on my reading of the code the subclasses NominalGEEResults and OrdinalGEEResults never get the naive and bias corrected covariances attached. They are calculated in the super call but not attached to the subclass results instance.
Is this intentional or a bug? Should those two also have all three covariances?
(right now I only attached the robust_covariance so all existing unit tests pass after the first refactoring.
a consequence of fixing this: So far cov_params() was pointing to the robust covariance. Now it always returns the default covariance, cov_params_default that depends on the cov_type. To have the robust covariance matrix available, I attached it as new attribute robust_covariance, which follows the same pattern as currently for the other two.
(more radical change: only calculate robust and robust_bc covariances on demand, and move part of GEE_covmat to be called by the results class. (And store the naive covariance as normalized_cov_params.) (robust_bc doesn't need robust, AFAICS from a quick look.)
Activity
[-]GEE: default covariance is not used[/-][+]BUG: GEE default covariance is not used[/+]josef-pkt commentedon Aug 19, 2014
moving to prio-high
took me a while to see what's wrong
bse is correctly set and uses the define
covariance_typeHowever, if we call summary right after fit, then the
covariance_typeget's changed to the defaultrobust, and then the covariance_type is not the one set in fit anymoreself.covariance_type = covariance_typesummarycannot choose the covariance_type, i.e. we cannot have it as an argument, because it relies on cached attributes which become inconsistent if some of them are changed.also I don't see pvalues being set to the default covariance_type (pvalues are inherited), I haven't verified this yet, just based on reading the code.
Similar, other inherited methods like wald_test and conf_int should be using the wrong cov_params (just a guess)
edit conf_int is not inherited, but it uses "robust" as default in the method argument, and does not default to the chosen
self.covariance_type@kshedden I will try to prepare a PR for this so that the inherited methods work correctly.
Essentially, use
cov_params_defaulteverywhere ifcovariance_type/cov_typeis not specifically given as argument.(This would follow mostly my recent changes to the handling of covariance matrices and, I think, avoid the possibility to get inconsistent attributes and results.)
josef-pkt commentedon Aug 19, 2014
Two results instances, one with and one without calling summary()
http://nbviewer.ipython.org/gist/josef-pkt/3cf9c6a2bf304904c839#Appendix:-Convariance-Types-in-GEE
kshedden commentedon Aug 19, 2014
@josef-pkt I can work on this, but it sounds like you have already started.
Let me know if you want me to take this over. I'm fine of course if you
can do it.
On Wed, Aug 20, 2014 at 12:33 AM, Josef Perktold [email protected]
wrote:
josef-pkt commentedon Aug 19, 2014
Yes I already started, mainly to see if fixing summary and adding
cov_params_defaultsolves the main problems.I'm working on top of two other PR's, one not yet pushed.
josef-pkt commentedon Aug 19, 2014
another tricky piece:
setting
cov_params_defaultinGEEResult.__init__doesn't actually work because the covariances and covariance_type is added to the results instance after the init has been set.we would have to set it in the fit method already
However, it's cleaner to add some of the covariance information as arguments in
GEEResults.__init__similar to the way I handle it in the other models.josef-pkt commentedon Aug 19, 2014
@kshedden If you want to see how I did it for GEE, the discrete models and for RegressionModel
https://github.com/statsmodels/statsmodels/pull/1870/files#diff-724e15f4019b2a24906f6b271d67e370L876
new keywords in
XXXResults.__init__:cov_type='nonrobust', cov_kwds=None, use_t=Nonejosef-pkt commentedon Aug 19, 2014
GEE would default to
cov_type='robust'as it does now, since it's the standard for GEE.josef-pkt commentedon Aug 19, 2014
related to last point
OrdinalGEEResultsandNominalGEEResultsneed the same__init__arguments. Both of those__init__methods could currently be dropped, they don't do anything except call super.BUG: GEE partial cleanup of cov_type, see statsmodels#1906
josef-pkt commentedon Aug 20, 2014
I started the minimal changes so far in #1916
@kshedden One question, based on my reading of the code the subclasses NominalGEEResults and OrdinalGEEResults never get the naive and bias corrected covariances attached. They are calculated in the super call but not attached to the subclass results instance.
Is this intentional or a bug? Should those two also have all three covariances?
(right now I only attached the
robust_covarianceso all existing unit tests pass after the first refactoring.a consequence of fixing this: So far
cov_params()was pointing to the robust covariance. Now it always returns the default covariance,cov_params_defaultthat depends on thecov_type. To have the robust covariance matrix available, I attached it as new attributerobust_covariance, which follows the same pattern as currently for the other two.(more radical change: only calculate robust and robust_bc covariances on demand, and move part of GEE_covmat to be called by the results class. (And store the naive covariance as
normalized_cov_params.) (robust_bc doesn't need robust, AFAICS from a quick look.)BUG: GEE partial cleanup of cov_type, see statsmodels#1906
BUG: GEE partial cleanup of cov_type, see statsmodels#1906
josef-pkt commentedon Aug 23, 2014
fixed in #1924 and merged
BUG: GEE partial cleanup of cov_type, see statsmodels#1906
Merge commit 'v0.5.0-1269-g957a43e' into debian-experimental