| corAR1xAR1 | R Documentation |
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).
corAR1xAR1(
value = c(0.5, 0.5),
form = ~row + col,
nugget = FALSE,
fixed = FALSE,
by_group = FALSE
)
value |
Starting values of |
form |
|
nugget |
An independent plot error besides the AR1 x AR1 part: the
correlation is |
fixed |
Keep the starting values (not estimated)? |
by_group |
With |
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.
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).
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")}
residvariogram, predictmeans
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
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.