Reputation: 21
I am using the graph_model function under "reghelper" package to plot interaction plot for my multilevel model.
My y and x are both continuous variables, I also have a moderator (m) and a covariate (n) which are categorical variables. Here's my code:
model <- lmer (y ~ x + m + x*m + n + (1|ID), data=data)
graph_model (model, y=y, x=x, lines=m)
However, I encountered the following error with the graph_model: "Error in factor(grid[[term]], labels = c("-1 SD", "+1 SD")):invalid 'labels'; length 2 should be 1 or 0".
I tried to
In both conditions, the error disappeared, and code ran successfully. But I wonder how I can get the code run by treating the categorical variables n and m still as factors, rather than z-scored?
Thank you!
Upvotes: 2
Views: 222