Skip to content

BUG/REF: Regression Results use_t wrong if cov_type='nonrobust' #5331

Closed

Description

@josef-pkt

I'm not sure anymore about the below.
AFAICS, use_t is still handled through get_robustcov_results if cov_type is not 'nonrobust'

TheilRegressionResults subclasses RegressionResults but RegressionResults but setting use_t is/seems broken.

Use_t support in TheilGLS will be added by #5296, but the current RegressionResults.__init__ doesn't handle this case. This can cause problems for other subclasses and is not TheilGLS specific.

        if cov_type == 'nonrobust':
            self.cov_type = 'nonrobust'
            self.cov_kwds = {
                'description': 'Standard Errors assume that the ' +
                'covariance matrix of the errors is correctly ' +
                'specified.'}
            if use_t is None:
                self.use_t = True  # TODO: class default
        else:
            if cov_kwds is None:
                cov_kwds = {}
            if 'use_t' in cov_kwds:
                # TODO: we want to get rid of 'use_t' in cov_kwds
                use_t_2 = cov_kwds.pop('use_t')
                if use_t is None:
                    use_t = use_t_2
                # TODO: warn or not?
            self.get_robustcov_results(cov_type=cov_type, use_self=True,
                                       use_t=use_t, **cov_kwds)

I'm not sure what's going on
TheilGLS does not use the cov_type in the RegressionResults instantiation which implies cov_type='nonrobust'

lfit = TheilRegressionResults(self, params,
                       normalized_cov_params=normalized_cov_params, use_t=use_t)

this avoids going through self.get_robustcov_results which doesn't support the TheilGLS cov_types.

(maybe some bug still in #5296 that I cannot see yet.)

Activity

  1. josef-pkt commented on Oct 19, 2018

    @josef-pkt
    MemberAuthor

    There is a bug if cov_type='nonrobust', then self.use_t is never set if use_t is not None:

  2. changed the title [-]REF: Regression Results use_t wrong if cov_type='nonrobust'[/-] [+]BUG/REF: Regression Results use_t wrong if cov_type='nonrobust'[/+] on Oct 19, 2018
  3. added this to the 0.10 milestone on Dec 6, 2018
  4. bashtage commented on Jul 30, 2026

    @bashtage
    Member

    Fixed by commit d6491c3 (same day as filing), which made self.use_t = use_t unconditional in RegressionResults.init (statsmodels/regression/linear_model.py) rather than only inside the "if use_t is None" branch. Closing as fixed.

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions