I am estimating a model using survey design and robust errors, and I am trying to display the results with stargazer. However, I haven't been able to add basic information, such as number of observations, R2, Adjusted R2, Residual Std. Error and F Statistic, at the end of the table.
My code is something like this (I abbreviated the model):
# 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')
But I do not know how to add those statistics.
The problem is that
svyglmdoes not produce statistics like R-squared that can then be passed tostargazer. It seems that you would have to calculate these additional statistics of interest yourself and then pass them tostargazerusing theadd.linesparameter ofstargazer. You can read aboutadd.linesin thestargazerdocumentation here: https://cran.r-project.org/web/packages/stargazer/stargazer.pdf.Here would be a reproducible example:
These other posts ask similar questions about calculating these statistics from
svyglm()and may be helpful to you in doing this: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.