corAR1xAR1: Separable AR1 x AR1 correlation for field trials

View source: R/cor-ar1xar1.R

corAR1xAR1R Documentation

Separable AR1 x AR1 correlation for field trials

Description

A correlation structure for nlme::gls() and nlme::lme(): the correlation of two plots is \phi_r^{|dr|}\phi_c^{|dc|}, with dr and dc their distances in rows and columns (Gilmour, Cullis and Verbyla 1997), as Genstat's VSTRUCTURE AR,AR and ASReml's ar1(row):ar1(col).

Usage

corAR1xAR1(
  value = c(0.5, 0.5),
  form = ~row + col,
  nugget = FALSE,
  fixed = FALSE,
  by_group = FALSE
)

Arguments

value

Starting values of \phi_r and \phi_c (in (-1, 1)), and of the nugget share (in (0, 1)) when nugget = TRUE.

form

~ row + col or ~ row + col | group: integer row and column positions of the plots over the whole field (one AR1 x AR1 per group, the same \phi).

nugget

An independent plot error besides the AR1 x AR1 part: the correlation is (1 - n)\phi_r^{|dr|}\phi_c^{|dc|} off the diagonal, n the share of the plot variance.

fixed

Keep the starting values (not estimated)?

by_group

With form = ~ row + col | trial: a \phi_r, \phi_c (and nugget share) for each group, as fitting each trial alone, while the fixed effects stay shared. For a residual variance of each trial add weights = varIdent(form = ~ 1 | trial). value gives the starting values of every group.

Details

The row and column are integer positions over the whole field, so plots missing from the grid need nothing: the correlation of the plots present is the sub-matrix. In gls() the structure covers all plots (or each group). In lme() a correlation acts only within the groups of the innermost random effect: with random = ~ 1 | rep the AR1 x AR1 would be within each replicate. For replicate (block) effects plus an AR1 x AR1 over the whole field, as Genstat and ASReml fit it, put the random effects in one group: lme(y ~ variety, random = list(all = pdIdent(~ rep - 1)), correlation = corAR1xAR1(form = ~ row + col | all)) with all = factor(1).

With nugget = TRUE the plot variance is split into an AR1 x AR1 part and an independent part, the nugget share n; Genstat's units term with the AR1 x AR1 term scaled by a ratio g is the same model with n = 1/(1 + g) (with AR1 x AR1 as the residual and units as a random term, n = g/(1 + g)). Each likelihood uses a dense matrix of the plots of a group: a fit takes about a second for 150 plots, 10 s for 600 and minutes for 2000 (above 1000 plots in a group a message points to the smooth trend).

A smooth field trend is the other common spatial model: semireg(y ~ variety + t2(row, col) + (1 | rowf) + (1 | colf), data = d), a smooth surface over the field as SpATS fits, often as good as AR1 x AR1 in practice (on Slate Hall the AR1 x AR1 means are the more precise: average SED 0.598, 0.617 with a nugget, against 0.679, all Kenward-Roger adjusted). residvariogram() shows whether a fit leaves spatial correlation.

Checked against Genstat (REML Guide's Slate Hall trial): \phi and the variances to Genstat's printed digits; the 25 variety means and all 300 SEDs of each model within 5e-6 (tested to 1e-5); the Wald statistic; the d.d.f. of the variety test with df_method = "KR-average". Kenward-Roger and Satterthwaite leave out variance components (and a nugget) estimated at 0.

With by_group = TRUE the parameters are named by group (phi_row.T1, ...). Fitting yield ~ trial / variety with weights = varIdent(form = ~ 1 | trial) and a \phi pair per trial gives the estimates and log-likelihood of separate fits of each trial (checked in the tests).

Normalized residuals (residplot(), residvariogram()) are whitened with the plots of each group in row and column order, so they do not depend on the order of the data.

Value

An object of class c("corAR1xAR1", "corStruct") for the correlation argument; coef(fit$modelStruct$corStruct, unconstrained = FALSE) gives \phi_r, \phi_c (and the nugget share).

References

Gilmour, A. R., Cullis, B. R. and Verbyla, A. P. (1997). Accounting for natural and extraneous variation in the analysis of field experiments. Journal of Agricultural, Biological, and Environmental Statistics, 2, 269-293. \Sexpr[results=rd]{tools:::Rd_expr_doi("10.2307/1400446")}

See Also

residvariogram, predictmeans

Examples


d <- read.csv(system.file("extdata", "slatehall.csv", package = "predictmeans"))
d$variety <- factor(d$variety)
fit <- nlme::gls(yield ~ variety, data = d,
                 correlation = corAR1xAR1(form = ~ fieldrow + fieldcolumn))
coef(fit$modelStruct$corStruct, unconstrained = FALSE)    # Genstat: 0.4586, 0.6838
pm <- predictmeans(fit, "variety")
head(pm$means)
residvariogram(fit, row = "fieldrow", col = "fieldcolumn", data = d, nsim = 19)   # a few seconds


predictmeans documentation built on Dec. 3, 2026, 5:07 p.m.