Learn R Programming

asremlPlus (version 4.3.45)

addSpatialModel.asrtests: Adds, to a supplied model, a spatial model that accounts for local spatial variation.

Description

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 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.

No hypothesis testing or comparison of information criteria is made. To only change the terms based on a comparison of information criteria use chooseSpatialModelOnIC.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.

One or more rows is added for each section to the test.summary data.frame. 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 for the new model.

Usage

# S3 method for asrtests
addSpatialModel(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", ...)

Value

An asrtests.object containing the components (i) asreml.obj, (ii) wald.tab, and (iii) test.summary for the model that includes the spatial model, unless the spatial model fails to be fitted when allow.unconverged

and/or allow.fixedcorrelation is set to FALSE.

Arguments

asrtests.obj

An asrtests.object containing the components (i) asreml.obj, (ii) wald.tab, and (iii) test.summary.

spatial.model

A single character string nominating the type of spatial model to fit. Possible values are corr, TPNCSS and TPPS.

sections

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.

row.covar

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.

col.covar

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.

row.factor

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.

col.factor

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.

nsegs

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.

nestorder

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.

degree

A character of length 2. The degree of polynomial spline to be used for column and row dimensions respectively; default=3.

difforder

A character of length 2. The order of differencing for column and row dimensions, respectively; default=2.

asreml.option

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 addSpatialModel.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.

tpps4mbf.obj

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.

allow.unconverged

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.

allow.fixedcorrelation

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.

checkboundaryonly

If TRUE then boundary and singular terms are not removed by rmboundary.asrtests; a warning is issued instead.

update

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.

IClikelihood

A character that controls both the occurence and the type of likelihood for information criterion in the test.summary of the new asrtests.object. If none, none are included. Otherwise, if REML, then the AIC and BIC based on the Restricted Maximum Likelihood are included; if full, then the AIC and BIC based on the full likelihood are included. (See also infoCriteria.asreml.)

...

Further arguments passed to changeModelOnIC.asrtests, asreml and tpsmmb.

Author

Chris Brien

Details

The model to which the spatial mdoels is to be added is supplied in the asrtests.obj. It 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. 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 term 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 changeTerms.asrtests to fit the spatial model. Arguments from tpsmmb and changeTerms.asrtests can be supplied in calls to addSpatialModel.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.

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, rmboundary.asrtests, addSpatialModelOnIC.asrtests, testranfix.asrtests,
testresidual.asrtests, newfit.asreml, reparamSigDevn.asrtests, changeTerms.asrtests,
chooseSpatialModelOnIC.asrtests, changeTerms.asrtests, infoCriteria.asreml

Examples

Run this code
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 <- addSpatialModel(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