Skip to content

get_robustcov mismatch? #4014

Closed
Closed

Description

@jbrockmendel

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.

From the linear_model version:

    # TODO cannot access cov without calling se first
    getattr(self, cov_type.upper() + '_se')
    res.cov_params_default = getattr(self, 'cov_' + cov_type.upper())

From the covtype version:

    res.cov_params_default = getattr(self, 'cov_' + cov_type.upper(), None)
    if res.cov_params_default is None:
        # results classes that don't have cov_HCx attribute
        res.cov_params_default = sw.cov_white_simple(self, use_correction=False)

Why is the getattr(self, cov_type.upper() + '_se') call necessary in linear_mode but not in covtype?

Activity

  1. josef-pkt commented on Oct 10, 2017

    @josef-pkt
    Member

    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.

  2. jbrockmendel commented on Oct 11, 2017

    @jbrockmendel
    ContributorAuthor

    After checking RegressionResult claass: the generic version is correct, the linear model call to se is redundant now.

    Thanks. Quick follow-up: does that mean the TODO note in the linear_model version is inaccurate/unnecessary?

    In general, the general plan is to have only ONE.

    Only ONE what? They both start with H, but you might be confusing Heteroskedasticity with Highlander. Happens to me all the time.

  3. josef-pkt commented on Oct 11, 2017

    @josef-pkt
    Member

    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).

    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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions