View source: R/helper_starprep.R
starprep | R Documentation |
Prepare model fits for stargazer
starprep(
...,
stat = c("std.error", "statistic", "p.value", "ci", "df"),
se_type = NULL,
clusters = NULL,
alpha = 0.05
)
... |
a list of lm_robust or lm objects |
stat |
either "std.error" (the default), "statistic" (the t-statistic), "p.value", "ci", or "df" |
se_type |
(optional) if any of the objects are lm objects, what standard
errors should be used. Must only be one type and will be used for all lm
objects passed to starprep. See |
clusters |
(optional) if any of the objects are lm objects, what clusters
should be used, if clusters should be used. Must only be one vector and will
be used for all lm objects passed to starprep. See |
alpha |
(optional) if any of the objects are lm objects, what significance level should be used for the p-values or confidence intervals |
Used to help extract statistics from lists of model fits for stargazer.
Prefers lm_robust objects, but because stargazer
does not work with lm_robust
objects, starprep
can also take lm
objects and calls commarobust
to get
the preferred, robust statistics.
a list of vectors of extracted statistics for stargazers
library(stargazer)
lm1 <- lm(mpg ~ hp, data = mtcars)
lm2 <- lm(mpg ~ hp + wt, data = mtcars)
# Use default "HC2" standard errors
stargazer(lm1, lm2,
se = starprep(lm1, lm2),
p = starprep(lm1, lm2, stat = "p.value"),
omit.stat = "f")
# NB: We remove the F-stat because stargazer only can use original F-stat
# which uses classical SEs
# Use default "CR2" standard errors with clusters
stargazer(lm1, lm2,
se = starprep(lm1, lm2, clusters = mtcars$carb),
p = starprep(lm1, lm2, clusters = mtcars$carb, stat = "p.value"),
omit.stat = "f")
# Can also specify significance levels and different standard errors
stargazer(lm1, lm2,
ci.custom = starprep(lm1, lm2, se_type = "HC3", alpha = 0.1, stat = "ci"),
omit.stat = "f")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.