我正在使用调查设计和稳健误差估计模型,并尝试使用stargazer显示结果。但是,我无法在表末添加基本信息,例如观测数、R2、调整后R2、残差标准误差和F统计量。
我的代码是这样的(我缩写了模型):
# Svy design.
svy <- svydesign(id = ~conglomerado,
strata = ~estrato,
check.strata = TRUE,
weights = ~fact_cal_esi,
data = subset(completos, ocup_ref==1))
# Estimation.
short_model <- svyglm(ln_w ~ sex + age + factor(level),
design=svy)
short_model_r <- coeftest(short_model , vcov = vcovHC(short_model , type = "HC1"))
# Table.
stargazer(models,type="text",
column.labels = c("Short model"),
title = 'Table 1: Short model')
字符串
但我不知道如何添加这些统计数据。
1条答案
按热度按时间jvidinwx1#
问题是
svyglm
不会产生像R平方这样的统计信息,而这些统计信息又不能传递给stargazer
。看来您必须自己计算这些额外的统计信息,然后使用stargazer
的add.lines
参数将它们传递给stargazer
。您可以在stargazer
文档中阅读有关add.lines
的信息,网址是:https://cran.r-project.org/web/packages/stargazer/stargazer.pdf。下面是一个可重复的示例:
字符串
这些其他的帖子问了类似的问题,关于计算这些统计数据从
svyglm()
,并可能有助于您这样做:Survey-package: How do I get R-squared from a svyglm-object?,
https://stats.stackexchange.com/questions/618248/how-to-calculate-f-statistic-from-a-svyglm-model-in-r,
https://stats.stackexchange.com/questions/523152/different-ways-to-calculate-rsquared-after-regression-with-complex-survey-data-i的函数。