Exploratory analyses for linear regression models with multiple response, predictor, and two-way interaction variables. (lmer
models).
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
This function also do not supports changing random slopes.
lme_model_explore(
...,
data,
response_variable,
predictor_variable,
two_way_interaction_variable = NULL,
three_way_interaction_variable = NULL,
random_effect,
control_variable = NULL,
marginal_alpha = 0.1,
return_result = FALSE,
print_control = FALSE,
verbose = TRUE,
show_p = TRUE,
show_formula = FALSE
)
additional parameters pass to lme4::lmer()
data.frame
Response variable. Support dplyr::select()
syntax.
Pred variable. Support dplyr::select()
syntax.
Two-way interaction variable. Each two-way interaction variable will interact with each pred variable. Support dplyr::select()
syntax.
Three-way interaction variable. Each three-way interaction variable will interact with each pred and two-way interaction variables. Support dplyr::select()
syntax.
The random-effects terms in the format of (|)
. See lm4::lmer for specifics.
Control variables. Support dplyr::select()
syntax.
Set marginal_alpha level for marginally significant (denoted by .
). Set to 0.05 if do not want marginally significant denotation.
Default is FALSE
. If TRUE
, it returns the model estimates as a data frame.
Default is FALSE
. If TRUE
, print coefficients of control variables.
Default is TRUE
. Set to FALSE
to suppress outputs
Default is TRUE
. When TRUE
, show the p-value in parenthesis.
Default is FALSE
. Set to TRUE
to show the formula.
data.frame
lme_model_explore(data = popular,
response_variable = c(popular,extrav),
predictor_variable = c(texp),
two_way_interaction_variable = sex,
random_effect = '(1 | class)')
#> ─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
#> Response Pred Interact_pred Interact_term Interact_term_coef Interact_pred_coef Pred_coef (Intercept) df conditional_r2 marginal_r2
#> ─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
#> popular texp sex texp*sex -0.016 (0.025) * 1.577 (0.000) *** 0.063 (0.000) *** 3.502 (0.000) *** 1994.000 0.540 0.344
#> extrav texp sex texp*sex -0.018 (0.029) * 0.482 (0.000) *** -0.066 (0.000) *** 6.047 (0.000) *** 1994.000 0.261 0.160
#> ─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
#> You can drag and resize the R console to view the entire table
#> Note: Coefficient (p-value): + p < 0.1, * p < 0.05, ** p < 0.01, *** p < 0.001