我想我在 Python 中使用 statsmodel 包构建的回归模型中得到了不同的 AIC 和 BIC 值
I think I am getting different AIC & BIC values in a regression model built using statsmodel package in Python
我构建了一个单因素(单变量回归)模型,当我这样做时
aic = results.aic
什么时候做
aic = results.nobs*np.log(results.ssr/results.nobs) + 4
我得到了不同的输出。哪一个是正确的?
第二个公式给出与 SAS Base 9.4 输出相同的结果
aic = results.aic #from statsmodel packages
aic = results.nobs*np.log(results.ssr/results.nobs) + 4
在模型维度解释方面,statsmodels 和 SAS 中的 AIC 之间的计算不同。
在统计模型中,aic 看起来像:
Statsmodels Eval_metrics source code
def aic(llf, nobs, df_modelwc):
return -2. * llf + 2. * df_modelwc
其中 df_modelwc 是
df_modelwc : int
number of parameters including constant
在 SAS 解释中:
SAS Mixed Procedure Documentation
AIC 看起来像
-2LL + 2d,
其中 'd is an effective number of estimated covariance parameters'。
这两种解释都是正确的,但是您不能比较基于来自两个不同来源的解释的拟合优度度量。
我构建了一个单因素(单变量回归)模型,当我这样做时
aic = results.aic
什么时候做
aic = results.nobs*np.log(results.ssr/results.nobs) + 4
我得到了不同的输出。哪一个是正确的?
第二个公式给出与 SAS Base 9.4 输出相同的结果
aic = results.aic #from statsmodel packages
aic = results.nobs*np.log(results.ssr/results.nobs) + 4
在模型维度解释方面,statsmodels 和 SAS 中的 AIC 之间的计算不同。
在统计模型中,aic 看起来像:
Statsmodels Eval_metrics source code
def aic(llf, nobs, df_modelwc):
return -2. * llf + 2. * df_modelwc
其中 df_modelwc 是
df_modelwc : int
number of parameters including constant
在 SAS 解释中:
SAS Mixed Procedure Documentation
AIC 看起来像
-2LL + 2d, 其中 'd is an effective number of estimated covariance parameters'。
这两种解释都是正确的,但是您不能比较基于来自两个不同来源的解释的拟合优度度量。