| anova_plot | R Documentation | 
 
Plot categorical variable with barplot. Continuous moderator are plotted at ± 1 SD from the mean.
anova_plot(model, predictor = NULL, graph_label_name = NULL, y_lim = NULL)
| model | fitted model (usually  | 
| predictor | predictor variable. Must specified for non-interaction plot and must not specify for interaction plot. | 
| graph_label_name | vector or function. Vector should be passed in the form of  | 
| y_lim | the plot's upper and lower limit for the y-axis. Length of 2. Example:  | 
a ggplot object
# Main effect plot with 1 categorical variable
fit_1 = lavaan::HolzingerSwineford1939 %>% 
  dplyr::mutate(school = as.factor(school)) %>% 
  lm(data = ., grade ~ school)
anova_plot(fit_1,predictor = school)
# Interaction effect plot with 2 categorical variables 
fit_2 = lavaan::HolzingerSwineford1939 %>% 
  dplyr::mutate(dplyr::across(c(school,sex),as.factor)) %>% 
  lm(data = ., grade ~ school*sex)
anova_plot(fit_2)
# Interaction effect plot with 1 categorical variable and 1 continuous variable
fit_3 = lavaan::HolzingerSwineford1939 %>% 
  dplyr::mutate(school = as.factor(school)) %>% 
  dplyr::mutate(ageyr = as.numeric(ageyr)) %>% 
  lm(data = ., grade ~ ageyr*school)
anova_plot(fit_3)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.