1

I have produced a graph of a significant interaction /model prediction from a three-way Linear mixed model, and I am now trying to incorporate the raw data points on top of this graph. I can create the graph of the model estimates using this code (graph attached):

mod.2 <-lm(logRTs ~ 
           bilec_total_input2*Away_Towards*Diagnosis, 
           data = trimmedRT)
summary(mod.2)

fit <- lm(logRTs ~ bilec_total_input2*Away_Towards*Diagnosis, 
          data = trimmedRT)
graph <- plot_model(fit, type = "pred", 
                  terms = c("bilec_total_input2", 
                            "Away_Towards", 
                            "Diagnosis"
                            )
                    )
plot_model(fit, type = "int") 

and I can produce a plot of the raw data using:

rawdatagraph <- ggplot(trimmedRT,
                       aes(bilec_total_input2, logRTs, 
                       colour = Away_Towards)
                      ) 
                      + geom_point() 
Graph + facet_grid(. ~ Diagnosis)

But I cannot combine the data. I have tried this:

rawdatagraph + ggplot(trimmedRT,
                      aes(bilec_total_input2, logRTs, colour = Away_Towards)
                      ) 
                      + geom_point() 
Graph + facet_grid(. ~ Diagnosis)

I have also tried:

graph + geom_point(data = trimmedRT, 
                  aes(x = logRTs, y = bilec_total_input2, 
                  colour= Away_Towards))
                   

I keep getting this message: Error in FUN(X[[i]], ...) : object 'group_col' not found.

graph of model prediction

Graph of raw data

  • Hi! Could you provide a reprex? https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example. Make sure, for example, that packages needed are indicated and provide either a sample of your data or even better reproduce the issue with a built-in dataset such as mtcars or iris. – Marcelo Avila Jun 20 '21 at 18:40

0 Answers0