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
As discussed elsewhere, base.covtype.get_robustcov_results is almost identical to regression.linear_model.RegressionResults.get_robustcov_results. Quick question about the "almost" part.
# TODO cannot access cov without calling se first
getattr(self, cov_type.upper() + '_se')
res.cov_params_default = getattr(self, 'cov_' + cov_type.upper())
In general, the general plan is to have only ONE.
However, the individual models can have model specific variants of cov_types or additional cov_types.
Currently only the linear models, essentially OLS and WLS, specify HC1 through HC3, and it was first implemented directly as lazy attributes of RegressionResults.
All other models, i.e. generically we only have one HCx.
In the second version res.cov_params_default = getattr(self, 'cov_' + cov_type.upper(), None)
checks whether we already have the relevant cov as an attribute, and if not, then we compute the generic version.
I don't remember whether I have used the linear regression version as a test case/comparison to the generic version, but given the code I likely did.
Why is the getattr(self, cov_type.upper() + '_se') call necessary in linear_mode but not in covtype?
After checking RegressionResult claass: the generic version is correct, the linear model call to se is redundant now. At some point, when writing the generic version, I changed the cov_HCx to be lazy cached attributes that are not created in the se call.
based on my reading of the code, the todo is outdated and obsolete
i.e. these two lines are redundant and refer to earlier version of cov_HCx
# TODO cannot access cov without calling se first
getattr(self, cov_type.upper() + '_se')
Only ONE what?
only one generic get_robustcov_results with model specific overrides.
Most of the RegressionResults.get_robustcov_results is redundant duplication, except that it was easier to change things there first before working on the generic version, e.g only the linear model version has the "fixed scale" option. I don't know what 'fixed scale' options would mean in discrete and all families of GLM (although we need something similar for GLM, but maybe not for discrete).
Activity
josef-pkt commentedon Oct 10, 2017
In general, the general plan is to have only ONE.
However, the individual models can have model specific variants of cov_types or additional cov_types.
Currently only the linear models, essentially OLS and WLS, specify HC1 through HC3, and it was first implemented directly as lazy attributes of RegressionResults.
All other models, i.e. generically we only have one HCx.
In the second version
res.cov_params_default = getattr(self, 'cov_' + cov_type.upper(), None)checks whether we already have the relevant cov as an attribute, and if not, then we compute the generic version.
I don't remember whether I have used the linear
regressionversion as a test case/comparison to the generic version, but given the code I likely did.After checking RegressionResult claass: the generic version is correct, the linear model call to se is redundant now. At some point, when writing the generic version, I changed the cov_HCx to be lazy cached attributes that are not created in the se call.
jbrockmendel commentedon Oct 11, 2017
Thanks. Quick follow-up: does that mean the TODO note in the linear_model version is inaccurate/unnecessary?
Only ONE what? They both start with H, but you might be confusing Heteroskedasticity with Highlander. Happens to me all the time.
josef-pkt commentedon Oct 11, 2017
based on my reading of the code, the todo is outdated and obsolete
i.e. these two lines are redundant and refer to earlier version of cov_HCx
Only ONE what?
only one generic
get_robustcov_resultswith model specific overrides.Most of the
RegressionResults.get_robustcov_resultsis redundant duplication, except that it was easier to change things there first before working on the generic version, e.g only the linear model version has the "fixed scale" option. I don't know what 'fixed scale' options would mean in discrete and all families of GLM (although we need something similar for GLM, but maybe not for discrete).Nevertheless, next refactor will most likely remove the generic code from linear models.
My last changes were mostly copy-paste after I checked everything in the linear model version.
https://github.com/statsmodels/statsmodels/pull/3162/files