| pm_check | R Documentation |
A table of checks of a model's assumptions and structure, grouped in sections, with a plain note on each: the fit
itself (singular or not converged); the residuals (outliers, influence, normality, a transformation); the
variance (equal across factor levels, constant with the fitted values); the distribution of generalized models
(over- and underdispersion, excess zeros, separation); the design (balance and empty cells, aliasing,
collinearity, few levels of a random effect); and the terms (interactions, straight lines). For any model that
predictmeans handles.
pm_check(model, plot = FALSE)
model |
A fitted model, as for |
plot |
|
The checks inform; they do not decide. Rows marked ! are worth a look at the plots of
residplot; rows marked i are information. Keep the terms the design calls for (blocks, whole
plots, the treatment structure): dropping a term because its test is not significant makes the later tests and
intervals too optimistic. Tests of normality and of equal variances reject small departures in large data sets
and miss large ones in small data sets; the plots say how large a departure is.
singular fits (a variance component estimated as zero) and convergence warnings.
residuals beyond 3 (of the residuals residplot uses: standardized, normalized or
randomized quantile), against the number expected for normal residuals; worth a look when that many, or one as
large as the largest (Bonferroni over the observations), has probability below 0.01.
(lm, aov, glm) the largest Cook's distance; above 0.5 is worth a look
(CookD for mixed models).
Shapiro-Wilk tests of the residuals and of each term's random effects (intercepts).
(lm and aov with a positive response that is not
transformed in the formula) the Box-Cox power the residuals favour: the profile likelihood estimate of
\lambda and its 95% interval (Box and Cox, 1964; as MASS::boxcox()). Worth a look when the
interval leaves out 1 (no transformation); the note names the usual transformation within the interval.
for each factor: the ratio of the largest to the smallest standard deviation of the residuals within its levels, and the Brown-Forsythe test (ANOVA of the absolute deviations from the medians).
(gaussian models) Spearman correlation of the absolute residuals with the fitted
values; worth a look when |\rho| \ge 0.2 and p < 0.01 (the variance grows with the mean).
(Poisson, binomial with more than one trial, negative binomial; glm, glmer,
glmmTMB) Pearson chi-square / residual df, about 1 when the variance function is right; overdispersion
(ratio > 1.5, p < 0.01) makes SEs too small, underdispersion (ratio < 0.7, p < 0.01) too large. For mixed
models the residual df counts the variance parameters, an approximation. A 0/1 response carries no information
on dispersion; for families with an estimated dispersion (Gamma, quasi) its estimate is shown.
(Poisson, negative binomial) the observed zeros against those simulated from the fitted model (200 simulations, fixed seed; the user's random numbers are not changed); worth a look when there are more (p < 0.01).
(binomial) fitted probabilities of 0 or 1, or coefficients beyond 10 on the logit scale or with standard errors above 50: the estimates and Wald tests of these terms are unreliable.
of the crossed fixed factors: balanced, unbalanced or with empty cells; unbalanced data
make Type I, II and III tests differ (see anova.lmerMod, section 'Which type of test').
coefficients dropped as aliased (empty cells or confounded factors).
(models of main effects only) the generalized variance inflation factor of each term,
GVIF^{1/(2 df)} (Fox and Monette, 1992); above \sqrt{10} is worth a look.
a grouping factor with fewer than 5 levels: its variance is poorly estimated.
the Type III test of each interaction term (as permmodels(type = "III")).
for a factor with numeric levels and at least three of them: the joint test of the
polynomial contrasts above the linear one (with the actual spacing of the levels), from pm_joint.
A data frame of class "pm_check": section, check, result, p.value,
look, status ("!" worth a look, "i" information, "OK") and note;
printed by section with the notes below. summary() keeps only the rows worth a look. The rows worth a
look are also kept as advice (advice).
Dongwen Luo, Siva Ganesh and John Koolaard
Fox, J. and Monette, G. (1992). Generalized collinearity diagnostics. Journal of the American Statistical Association, 87, 178-183.
residplot, CookD, advice, pm_boxcox
library(predictmeans)
Oats$nitro <- factor(Oats$nitro)
fm <- lmer(yield ~ nitro*Variety + (1|Block/Variety), data = Oats)
pm_check(fm)
# counts: overdispersion
gm <- glm(breaks ~ wool * tension, family = poisson, data = warpbreaks)
pm_check(gm)
summary(pm_check(gm))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.