The function creates a two-way interaction plot. It will creates a plot with ± 1 SD from the mean of the independent variable. See below for supported model. I recommend using concurrently with lm_model(), lme_model().

three_way_interaction_plot(
model,
data = NULL,
cateogrical_var = NULL,
graph_label_name = NULL,
y_lim = NULL,
plot_color = FALSE
)

## Arguments

model

object from lme, lme4, lmerTest object.

data

data frame. If the function is unable to extract data frame from the object, then you may need to pass it directly

cateogrical_var

list. Specify the upper bound and lower bound directly instead of using ± 1 SD from the mean. Passed in the form of list(var_name1 = c(upper_bound1, lower_bound1),var_name2 = c(upper_bound2, lower_bound2))

graph_label_name

vector of length 4 or a switch function (see ?two_way_interaction_plot example). Vector should be passed in the form of c(response_var, predict_var1, predict_var2, predict_var3).

y_lim

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

plot_color

default if FALSE. Set to TRUE if you want to plot in color

## Value

a ggplot object

## Details

It appears that predict cannot handle categorical factors. All variables are converted to numeric before plotting.

## Examples

# I am going to show the more generic usage of this function
# You can also use this package's built in function to fit the models
# I recommend using the integrated_multilevel_model_summary to get everything

# lme example
lme_fit <- lme4::lmer("popular ~ extrav + sex + texp + extrav:sex:texp +
(1 + extrav + sex | class)", data = popular)
#> boundary (singular) fit: see help('isSingular')

three_way_interaction_plot(lme_fit, data = popular)

# lm example

lm_fit <- lm(Sepal.Length ~ Sepal.Width + Petal.Length + Petal.Width +
Sepal.Width:Petal.Length:Petal.Width, data = iris)

three_way_interaction_plot(lm_fit, data = iris)

`