Description Usage Arguments Details Value References Examples
View source: R/modular_regressions.r
The function allows to automatically specify a number of regression models based on an input of a dependent variable, independent variables, control variables, interaction terms, and model structure.
1 |
type |
|
fam |
|
dv |
|
cv |
|
iv |
|
mv |
|
fe |
|
robust_type |
Indicator which type of standard errors is to be computed: 0 - no clustering, 1 - clustering using |
var_cluster |
Vector, matrix, or data.frame containing the variables that are used for clustering |
data |
|
full_model |
|
show |
|
show_cv |
|
The function runs a series of models of type and familiy. When type == "glmer" is selected, the variables defined in fe are used to compute random intercepts, i.e. "(1 | fe)". First, the function runs a controls only model regressing cv on dv. Next, a base model is computed as dv = f(cv + iv). Then a series of interaction models with all combinations of iv and mv is computed. If full_model is set to TRUE, a full model with all combinations of iv and mv in it is added.
For type "glm" the options robust_type == 0, robust_type == 1, and robust_type == 2 control how the variance-covariance matrix for standard error estimation is computed. The options robust_type == 1 and robust_type == 2 require a cluster variable defined in var_cluster.
type "glmer" requires one or more variables to compute fixed effects defined in fe.
The output is a list of three elements, named "coefficents", "p.values", and "std.errors". Each of the list elements shows the coeffient estimates, p-values, and standard errors for the computed models, respectively.
When the option show is set to TRUE the output is printed to the console. If the package knitr is available, the output is printed using knitr::kable. When show and show_cv are set to TRUE the output is printed using package stargazer.
model_vcov, lmer, glmer
1 2 3 4 5 6 7 8 9 | data <- supportR::create_data()
modular_regressions(type = "glm", fam = "gaussian", dv = "firm_value", cv = c("rnd", "competition", "quality"), iv = "profit", mv = c("cogs", "board_size"), robust_type = 0, data = data, full_model = TRUE, show = TRUE, show_cv = FALSE)
modular_regressions(type = "glm", fam = "gaussian", dv = "firm_value", iv = "profit", mv = c("cogs", "board_size"), robust_type = 2, var_cluster = "industry", data = data, full_model = FALSE, show = TRUE, show_cv = FALSE)
modular_regressions(type = "glmer", fam = "gaussian", dv = "firm_value", cv = c("rnd", "competition", "quality"), iv = "profit", mv = c("cogs", "board_size"), fe = "industry", data = data, full_model = TRUE, show = FALSE, show_cv = FALSE)
modular_regressions(type = "glm", fam = "binomial", dv = "female_ceo", cv = c("rnd", "competition", "quality"), iv = "profit", mv = c("cogs", "board_size"), robust_type = 0, var_cluster = NULL, data = data, full_model = TRUE, show = TRUE, show_cv = TRUE)
modular_regressions(type = "glm", fam = "binomial", dv = "female_ceo", cv = c("rnd", "competition", "quality"), iv = "profit", mv = c("cogs", "board_size"), robust_type = 2, var_cluster = "industry", data = data, full_model = FALSE, show = TRUE, show_cv = FALSE)
modular_regressions(type = "glmer", fam = "binomial", dv = "female_ceo", iv = "profit", mv = c("cogs", "board_size"), fe = "industry", data = data, full_model = TRUE, show = TRUE, show_cv = FALSE)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.