With a lmer model, can I extract the fitted values of 'y' for the whole model
I am a novice with R and this is a very basic question. I am using lmer to fit a mixed model to a data frame, as follows:
model1=lmer(Mass~Season + Area + Month + (1|Season:Month), data=Transdata)
and then using ggplot2
to plot the fitted data and various diagnostics. For example, for fitted values:
ggplot(model1, aes(x = Season, y = Mass)) + geom_point()
gives me a plot of Mass per Season, shown separately for each of the 3 different areas and 4 different months. Is there a way in which I can get a single estimate of the mean Mass per Season integrated across the different Areas and Months (i.e. from the fixed effects), and e.g. the SEs for each estimate?
Solution 1:
Is there a way in which I can get a single estimate of the mean Mass per Season integrated across the different Areas and Months (i.e. from the fixed effects), and e.g. the SEs for each estimate?
If I have understood the question properly, surely just the output from summary(model1)
will provide this. It will give a separate estimate for each level of Season, apart from the reference level, and each estimate is then the expected difference in Mass
for each Season
relative to the reference level, keeping the other fixed effects constant, which would seem to answer your question.
Edit: After re-reading the question, the title seems to ask a different question to the body. As for the title:
With a lmer model, can I extract the fitted values of 'y' for the whole model
Yes, you can simply run
fitted(model1)