Adds either a correlation, two-dimensional tensor-product natural cubic smoothing spline (TPNCSS), or a two-dimensional tensor-product penalized P-spline model (TPPS) to account for the the local spatial variation exhibited by a response variable measured on a potentially irregular grid of rows and columns of the units. The data may 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.
A row is added for each section to the test.summary data.frame
of the asrtests.object stating whether or not the new model has been
swapped for a model in which the spatial model has been add to the supplied model.
Convergence and the occurrence of fixed correlations 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 the new model, if a spatial model is added.
# S3 method for asrtests
addSpatialModelOnIC(asrtests.obj, spatial.model = "TPPS",
sections = NULL,
row.covar = "cRow", col.covar = "cCol",
row.factor = NULL, col.factor = NULL,
nsegs = NULL, nestorder = c(1,1),
degree = c(3,3), difforder = c(2,2),
asreml.option = "mbf", tpps4mbf.obj = NULL,
allow.unconverged = FALSE, allow.fixedcorrelation = FALSE,
checkboundaryonly = FALSE, update = FALSE,
IClikelihood = "full", which.IC = "AIC", ...)An asrtests.object containing the components (i) asreml.obj,
(ii) wald.tab, and (iii) test.summary for the model whose fit has
the smallest information criterion between the supplied and spatial model. The values
of the degrees of freedom and the information criteria in the test.summary are
differences between those of the changed model and those of the model supplied to
addSpatialModelOnIC.
An asrtests.object containing the components
(i) asreml.obj, (ii) wald.tab, and (iii) test.summary.
A single character string nominating the type of spatial
model to fit. Possible values are corr, TPNCSS and
TPPS.
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 character of length 2. The degree of polynomial spline to
be used for column and row dimensions respectively; default=3.
A character of length 2. The order of differencing for
column and row dimensions, respectively; default=2.
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, extra to that created by
makeTPSPlineXZMats.data.frame, 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.
Further arguments passed to changeModelOnIC.asrtests, asreml and
tpsmmb.
Chris Brien
A fitted spatial model is only returned if it improves the fit over and above that of achieved with the model fit supplied in the asrtests.obj. To fit the spatial model without any hypothoses testing or comparison of informtion criteria use addSpatialModel.asrtests. The model fit supplied in the asrtests.obj should not include terms that will be included in the local spatial model. All spatial model terms are fitted as fixed or random. Consequently, the residual model does not have to be iid.
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 TPNCSS spatial model is as decribed by Verbyla et al. (2018) and the TPPS model is as described by Rodriguez-Alvarez et al. (2018). However, for the TPPS model, the degree of the polynomial and the order of differencing can be varied. The defaults of 3 and 2, respectively, fit a cubic spline with second order differencing, while setting both the degree and order of differencing to 1 will fit a type of linear variance model (Piepho, Boer and Williams, 2022) The fixed terms for these 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). 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 TPPS model is 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 enviroment 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 addSpatialModelOnIC.asrtests and will be passed on to the relevant function through the ellipses argument (...).
The data for experiment can be divided sections and the same spatial model fitted separately to each. 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,
testranfix.asrtests, testresidual.asrtests,
newfit.asreml, reparamSigDevn.asrtests,
addSpatialModel.asrtests,
changeModelOnIC.asrtests, chooseSpatialModelOnIC.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)
current.asrt <- addSpatialModelOnIC(current.asrt, spatial.model = "TPPS",
row.covar = "cRow", col.covar = "cColumn",
row.factor = "Row", col.factor = "Column",
asreml.option = "grp")
infoCriteria(current.asrt$asreml.obj)
}Run the code above in your browser using DataLab