Srini
Srini

Reputation: 97

I think I am getting different AIC & BIC values in a regression model built using statsmodel package in Python

I built a single factor (univariate regression) model and when I do

aic = results.aic 

and when do

aic = results.nobs*np.log(results.ssr/results.nobs) + 4 

I get different outputs. Which one is correct?

The second formula gives the same results as SAS Base 9.4 outputs

  aic = results.aic #from statsmodel packages
  aic = results.nobs*np.log(results.ssr/results.nobs) + 4

Upvotes: 1

Views: 936

Answers (1)

s3nh
s3nh

Reputation: 556

Calculation between AIC in statsmodels and SAS differ when it comes to model dimension interpretation.

In statmodels, aic looks like:

Statsmodels Eval_metrics source code

def aic(llf, nobs, df_modelwc):

    return -2. * llf + 2. * df_modelwc

where df_modelwc is

df_modelwc : int
        number of parameters including constant

while in SAS interpretation:

SAS Mixed Procedure Documentation

AIC looks like

-2LL + 2d, where 'd is an effective number of estimated covariance parameters'.

Both of the interpretations are correct, but you cannot compare goodness of fit measure based on interpretation from two different sources.

Upvotes: 2

Related Questions