chooseSpatialModelOnIC.asrtests {asremlPlus} | R Documentation |
Uses information criteria to choose the best fitting spatial model for accounting for local spatial variation.
Description
For a response variable measured on a potentially irregular grid of rows and
columns of the units, uses information criteria (IC) to decide whether the fit and
parsimony of the model fitted to a set of data can be improved by adding, to the fitted
model stored in the supplied asrtests.object
, one of the following spatial
models to account for the local spatial variation:
(i) a two-dimensional first-order autocorrelation model, (ii) a two-dimensional
tensor-product natural cubic smoothing spline model (TPNCSS), (iii) a two-dimensional
tensor-product penalized P-spline model with second-difference penalties (TPPSC2) model,
or (iv) a two-dimensional tensor-product penalized linear spline model with
first-difference penalties (TPPSL1). The models from which to select can be reduced
to a subset of these four models. For each model, a term from the spatial model is
only added to the supplied model if the IC of the supplied model is decreased with
the addition of that term. If no model improves the IC when a local spatial variation
model is added, then the supplied, nonspatial model will be returned. The data can be
arranged in sections, for each of which there is a grid and for which the model is to
be fitted separately. Also, the rows and columns of a grid are not necessarily one
observational unit wide. For TPPSC2
models, the improvement in the fit from
rotating the eigenvectors of the penalty matrix can be investigated; if there is no
improvement, the unrotated fit will be returned.
One or more rows is added to the test.summary
data.frame
of the
asrtests.object
, for each section
and each spatial model,
stating whether or not the new model has been swapped for a model in which the
spatial model has been added to the supplied model. Convergence in fitting the
model is checked and a note included in the action
if there was not.
All components of the asrtests.object
are updated to exhibit the
differences between the supplied and any new model.
Usage
## S3 method for class 'asrtests'
chooseSpatialModelOnIC(asrtests.obj, trySpatial = "all",
sections = NULL,
row.covar = "cRow", col.covar = "cCol",
row.factor = "Row", col.factor = "Col",
corr.funcs = c("ar1", "ar1"), corr.orders = c(0, 0),
row.corrFitfirst = TRUE, allow.corrsJointFit = TRUE,
dropFixed = NULL, dropRandom = NULL,
nsegs = NULL, nestorder = c(1,1),
usRandLinCoeffs = TRUE,
rotateX = FALSE, ngridangles = NULL,
which.rotacriterion = "AIC", nrotacores = 1,
asreml.option = "grp", tpps4mbf.obj = NULL,
allow.unconverged = FALSE,
allow.fixedcorrelation = FALSE,
checkboundaryonly = FALSE, update = FALSE,
maxit = 30, IClikelihood = "full", which.IC = "AIC",
return.asrts = "best", ...)
Arguments
asrtests.obj |
An |
trySpatial |
A |
sections |
A single |
row.covar |
A single |
col.covar |
A single |
row.factor |
A single |
col.factor |
A single |
corr.funcs |
A single |
corr.orders |
A |
row.corrFitfirst |
A |
allow.corrsJointFit |
A |
dropFixed |
A single An element that is The terms must match those in the |
dropRandom |
A single An element that is The terms must match those in the |
nsegs |
A pair of |
nestorder |
A |
usRandLinCoeffs |
A |
rotateX |
A |
ngridangles |
A |
which.rotacriterion |
A single |
nrotacores |
A |
asreml.option |
A single |
tpps4mbf.obj |
An object made with |
allow.unconverged |
A |
allow.fixedcorrelation |
A |
checkboundaryonly |
If |
update |
If |
which.IC |
A |
maxit |
A |
IClikelihood |
A |
return.asrts |
A |
... |
Further arguments passed to |
Details
For each spatial model that is to be fitted, a fitted spatial model is only returned if it improves the fit over and above that achieved with the model fit supplied in the asrtests.obj
, because terms in the spatial model are not added unless model fit is improved by their addition as measured by an IC. If return.asrts
is all
, then this applies to each spatial model specified by trySpatial
. To force a spatial model to be fitted use addSpatialModel.asrtests
. The model fit supplied in the asrtests.obj
should not include terms that will be included in any local spatial model. All spatial model terms are fitted as fixed or random. Consequently, the residual model does not have to be iid. The improvement in the fit resulting from the addition of a spatial model to the supplied model is evaluated. Note that the data must be in the order that corresponds to the residual
argument with a variable to the right of another variable changing levels in the data frame faster than those of the preceding variables e.g. Row:Column
implies that all levels for Column
are in consecutive rows of the data.frame
that have a single Row
level.
For the corr
spatial model, the default model is an autocorrelation model of order one (ar1
) for each dimension. However, any of the single dimension correlation/variance models from asreml
can be specified for each dimension, as can no correlation model for a dimension; the models for the two dimensions can differ. Using a forward selection procedure, a series of models are tried, without removing boundary or singular terms, beginning with the addition of row correlation and followed by the addition of column correlation or, if the row.corrFitfirst
is set to FALSE
, the reverse order. If the fitting of the first-fitted correlation did not result in a model change because the fitting did not converge or correlations were fixed, but the fit of the second correlation was successful, then adding the first correlation will be retried. If one of the metric correlation functions is specified (e.g. exp
), then the row.covar
or col.covar
will be used in the spatial model. However, because the correlations are fitted separately for the two dimensions, the row.factor
and col.factor
are needed for all models and are used for any dimension that does not involve a correlation/variance function for the fit being performed. Also, the correlation models are fitted as random
terms and so the correlation model will include a variance parameter for the grid even when ar1
is used to specify the correlation model, i.e. the model fitted is a variance model and there is no difference between ar1
and ar1v
in fitting the model. The variance parameter for this term represents the spatial variance and the fit necessarily includes a nugget term, this being the residual variance. If any correlation is retained in the model, for a section if sections
is not NULL
, then the need for a nuggest term is assessed by fixing the corresponding residual variance to one, unless there are multiple residual variances and these are not related to the sections
. Once the fitting of the correlation model has been completed, the rmboundary
function will be executed with the checkboundaryonly
value supplied in the chooseSpatialModelOnIC.asrtests
call. Finally, checking for bound and singular random terms associated with the correlation model and residual terms will be carried out when there are correlation terms in the model and checkboundaryonly
has been set to FALSE
; as many as possible will be removed from the fitted model, in some cases by fixing variance terms to one.
The tensor-product natural-cubic-smoothing-spline (TPNCSS
) spatial model is as described by Verbyla et al. (2018), the tensor-product penalized-cubic-spline (TPPSC2
) model with second-order differencing of the penalty is similar to that described by Rodriguez-Alvarez et al. (2018), and the tensor-product, first-difference-penalty, linear spline (TPPSL1
) model is amongst those described by Piepho, Boer and Williams (2022). The fixed terms for the spline models are row.covar + col.covar + row.covar:col.covar
and the random terms are spl(row.covar) + spl(col.covar) + dev(row.covar) + dev(col.covar) + spl(row.covar):col.covar + row.covar:spl(col.covar) + spl(row.covar):spl(col.covar)
, except that spl(row.covar) + spl(col.covar)
is replaced with spl(row.covar):int(col.covar) + int(row.covar):spl(col.covar)
in the TPPSC2
model, where int(.)
indicates an intercept or constant value specific to its argument. For TPPSL1
models, the terms spl(row.covar):col.covar + row.covar:spl(col.covar)
are omitted, The supplied model should not include any of these terms. However, any fixed or random main-effect Row or Column term that has been included as an initial model for comparison with a spatial model can be removed prior to fitting the spatial model using dropFixed
or dropRandom
. For the P-spline models with second-order differencing, the model matrices used to fit the pairs of random terms (i) spl(row.covar):int(col.covar)
and spl(row.covar):col.covar
and (ii) int(row.covar):spl(col.covar)
and row.covar:spl(col.covar)
are transformed using the spectral decomposition of their penalty matrices. An unstructured variance model is tried for each of these pairs and retained if it improves the fit. For TPPSC2
, it is also possible to optimize the rotation of the null-space eigenvectors of the penalty matrix for each of these random-term pairs (for more information see Piepho, Boer and Williams, 2022). The optimization is achieved either using an optimizer or takes the form of a search over a grid of rotation angles for a reduced model; the fit of the full model with rotation using the optimal rotation angles will only be returned if it improves on the fit of the full, unrotated model.
The TPPSC2
and TPPSL1
models are fitted using functions from the R
package TPSbits
authored by Sue Welham (2022). There are two methods for supplying the spline basis information produced by tpsmmb
to asreml
. The grp
method adds it to the data.frame
supplied in the data
argument of the asreml
call. The mbf
method creates smaller data.frames
with the spline basis information in the same environment as the internal function that calls the spline-fitting function. If it is desired to use in a later session, an asreml
function, or asrtests
function that calls asreml
, (e.g. predict.asreml
, predictPlus.asreml
, or changeTerms.asrtests
) on an asreml.object
created using mbf
terms, then the mbf
data.frames
will need to be recreated using makeTPPSplineMats.data.frame
in the new session, supplying, if there has been rotation of the penalty matrix eigenvectors, the theta
values that are returned as the attribute theta.opt
of the asreml.obj
.
All models utlize the function changeModelOnIC.asrtests
to assess the model fit, the information criteria used in assessing the fit being calculated using infoCriteria
. Arguments from tpsmmb
and changeModelOnIC.asrtests
can be supplied in calls to chooseSpatialModelOnIC.asrtests
and will be passed on to the relevant function though the ellipses argument (...).
The data for experiment can be divided into sections
and an attempt to fit the same spatial model to each is made. The fit may differ for each of the sections
, but the fit over all of the sections
is assessed. For more detail see sections
above.
Each combination of a row.coords and a col.coords does not have to specify a single observation; for example, to fit a local spatial model to the main units of a split-unit design, each combination would correspond to a main unit and all subunits of the main unit would have the same combination.
Value
A list
containing four components: (i) asrts
, (ii) spatial.IC
,
(iii) best.spatial.mod
, and (iv) best.spatial.IC
.
The component asrts
itself holds a list
of one or more
asrtests.object
s, either the best overall out of the supplied model and
the spatial models, or, for each spatial model, the best out of the supplied model
and that spatial model. Each asrtests.object
contains the components:
(i) asreml.obj
, (ii) wald.tab
, and (iii) test.summary
. If the
asrtests.object
is the result of fitting a TPPSC2
model with
an exploration of the rotation of the eigenvectors of the penalty matrix for the linear
components, then the asreml.obj
will have an attribute theta.opt
that contains
the optimal rotation angles of the eigenvectors.
The spatial.IC
component holds a data.frame
with summary of the
values of the information criteria for the supplied model and those resulting from
adding the spatial models to the supplied model. In the case of a spatial correlation model,
the information criteria for the selected spatial correlation model is returned.
If a spatial model could not be fitted, then all returned values will be NA
).
The best.spatial.mod
component is a character giving the name of the best spatial
model, and best.spatial.AIC
gives the value of its AIC
.
Author(s)
Chris Brien
References
Piepho, H.-P., Boer, M. P., & Williams, E. R. (2022). Two-dimensional P-spline smoothing for spatial analysis of plant breeding trials. Biometrical Journal, 64, 835-857.
Rodriguez-Alvarez, M. X., Boer, M. P., van Eeuwijk, F. A., & Eilers, P. H. C. (2018). Correcting for spatial heterogeneity in plant breeding experiments with P-splines. Spatial Statistics, 23, 52-71.
Verbyla, A. P., De Faveri, J., Wilkie, J. D., & Lewis, T. (2018). Tensor Cubic Smoothing Splines in Designed Experiments Requiring Residual Modelling. Journal of Agricultural, Biological and Environmental Statistics, 23(4), 478-508.
Welham, S. J. (2022) TPSbits
: Creates Structures to Enable Fitting and Examination of 2D Tensor-Product Splines using ASReml-R. Version 1.0.0 https://mmade.org/tpsbits/
See Also
as.asrtests
,
makeTPPSplineMats.data.frame
,
addSpatialModelOnIC.asrtests
,
addSpatialModel.asrtests
,
changeModelOnIC.asrtests
,
changeTerms.asrtests
,
rmboundary.asrtests
,
testranfix.asrtests
,
testresidual.asrtests
,
newfit.asreml
,
reparamSigDevn.asrtests
,
changeTerms.asrtests
,
infoCriteria.asreml
Examples
## Not run:
data(Wheat.dat)
#Add row and column covariates
Wheat.dat <- within(Wheat.dat,
{
cColumn <- dae::as.numfac(Column)
cColumn <- cColumn - mean(unique(cColumn))
cRow <- dae::as.numfac(Row)
cRow <- cRow - mean(unique(cRow))
})
#Fit initial model
current.asr <- asreml(yield ~ Rep + WithinColPairs + Variety,
random = ~ Row + Column,
data=Wheat.dat)
#Create an asrtests object, removing boundary terms
current.asrt <- as.asrtests(current.asr, NULL, NULL,
label = "Random Row and Column effects")
current.asrt <- rmboundary(current.asrt)
# Choose the best of four models for the local spatial variation
current.asrt <- chooseSpatialModelOnIC(current.asrt,
row.covar = "cRow", col.covar = "cColumn",
dropRowterm = "Row", dropColterm = "Column",
asreml.option = "grp")
## End(Not run)