'Error message when making QQ plots of residuals (lmer)
Does anyone know how to fix this error when trying to make QQ plots of residuals, data and code below;
head(final_data)
Country Continent Life_Expectancy
1 Afghanistan Eastern Mediterranean 62.68935
2 Albania Europe 76.37373
3 Algeria Africa 76.36365
4 Angola Africa 62.63262
5 Antigua and Barbuda Americas 74.99754
6 Argentina Americas 76.94621
mod6 = lmer(Life_Expectancy ~ Concentration_of_PM2.5 +
(1|Continent),
data=final_data)
res5 = data.frame(Residuals=resid(mod5),
Continent=final_data$Continent,
Fitted=fitted(mod5))
qq_plot6 = ggplot(final_data, aes(sample = mod6$residuals)) +
geom_qq() +
geom_qq_line(col = 'red') +
xlab('Theoretical residuals') +
ylab('Sample residuals') +
ggtitle('QQ plot for residual mod6') +
theme(plot.title = element_text(hjust = 0.5))
I get this error when making the QQ plot here:
Error in mod6$residuals : $ operator not defined for this S4 class
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
