prepare_regression_table: Prepares a Regression Table

Description Usage Arguments Details Value Examples

View source: R/prepapre_regression_table.R

Description

Builds a regression table based on a set of user-specified models or a single model and a partitioning variable.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
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 stargazer as type to determine the presentation format ("html", "text", or "latex").

Details

This is a wrapper function calling the stargazer package. Depending on whether the dependent variable is numeric, logical or a factor with two levels, the models are estimated using felm (for numeric dependent variables) or glm (with family = binomial(link="logit")) (for two-level factors or logical variables). You can override this behavior by specifying the model with the models parameter. Multinomial logit models are not supported. For glm, clustered standard errors are estimated using cluster.vcov. For felm, it is being run with cmethod='reghdfe' to make clustered standard errors consistent with Stata's 'reghdfe'. 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

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
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)

joachim-gassen/ExPanDaR documentation built on April 15, 2021, 6:07 p.m.