I have a model with several fixed and random variables.
Here is the code:
model1<-lmer(dep ~ pred + sex + age + heat + (1|ID) + (1|year),data=data)
So, by running a ggplot I get this graph
However, the ggplot, and the geom_smooth()
function will only plot the slope and confidence intervals calculated between dep
and pred
.
But it will not take into account the other factors, including random terms
Indeed, with the code
Effect("pred",model1)
I get a different and probably real slope
pred effect
600 1000 2000 3000 4000
-0.14747707 -0.10876855 -0.01199725 0.08477404 0.18154534
Is there a way to plot the slope and the real confidence interval area of a lmer
?
UPDATE: I was able to get a graph with the good coordinates and confidence intervals using plot(effect("pred",model1))
And this is how looks like:
But how can I now make this graph look decent? Or how can I plot this in ggplot or similar so that I can modify everything?