Skip to contents

Analysis of experiments in which the same experimental units (plots, animals, trees) are measured on several occasions: plant height or LAI at successive dates, soil moisture through the season, or body weight, heart rate or blood metabolites over time. Gives the univariate split-plot-in-time ANOVA, Mauchly's test of sphericity with Greenhouse-Geisser and Huynh-Feldt corrected p-values, a comparison of covariance structures by mixed models (compound symmetry, first-order autoregressive and unstructured), SE and CD for every comparison, letter groupings, and a separate analysis at each time.

Usage

anova_repeated(
  data,
  response,
  treatment,
  time,
  subject = NULL,
  block = NULL,
  posthoc = "lsd",
  alpha = 0.05,
  covariance = TRUE,
  verbose = TRUE
)

Arguments

data

Data frame in long format (one row per unit per time).

response

Name of the response variable.

treatment

Name of the treatment column.

time

Name of the time (occasion) column. Times are taken in the order of their levels (numeric times are sorted).

subject

Name of the column identifying the experimental unit that is measured repeatedly. If NULL and block is given, each block x treatment combination is one unit.

block

Name of the block column for units laid out in randomized complete blocks, or NULL (completely randomized units).

posthoc

Method for the letters (default "lsd").

alpha

Significance level. Default 0.05.

covariance

Logical. If TRUE (default), fits mixed models with different covariance structures using nlme.

verbose

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

Value

An object of class aridagri_repeated with anova_table (univariate), sphericity (Mauchly's W and p, GG and HF epsilons), corrected (within-unit tests with GG and HF p-values), covariance_models (AIC/BIC table), best_structure, mixed_anova, se_cd, means (treatment x time table), treatment_means, time_means, letters, by_time (ANOVA at each time) and models.

Details

Univariate analysis. Treatment (and block) are tested against the between-unit error, Error(a). Time and the treatment x time interaction are tested against the within-unit error, Error(b). With blocks, the block x time interaction is fitted as a separate within-unit term, as in the univariate tests of SAS PROC GLM with a REPEATED statement, so that the sphericity corrections apply to the same error term. This is valid when the covariance of the repeated measurements is spherical. Mauchly's test checks this, and the Greenhouse-Geisser (1959) and Huynh-Feldt (1976) epsilons, the latter with the correction of Lecoutre (1991) as in anova.mlm(), scale the degrees of freedom of the within-unit tests when it fails. A common rule is to use the Greenhouse-Geisser p-value when epsilon is below 0.75 and the Huynh-Feldt p-value otherwise.

Mixed models. Generalized least squares models with the same fixed effects are fitted by REML with compound symmetry (CS), first-order autoregressive (AR1, on the time order) and unstructured (UN, with separate variances per time) covariance, and compared by AIC and BIC. The marginal F-tests of the best structure are reported (with the residual degrees of freedom used by nlme, so tests of between-unit effects are approximate; the univariate test of treatment is exact for balanced data). Structures that fail to converge are skipped.

Comparisons. With \(r\) units per treatment, \(a\) treatments and \(t\) times, the SEd are as in a split-plot design with treatments in main plots and times in sub-plots: treatment means \(\sqrt{2E_a/(rt)}\), time means \(\sqrt{2E_b/(ra)}\), times within a treatment \(\sqrt{2E_b/r}\), and treatments at the same time \(\sqrt{2[(t-1)E_b + E_a]/(rt)}\) with the weighted t.

References

Greenhouse, S.W. and Geisser, S. (1959). On methods in the analysis of profile data. Psychometrika, 24(2), 95-112. doi:10.1007/BF02289823

Lecoutre, B. (1991). A correction for the epsilon approximate test in repeated measures designs with two or more independent groups. Journal of Educational Statistics, 16(4), 371-372. doi:10.3102/10769986016004371

Huynh, H. and Feldt, L.S. (1976). Estimation of the Box correction for degrees of freedom from sample data in randomized block and split-plot designs. Journal of Educational Statistics, 1(1), 69-82. doi:10.3102/10769986001001069

Littell, R.C., Henry, P.R. and Ammerman, C.B. (1998). Statistical analysis of repeated measures data using SAS procedures. Journal of Animal Science, 76(4), 1216-1231. doi:10.2527/1998.7641216x

Examples

data(mungbean_repeated)
rm <- anova_repeated(mungbean_repeated, response = "spad",
                     treatment = "treatment", time = "das", block = "block")
#> 
#> ======================================================================
#>  REPEATED MEASURES ANOVA (SPLIT-PLOT IN TIME)
#> ======================================================================
#>  Response  : spad
#>  Treatment : treatment
#>  Time      : das
#>  Units     : 16
#>  Times     : 4
#> 
#>  Univariate analysis of variance
#>         Source Df  Sum Sq Mean Sq F value Pr(>F)    
#>  block          3   48.65   16.22   5.124 0.0244   *
#>  treatment      3   87.91   29.30   9.259 0.0041  **
#>  Error(a)       9   28.48    3.16                   
#>  das            3 1203.91  401.30 417.333 0.0000 ***
#>  block:das      9   14.89    1.65   1.721 0.1326  NS
#>  treatment:das  9   40.66    4.52   4.698 0.0008 ***
#>  Error(b)      27   25.96    0.96                   
#>  Total         63 1450.47                           
#>  Signif. codes: *** p < 0.001, ** p < 0.01, * p < 0.05, NS not significant
#> 
#>  Grand mean = 38.202   CV(a) = 4.66%   CV(b) = 2.57%
#> 
#>  Mauchly's test of sphericity: W = 0.5414, p = 0.4518
#>  Greenhouse-Geisser epsilon = 0.7684   Huynh-Feldt epsilon = 1.0000
#> 
#>  Within-unit tests with corrected p-values
#>         Source Df F_value p_uncorrected      p_GG      p_HF recommended
#>            das  3 417.333     1.013e-22 6.414e-18 1.013e-22   1.013e-22
#>  treatment:das  9   4.698     8.219e-04 2.793e-03 8.219e-04   8.219e-04
#> 
#>  Mixed models: covariance structures (lower AIC is better)
#>  Structure Parameters    AIC    BIC logLik
#>         CS         21 238.70 276.63 -98.35
#>        AR1         21 230.72 268.66 -94.36
#>         UN         29 238.50 290.90 -90.25
#> 
#>  F-tests with the AR1 structure (residual df; for treatment, the univariate test above is exact)
#>               numDF F-value   p-value
#> block             3   3.971 1.357e-02
#> treatment         3   7.060 5.465e-04
#> das               3 349.707 3.510e-31
#> treatment:das     9   3.268 3.867e-03
#> 
#>  SEm, SEd and CD (alpha = 0.05)
#>  Comparison                                    SEm   SEd   CD    Error    
#>  treatment means                               0.445 0.629 1.423 E(a)     
#>  das means                                     0.245 0.347 0.711 E(b)     
#>  treatment levels at the same or different das 0.615 0.870 1.880 E(a)+E(b)
#>  das levels at the same treatment              0.490 0.693 1.423 E(b)     
#> 
#>  Treatment x time means
#>                25    35    45    55
#> Control     31.50 38.03 41.33 38.48
#> Water spray 30.62 38.00 41.58 37.48
#> Urea 2%     31.60 39.35 45.98 42.67
#> ZnSO4 0.5%  31.40 38.85 43.80 40.58
#> 
#>  Analysis at each time
#>  Time  Mean F_value p_value Sig   CV   SEm    CD
#>    25 31.28   0.446 0.72600  NS 4.26 0.666 2.132
#>    35 38.56   2.108 0.16900  NS 2.36 0.455 1.455
#>    45 43.17  10.450 0.00273  ** 3.12 0.673 2.154
#>    55 39.80  13.088 0.00124  ** 3.21 0.639 2.044
rm$sphericity
#>   Mauchly_W   p_value GG_epsilon HF_epsilon lower_bound
#> 1 0.5413907 0.4518438  0.7683995          1   0.3333333
rm$covariance_models
#>   Structure Parameters      AIC      BIC    logLik
#> 1        CS         21 238.6950 276.6349 -98.34750
#> 2       AR1         21 230.7225 268.6625 -94.36127
#> 3        UN         29 238.5023 290.8955 -90.25116