Skip to content

ENH: add dk_params option to GLM info_criteria - #7693

Merged
josef-pkt merged 2 commits into
statsmodels:mainfrom
josef-pkt:glm_aic_dkparams
Sep 6, 2021
Merged

josef-pkt merged 2 commits into
statsmodels:mainfrom
josef-pkt:glm_aic_dkparams

Conversation

@josef-pkt

@josef-pkt josef-pkt commented Sep 6, 2021 •

Copy link
Copy Markdown
Member

closes #6577 aic
#1802 bic and FAQ

this adds dk_params to GLMResults.info_criteria
default is unchanged

@josef-pkt

Copy link
Copy Markdown
Member Author

aside: R seems strange:
qaic test has the following comment

    # R gives 31.13266 because it uses a df that is 1 greater,
    # presumably because they count the scale parameter in df.
    # This won't matter when comparing models by differencing
    # QAICs.

with new dk_params=1, the unit test passes for 31.13266

However, Binomial does not have a scale parameter, so adding +1 is not correct.

@josef-pkt

Copy link
Copy Markdown
Member Author

Note: handling of freq_weights

nobs in info_criteria (and old bic) is computed using df_resid
df_resid uses wnobs, i.e. takes freq_weights into account.
self.df_resid = self.wnobs - self.df_model - 1

This looks correct for automatically including wnobs in information criteria.
But it looks like we can use self.model.wnobs directly (it seems to always exist in GLM based on reading that code)

It's not relevant for aic because that does not directly depend on (w)nobs.

@josef-pkt

josef-pkt commented Sep 6, 2021 •

Copy link
Copy Markdown
Member Author

Trying the same for RegressionResults causes failure in Rolling regression

>       return self.info_criteria("aic")
E       AttributeError: 'RollingRegressionResults' object has no attribute 'info
_criteria'

...\statsmodels\statsmodels\regression\linear_model.py:1829: AttributeError

RollingRegressionResults does not subclass any results class, but wraps methods of RegressionResults explicitly.
RollingRegressionResults does not use a PandasWrapper results class as the rest of statsmodels.

pretty dirty, need to call a method of a class directly.

@josef-pkt

josef-pkt commented Sep 6, 2021 •

Copy link
Copy Markdown
Member Author

as followup to this PR: TIC, GBIC is in
commit "ENH: add im_ratio, tic and gbic to discrete" of #7166
02f7bce

can be added to info_criteria results methods.

@josef-pkt

Copy link
Copy Markdown
Member Author

added definition test for aicc and hqic in regression (not verified outside numbers)

can be merged when green

@josef-pkt

josef-pkt commented Sep 6, 2021 •

Copy link
Copy Markdown
Member Author

closes #6577, #1802 for dk_params, but I leave other ENH like more AICC, TIC, ... open

update: I will keep #1802 open as a FAQ. Users will still be surprised when comparing to R.

@josef-pkt
josef-pkt merged commit 2fb1f97 into statsmodels:main Sep 6, 2021
@josef-pkt
josef-pkt deleted the glm_aic_dkparams branch September 6, 2021 20:03
@josef-pkt josef-pkt added this to the 0.13 milestone Sep 6, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

AIC value inconsistent with R

1 participant