For a response variable measured on a potentially irregular grid of rows and
columns of the units, uses information criteria to decide whether to add to the fitted
model stored in the supplied asrtests.object
either a two-dimensional
exponential correlation model, a two-dimensional tensor-product natural cubic smoothing
spline model (TPNCSS), a two-dimensional tensor-product penalized P-spline model (TPPCS)
model, or a two-dimensional tensor-product penalized linear spline model with
first-difference penalties (TPP1LS) to account for the local spatial variation. The models
from which to select can be reduced to a subset of these four models. 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. The spatial model is only added if the information criterion
of the supplied model is decreased with the addition of the local spatial model.
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.
# S3 method for asrtests
chooseSpatialModelOnIC(asrtests.obj, trySpatial = "all",
sections = NULL,
row.covar = "cRow", col.covar = "cCol",
row.factor = NULL, col.factor = NULL,
nsegs = NULL, nestorder = c(1,1),
asreml.option = "mbf",
tpps4mbf.obj = NULL,
allow.unconverged = FALSE,
allow.fixedcorrelation = FALSE,
checkboundaryonly = FALSE, update = FALSE,
IClikelihood = "full", which.IC = "AIC",
return.asrts = "best", ...)
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
.
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 model to the supplied model (if the spatial model did not fit, then
all values will be NA
).
The best.spatial
component is a character giving the name of the best spatial
model, and best.spatial.AIC
gives the value of its AIC
.
An asrtests.object
containing the components
(i) asreml.obj
, (ii) wald.tab
, and (iii) test.summary
.
A character
string nominating the types of spatial
model whose fits are to be assessed. Possible values are corr
,
TPNCSS
, TPPCS
, and TPP1LS
.
A single character
string that species the name of the column
in the data.frame
that contains the factor
that identifies different sections of the data
to which separate spatial models are to be fitted.
A single character
string nominating a numeric
column in the data.frame
that contains the values of a
centred covariate indexing the rows of the grid.
A single character
string nominating a numeric
column in the data.frame
that contains the values of a
centred covariate indexing the columns of the grid.
A single character
string nominating a factor
in the data.frame
that has as many levels
as there
are unique values in row.covar
. This argument is required for
spatial.model
set to TPNCSS
or TPPS
. It is used
to remove a term corresponding to the row.factor
and a random
row deviations term based on row.covar
will be included in the
model. If the argument is NULL
, it is assumed that such a term
is not included in the fitted model stored in asrtests.obj
.
A single character
string nominating a factor
in the data.frame
that has as many levels
as there
are unique values in col.covar
. This argument is required for
spatial.model
set to TPNCSS
or TPPS
. It is used
to remove a term corresponding to the col.factor
and a random
column deviations term based on col.covar
will be included in the
model. If the argument is NULL
, it is assumed that such a term
is not included in the fitted model stored in asrtests.obj
.
A pair of numeric
values giving the number of segments into
which the column and row ranges are to be split, respectively (each value
specifies the number of internal knots + 1). If only one number is
specified, that value is used in both dimensions. If not specified, then
(number of unique values - 1) is used in each dimension; for a grid layout
with equal spacing, this gives a knot at each data value.
A character
of length 2. The order of nesting for column
and row dimensions, respectively; default=1 (no nesting). A value of 2
generates a spline with half the number of segments in that dimension, etc.
The number of segments in each direction must be a multiple of the order
of nesting.
A single character
string specifying whether the grp
or
mbf
methods are to be used to supply externally formed covariate
matrices to asreml
. If the mbf
methods is to be used, then
makeTPSPlineXZMats.data.frame
must be used before calling
addSpatialModelOnIC.asrtests
. Compared to the mbf
method,
the grp
method creates large asreml
objects, but is faster.
The grp
method adds columns to the
data.frame
containing the data
; the mbf
method
adds only fixed covariate to data
and stores the random covariates
externally.
An object made with makeTPSPlineXZMats.data.frame
and
which contains the spline basis information, that is extra to the
data.frames
created by makeTPSPlineXZMats.data.frame
in the environment in which it is called and that is needed to fit a
TPPS
model using the mbf
method of asreml
.
A logical
indicating whether to accept a new model
even when it does not converge. If FALSE
and the fit of the new
model does not converge, the supplied asrtests.obj
is returned.
Also, if FALSE
and the fit of the new model has converged, but that
of the old model has not, the new model will be accepted.
A logical
indicating whether to accept a new model
even when it contains correlations in the model whose values have been
designated as fixed, bound or singular. If FALSE
and the new model
contains correlations whose values have not been able to be estimated,
the supplied asrtests.obj
is returned. The fit in the
asreml.obj
component of the supplied asrtests.obj
will
also be tested and a warning issued if both fixed correlations are found
in it and allow.fixedcorrelation
is FALSE
.
If TRUE
then boundary and singular terms are not removed by
rmboundary.asrtests
; a warning is issued instead.
If TRUE
then update.asreml
is called to fit the model
to be tested. In doing this the arguments R.param
and
G.param
are set to those in the asreml
object stored in asrtests.obj
so that the values from the previous
model are used as starting values. If FALSE
then a call is made to
asreml
in which the only changes from the previous call are that
(i) models are modifed as specified and
(ii) modifications specified via ...
are made.
A character
specifying the information criterion to be used in
selecting the best model. Possible values are AIC
and
BIC
. The values of the criterion for supplied model must
exceed that for changed model for the changed model to be returned.
A character
specifying whether Restricted Maximum Likelihood
(REML
) or the full likelihood (full
) are to be used in
calculating the information criteria.
A character
string specifying whether the asrtests.object
for the best
fitting model (smallest AIC or BIC) is returned or the
asrtests.object
s resulting from the attempted fits of all
of
the models specifed using trySpatial
are returned.
Further arguments passed to changeModelOnIC.asrtests
, asreml
and
tpsmmb
.
Chris Brien
A fitted spatial model is only returned if it improves the fit over an above that achieved with the model fit supplied in the asrtests.obj
. If return.asrts
is all
, then this applies to each spatial model specified by trySpatial
. 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.
For the corr
spatial model, an exponential model (exp
) is used for each dimension to model the spatial correlation. A series of models are tried, beginning with the addition of row correlation and followed by the addition of column correlation. Only if the model fit is improved is a correlation retained. Finally, if any correlation is retained, the improvment to the fit of a nuggest term is assessed. In this model, the correlation between observations from different rows is the correlation between observations in adjacent rows raised to the power equal to the absolute value of the difference in their row.covar
values; similarly for the correlation in the column dimension.
The tensor-product natural-cubic-smoothing-spline TPNCSS
spatial model is as decribed by Verbyla et al. (2018), the tensor-product penalized-cubic-spline TPPCS
model is as described by Rodriguez-Alvarez et al. (2018), and the tensor-product, first-difference-penalty, linear spline TPP1LS
model that is amongst those described by Piepho, Boer and Williams (2022). The fixed terms for these models are row.covar + col.covar + row.covar:col.covar
and the random terms 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)
. The supplied model should not include any of these terms. However, any fixed or random main-effect term for either row.factor
or col.factor
will be removed from the fit.
The TPPCS
and TPP1LS
models are fitted using the function tpsmmb
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 the it to the data.frame
holding the information for the analysis. The mbf
method requires the spline basis information to be in the same environment as the function that is called to make a fit using asreml
. To this end, and prior to invoking the calling function, makeTPSPlineXZMats.data.frame
must be used produce the data.frames
.
All models utlize the function changeModelOnIC.asrtests
to assess the model fit, the information critera 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 throught 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.
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 would have the same combination.
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/
as.asrtests
, rmboundary.asrtests
,
addSpatialModelOnIC.asrtests
, addSpatialModel.asrtests
, ,
testranfix.asrtests
,
testresidual.asrtests
,
newfit.asreml
, reparamSigDevn.asrtests
,
chooseModel.asrtests
,
changeModelOnIC.asrtests
, infoCriteria.asreml
if (FALSE) {
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 three models the local spatial variation
current.asrt <- chooseSpatialModelOnIC(current.asrt,
row.covar = "cRow", col.covar = "cColumn",
row.factor = "Row", col.factor = "Column",
asreml.option = "grp")
}
Run the code above in your browser using DataLab