Generate tables with multiple response, predictor, or two-way interaction variables (only lm
models are supported).
You can pass multiple variables for one type of variable (either response, pred, or interaction) only.
If you want to pass multiple variables for multiple type of variable, try lm_model_explore instead.
At the moment, multi-categorical variables are not supported as predictors or interactions (but control is fine). Binary variable should be numeric
instead of factor
lm_model_table(
data,
response_variable,
predictor_variable,
two_way_interaction_variable = NULL,
control_variable = NULL,
other_parameters = NULL,
marginal_alpha = 0.1,
return_result = FALSE,
verbose = TRUE,
show_p = FALSE
)
data.frame
response variable. Support dplyr::select()
syntax.
predictor variable. Support dplyr::select()
syntax. It will automatically remove the response variable from predictor variable, so you can use contains()
or start_with()
safely.
Two-way interaction variable. Each two-way interaction variable will interact with the predictor variable. Support dplyr::select()
syntax.
control variables. Support dplyr::select()
syntax.
catch call for all other parameters that need to be entered (e.g., non-changing interaction terms). Have to be character
type.
the set marginal_alpha level for marginally significant (denoted by .
). Set to 0.05 if do not want marginally significant denotation.
It set to TRUE
, it return the model estimates data frame.
default is TRUE
. Set to FALSE
to suppress outputs
show the p-value in parenthesis
data.frame
# If you want all varibles to be changing, try lm_model_explore.
test = data.frame(y1 = rnorm(1000,2,3),
y2 = rnorm(1000,10,2),
y3 = rnorm(1000,1,4),
x1 = rnorm(1000,100,10),
x2 = rnorm(1000,10,1),
x3 = rnorm(1000,6,2),
m1 = rnorm(1000,3,1),
m2 = rnorm(1000,2,0.5),
m3 = rnorm(1000,9,0.1),
c1 = rnorm(1000,5,0.4),
c2 = rnorm(1000,2,0.2),
c3 = rnorm(1000,7,0.9)
)
# Changing response variable
lm_model_table(data = test,
response_variable = c(y1,y2,y3),
predictor_variable = x1,
control_variable = c(c1,c2,c3))
#> ──────────────────────────────────────────────────────────────
#> Parameter/Focal_response y1 y2 y3
#> ──────────────────────────────────────────────────────────────
#> (Intercept) -1.350 11.248 *** 0.007
#> x1 0.013 0.003 0.006
#> c1 0.362 0.018 -0.088
#> c2 -0.111 -0.869 ** -0.721
#> c3 0.063 0.008 0.295 *
#> df 995.000 995.000 995.000
#> r2 0.004 0.008 0.006
#> ──────────────────────────────────────────────────────────────
#> Note: + < 0.1, * p < 0.05, ** p < 0.01, *** p < 0.001
# Changing predictors
lm_model_table(data = test,
response_variable = y1,
predictor_variable = c(x1,x2,x3),
control_variable = c(c1,c2,c3))
#> ──────────────────────────────────────────────────────────
#> Parameter/Focal_pred x1 x2 x3
#> ──────────────────────────────────────────────────────────
#> (Intercept) -1.350 -1.635 0.078
#> Focal Predictor 0.013 0.176 + -0.027
#> c1 0.362 0.353 0.368
#> c2 -0.111 -0.153 -0.115
#> c3 0.063 0.053 0.063
#> df 995.000 995.000 995.000
#> r2 0.004 0.006 0.003
#> ──────────────────────────────────────────────────────────
#> Note: + < 0.1, * p < 0.05, ** p < 0.01, *** p < 0.001
# Changing interaction terms with a non-changing response variable
lm_model_table(data = test,
response_variable = y1,
predictor_variable = x1,
two_way_interaction_variable = c(m1,m2,m3),
control_variable = c(c1,c2,c3))
#> ────────────────────────────────────────────────────────────────────
#> Parameter/Focal_interact_term x1*m1 x1*m2 x1*m3
#> ────────────────────────────────────────────────────────────────────
#> (Intercept) -7.801 * -1.431 106.016
#> x1 0.071 * 0.018 -1.061
#> Focal_interact_pred 2.072 * 0.037 -11.916
#> c1 0.357 0.348 0.346
#> c2 -0.085 -0.074 -0.114
#> c3 0.080 0.064 0.054
#> Focal_interact_term -0.019 * -0.003 0.119
#> df 993.000 993.000 993.000
#> r2 0.011 0.006 0.006
#> ────────────────────────────────────────────────────────────────────
#> Note: + < 0.1, * p < 0.05, ** p < 0.01, *** p < 0.001
# A non-changing interaction term with changing response variables
lm_model_table(data = test,
response_variable = c(y1,y2,y3),
predictor_variable = x1,
other_parameters = c('x1*m1'),
control_variable = c(c1,c2,c3))
#> ──────────────────────────────────────────────────────────────
#> Parameter/Focal_response y1 y2 y3
#> ──────────────────────────────────────────────────────────────
#> (Intercept) -7.801 * 11.792 *** 3.658
#> x1 0.071 * -0.002 -0.032
#> c1 0.357 0.018 -0.084
#> c2 -0.085 -0.871 ** -0.763
#> c3 0.080 0.007 0.292 *
#> m1 2.072 * -0.175 -1.157
#> x1:m1 -0.019 * 0.002 0.012
#> df 993.000 993.000 993.000
#> r2 0.011 0.008 0.008
#> ──────────────────────────────────────────────────────────────
#> Note: + < 0.1, * p < 0.05, ** p < 0.01, *** p < 0.001