Skip to contents

Checks the assumptions behind an analysis of variance: normality of residuals (Shapiro-Wilk), homogeneity of variances across treatments (Bartlett and Levene/Brown-Forsythe), additivity of block and treatment effects (Tukey's one-degree-of-freedom test, for two-way models), serial independence (Durbin-Watson, in data order) and outliers (studentized residuals).

Usage

check_assumptions(model, verbose = TRUE, factor = NULL, plot = FALSE)

Arguments

model

A fitted aov or lm model.

verbose

Logical. If TRUE (default), prints the results.

factor

Name(s) of the factor(s) defining the groups for the variance tests. Default NULL uses the last main-effect factor in the model (the treatment in y ~ block + treatment). Give several names to use their combinations.

plot

Logical. If TRUE, draws the four standard residual plots with base graphics. Default FALSE.

Value

A list with shapiro, bartlett, levene, nonadditivity (where applicable), durbin_watson, outliers (row indices with |studentized residual| > 3) and groups_factor.

Details

The variance tests use the model residuals, so block effects do not inflate the group variances. Levene's test is the Brown-Forsythe form (absolute deviations from the group median). Tukey's test for non-additivity adds the squared fitted values as a one-degree-of-freedom covariate to a model with two additive factors; a significant result suggests a transformation (Gomez and Gomez, 1984, ch. 7). The Durbin-Watson statistic is only meaningful when the rows are in field or time order.

References

Tukey, J.W. (1949). One degree of freedom for non-additivity. Biometrics, 5(3), 232-242. doi:10.2307/3001938

Brown, M.B. and Forsythe, A.B. (1974). Robust tests for the equality of variances. Journal of the American Statistical Association, 69(346), 364-367. doi:10.1080/01621459.1974.10482955

Examples

data(mothbean_rbd)
fit <- aov(seed_yield ~ block + treatment, data = mothbean_rbd)
check_assumptions(fit)
#> 
#> ======================================================================
#>  ANOVA ASSUMPTION CHECKS
#> ======================================================================
#>  Normality (Shapiro-Wilk)       : W = 0.9717, p = 0.5473  OK
#>  Equal variances (Bartlett)     : K2 = 6.828, p = 0.4470  OK
#>  Equal variances (Levene)       : F = 1.210, p = 0.3354  OK
#>  Additivity (Tukey 1 df)        : F = 1.457, p = 0.2414  OK
#>  Durbin-Watson (data order)     : 2.745
#>  No studentized residual exceeds 3 in absolute value.
#>  Variance tests compare groups of: treatment