使用`texreg`来显示AIC,BIC GOF统计信息

问题描述 投票:2回答:1

我正在使用texreg生成回归输出表。我想将AIC,BIC和HQIC之类的统计信息包括在“拟合优度”统计信息中。

下面的可复制示例

library(texreg)
library(tidyverse)
mtcars
model1 <- lm(mpg ~ disp, data = mtcars)
model2 <- lm(mpg ~ disp + hp, data = mtcars)
screenreg(list(model1, model2))

给我这个:

=================================
             Model 1    Model 2  
---------------------------------
(Intercept)  29.60 ***  30.74 ***
             (1.23)     (1.33)   
disp         -0.04 ***  -0.03 ***
             (0.00)     (0.01)   
hp                      -0.02    
                        (0.01)   
---------------------------------
R^2           0.72       0.75    
Adj. R^2      0.71       0.73    
Num. obs.    32         32       
RMSE          3.25       3.13    
=================================
*** p < 0.001, ** p < 0.01, * p < 0.05

这很棒,但是除了R ^ 2,RMSE等,我还要AIC,BIC和HQIC(如果可能)。

编辑:

回答下面的评论,确实答案不一定来自texreg,但是我正在寻找一个答案,该答案可以产生某种格式的html表,这些表看起来可以提交给学术期刊了,例如stargazertexregsjPlot

r stargazer sjplot texreg
1个回答
0
投票

AIC和BIC基于最大对数似然。 lm函数使用普通的最小二乘而不是最大似然估计。因此,没有可能性,也没有AIC或BIC。但是,要获得AIC和BIC,您可以使用glm函数和高斯链接函数来估计模型,在这种情况下,默认情况下您将获得AIC和BIC:

library("texreg")
model1 <- glm(mpg ~ disp, data = mtcars, family = "gaussian")
model2 <- glm(mpg ~ disp + hp, data = mtcars, family = "gaussian")
screenreg(list(model1, model2))

结果:

======================================
                Model 1     Model 2   
--------------------------------------
(Intercept)      29.60 ***   30.74 ***
                 (1.23)      (1.33)   
disp             -0.04 ***   -0.03 ***
                 (0.00)      (0.01)   
hp                           -0.02    
                             (0.01)   
--------------------------------------
AIC             170.21      168.62    
BIC             174.61      174.48    
Log Likelihood  -82.10      -80.31    
Deviance        317.16      283.49    
Num. obs.        32          32       
======================================
*** p < 0.001; ** p < 0.01; * p < 0.05

您可以通过使用screenreg自变量include.loglik = FALSEinclude.deviance = FALSE等来消除GOF块中的对数似然,偏差等

© www.soinside.com 2019 - 2024. All rights reserved.