Model diagnostics Tim Paine, modified from Zarah Pattison’s slides
When conducting any statistical analysis it is important to evaluate how well the model fits the data and that the data meet the assumptions of the model. For linear models: Residuals are independently drawn from a normal distribution with a mean of 0 and a constant variance. Residuals: the distance of the data points from the fitted regression line
Constancy of variance A residual plot is a graph that shows the residuals on the vertical axis and the fitted values of the response on the horizontal axis. If the points in a residual plot are randomly dispersed around the horizontal axis, a linear regression model is appropriate for the data
QQ PLOTS Test for normality Ranked samples from our distribution plotted against a similar no. of ranked quantiles taken from a ND 1,6,9 good I find them of little use.
Constancy of variance Constant variance means that when you plot the residuals against the predicted values, the variance of the error of the predicted values should be constant. See that the length of the red lines are all the same. Synonym: homoscedasticity Antonym: heteroscedasticity
Ideal examples : Residuals versus fitted value plots
Residuals appear exhibit homogeneity, normality, and independence Residuals appear exhibit homogeneity, normality, and independence. However, the variation in residuals associated with the predictor variable Month suggests a problem with heterogeneity
Sop <- lmer(log(subnatcov+1) ~ loi + P + ss + channel.slope + domnatcov + iapcov*avmoisture+iapcov*cov + (1|river )+ (1|trans), data=finalscale, REML=FALSE)
Try a square root transformation
Sop <- lmer(sqrt(subnatcov+1) ~ loi + P + ss + channel.slope + domnatcov + iapcov*avmoisture+iapcov*cov + (1|river )+ (1|trans), data=finalscale, REML=FALSE)