lm_model_explore: Exploratory Linear Regression Model Table

View source: R/lm_model_explore.R

lm_model_exploreR Documentation

Exploratory Linear Regression Model Table

Description

[Experimental]
Exploratory analyses for linear regression models with multiple response, predictor, and two-way interaction variables. (lm 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

Usage

lm_model_explore(
  data,
  response_variable,
  predictor_variable,
  two_way_interaction_variable = NULL,
  three_way_interaction_variable = NULL,
  control_variable = NULL,
  marginal_alpha = 0.1,
  verbose = TRUE,
  show_p = TRUE,
  return_result = FALSE,
  print_control = FALSE,
  plot_interaction = FALSE,
  file_dir = NULL,
  device = "jpeg",
  width = 8.5,
  height = 5,
  units = "in",
  y_lim = NULL
)

Arguments

data

data.frame

response_variable

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

predictor_variable

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

two_way_interaction_variable

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

three_way_interaction_variable

Three-way interaction variable. Each three-way interaction variable will interact with each pred and two-way interaction variables. Support dplyr::select() syntax.

control_variable

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

marginal_alpha

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

verbose

Default is TRUE. Set to FALSE to suppress outputs

show_p

Default is TRUE. When TRUE, show the p-value in parenthesis.

return_result

Default is FALSE. If TRUE, it returns the model estimates as a data frame.

print_control

Default is FALSE. If TRUE, print coefficients of control variables.

plot_interaction

Default is FALSE. If TRUE, interactions will be plotted and saved on your laptop.

file_dir

Path of the directory to save plot to

device

Default is "jpeg". See ggplot2::ggsave() for all options.

width

Default is 8.5 (i.e., letter size width).

height

Default is 5.

units

Default is inches. Options are "in", "cm", "mm" or "px".

y_lim

the plot's upper and lower limit for the y-axis. Length of 2. Example: c(lower_limit, upper_limit)

Value

data.frame

Examples


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)
)


lm_model_explore(data = test, 
                 response_variable = c(y1,y2,y3),
                 predictor_variable = c(x1,x2,x3),
                 two_way_interaction_variable = c(m1,m2,m3),
                 control_variable = c(c1,c2,c3))


jasonmoy28/psycModel documentation built on Sept. 6, 2024, 11:45 a.m.