[Experimental]
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
)

Arguments

data

data.frame

response_variable

response variable. Support dplyr::select() syntax.

predictor_variable

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

Two-way interaction variable. Each two-way interaction variable will interact with the predictor variable. Support dplyr::select() syntax.

control_variable

control variables. Support dplyr::select() syntax.

other_parameters

catch call for all other parameters that need to be entered (e.g., non-changing interaction terms). Have to be character type.

marginal_alpha

the set marginal_alpha level for marginally significant (denoted by .). Set to 0.05 if do not want marginally significant denotation.

return_result

It set to TRUE, it return the model estimates data frame.

verbose

default is TRUE. Set to FALSE to suppress outputs

show_p

show the p-value in parenthesis

Value

data.frame

Examples

# 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)   2.829      11.393 ***  -0.062    
#>                         x1   0.001       0.002      -0.012    
#>                         c1  -0.336      -0.112       0.454    
#>                         c2   0.529      -0.132       0.302    
#>                         c3  -0.034      -0.098      -0.088    
#>                         df     995.000     995.000     995.000
#>                         r2       0.003       0.003       0.004
#> ──────────────────────────────────────────────────────────────
#> 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)   2.829       2.692       2.275    
#>        Focal Predictor   0.001       0.020       0.081 +  
#>                     c1  -0.336      -0.333      -0.313    
#>                     c2   0.529       0.536       0.542    
#>                     c3  -0.034      -0.034      -0.031    
#>                     df     995.000     995.000     995.000
#>                     r2       0.003       0.003       0.006
#> ──────────────────────────────────────────────────────────
#> 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)   2.794       1.723      -115.748    
#>                              x1  -0.001       0.013         1.036    
#>             Focal_interact_pred  -0.002       0.556        13.195    
#>                              c1  -0.328      -0.334        -0.344    
#>                              c2   0.527       0.533         0.473    
#>                              c3  -0.034      -0.033        -0.038    
#>             Focal_interact_term   0.001      -0.006        -0.115    
#>                              df     993.000     993.000       993.000
#>                              r2       0.004       0.004         0.007
#> ─────────────────────────────────────────────────────────────────────
#> 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)   2.794      13.474 ***  -2.142    
#>                         x1  -0.001      -0.022       0.005    
#>                         c1  -0.328      -0.106       0.469    
#>                         c2   0.527      -0.143       0.306    
#>                         c3  -0.034      -0.097      -0.086    
#>                         m1  -0.002      -0.711       0.674    
#>                      x1:m1   0.001       0.008      -0.006    
#>                         df     993.000     993.000     993.000
#>                         r2       0.004       0.006       0.004
#> ──────────────────────────────────────────────────────────────
#> Note: + < 0.1, * p < 0.05, ** p < 0.01, *** p < 0.001