I'm trying to add the datapoints using geom_point() to the plot_model() that is showing the linear relationship between the age and left.LGN variables.
plot <- plot_model(m1, terms = c("age"), type = "pred") +
geom_point(data = data, aes(x = age, y = Left.LGN)) +
labs(x = "Age (standardized)", y = "Adj. Left-LGN (standardized volume)", size = 20)
The script works until I add the third variable ("sex"):
plot <- plot_model(m1, terms = c("age", "sex"), type = "pred") +
geom_point(data = data, aes(x = age, y = Left.LGN, color = sex, group = sex)) +
labs(x = "Age (standardized)", y = "Adj. Left-LGN (standardized volume)", size = 20)
in which I got this error:
Error in `geom_point()`:
! Problem while computing aesthetics.
ℹ Error occurred in the 3rd layer.
Caused by error in `FUN()`:
! object 'group_col' not found
Run `rlang::last_error()` to see where the error occurred.
Has anybody had the same issue?
I expect to have a plot showing the relationship between age and Left-LGN volume related to males and females, adding the datapoints from the data.


