Fit a linear regression using lm()
. Linear regression is used to explore the effect of continuous variables / categorical variables in predicting a normally-distributed continuous variables.
lm_model(
data,
response_variable,
predictor_variable,
two_way_interaction_factor = NULL,
three_way_interaction_factor = NULL,
quite = 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 factors. You need to pass 2+ factor. Support dplyr::select()
syntax.
three-way interaction factor. You need to pass exactly 3 factors. Specifying three-way interaction factors automatically included all two-way interactions, so please do not specify the two_way_interaction_factor argument. Support dplyr::select()
syntax.
suppress printing output
an object class of lm
representing the linear regression fit
fit <- lm_model(
data = iris,
response_variable = Sepal.Length,
predictor_variable = dplyr::everything(),
two_way_interaction_factor = c(Sepal.Width, Species)
)
#> Fitting Model with lm:
#> Formula = Sepal.Length ~ Sepal.Width + Petal.Length + Petal.Width + Species + Sepal.Width*Species