prepare_regression_table {ExPanDaR} | R Documentation |
Prepares a Regression Table
Description
Builds a regression table based on a set of user-specified models or a single model and a partitioning variable.
Usage
prepare_regression_table(
df,
dvs,
idvs,
feffects = rep("", length(dvs)),
clusters = rep("", length(dvs)),
models = rep("auto", length(dvs)),
byvar = "",
format = "html"
)
Arguments
df |
Data frame containing the data to estimate the models on. |
dvs |
A character vector containing the variable names for the dependent variable(s). |
idvs |
A character vector or a a list of character vectors containing the variable names of the independent variables. |
feffects |
A character vector or a a list of character vectors containing the variable names of the fixed effects. |
clusters |
A character vector or a a list of character vectors containing the variable names of the cluster variables. |
models |
A character vector indicating the model types to be estimated ('ols', 'logit', or 'auto') |
byvar |
A factorial variable to estimate the model on (only possible if only one model is being estimated). |
format |
A character scalar that is passed on |
Details
This is a wrapper function calling the stargazer package. For numeric
dependent variables the models are estimated using lm
for models without and plm
for models with fixed
effects. Binary dependent variable models are estimated using
glm
(with family = binomial(link="logit")
).
You can override this behavior by specifying the model with the
models
parameter. Multinomial logit models are not supported.
Clustered standard errors are estimated using plm
's robust
covariance matrix estimators for OLS and
cluster.vcov
for logit models.
Only up to two dimensions are supported for fixed effects and standard
error clusters need to be also present as fixed effects.
If run with byvar
, only levels that have more observations than
coefficients are estimated.
Value
A list containing two items
- "models"
A list containing the model results and by values if appropriate
- "table"
The output of
stargazer
containing the table
Examples
df <- data.frame(year = as.factor(floor(stats::time(datasets::EuStockMarkets))),
datasets::EuStockMarkets)
dvs = c("DAX", "SMI", "CAC", "FTSE")
idvs = list(c("SMI", "CAC", "FTSE"),
c("DAX", "CAC", "FTSE"),
c("SMI", "DAX", "FTSE"),
c("SMI", "CAC", "DAX"))
feffects = list("year", "year", "year", "year")
clusters = list("year", "year", "year", "year")
t <- prepare_regression_table(df, dvs, idvs, feffects, clusters, format = "text")
t$table
t <- prepare_regression_table(df, "DAX", c("SMI", "CAC", "FTSE"), byvar="year", format = "text")
print(t$table)