predict.SpATS: Predictions from an 'SpATS' object

View source: R/predict.SpATS.R

predict.SpATSR Documentation

Predictions from an SpATS object

Description

Takes a fitted SpATS object produced by SpATS() and produces predictions.

Usage

## S3 method for class 'SpATS'
predict(object, newdata = NULL, which = NULL, 
	predFixed = c("conditional", "marginal"), return.vcov.matrix = FALSE, ...)

Arguments

object

an object of class SpATS as produced by SpATS().

newdata

an optional data frame to be used for obtaining the predictions.

which

an optional character string with the variables that define the margins of the multiway table to be predicted (see Details).

predFixed

a character string indicating how predictions for fixed factor are computed. Either "conditional" or "marginal" (see Details).

return.vcov.matrix

logical. If TRUE, the variance-covariance matrix for the predictions is returned.

...

further arguments passed to or from other methods. Not yet implemented.

Details

This function allows to produce predictions, either specifying: (1) the data frame on which to obtain the predictions (argument newdata), or (2) those variables that define the margins of the multiway table to be predicted (argument which). In the first case, all fixed components (including genotype when fixed) and the spatial coordinates must be present in the data frame. As for the random effects is concerned, they are excluded from the predictions when the value is missing in the data frame. In the second case, predictions are obtained for each combination of values of the specified variables that is present in the data set used to fit the model. For those variables not specified in the argument which, the following rules have been considered: (a) random factors and the spatial trend are ignored in the predictions, (b) for fixed numeric variables, the mean value is considered; and (c) for fixed factors, there are two possibilities according to argument 'predFixed': (c1) if predFixed = 'conditional', the reference level is used; and (c2) predFixed = 'marginal', predictions are obtained averaging over all levels of the fixed factor.

Value

The data frame used for obtaining the predictions, jointly with the predicted values and the corresponding standard errors. The label “Excluded” has been used to indicate those cases where a covariate has been excluded or ignored for the prediction (as for instance the random effect).

References

Welham, S., Cullis, B., Gogel, B., Gilmour, A., and Thompson, R. (2004). Prediction in linear mixed models. Australian and New Zealand Journal of Statistics, 46, 325 - 347.

See Also

SpATS, obtain.spatialtrend

Examples

library(SpATS)
data(wheatdata)
wheatdata$R <- as.factor(wheatdata$row)
wheatdata$C <- as.factor(wheatdata$col)

m0 <- SpATS(response = "yield", spatial = ~ SAP(col, row, nseg = c(10,20)), 
 genotype = "geno", fixed = ~ colcode + rowcode, random = ~ R + C, 
 data = wheatdata, control =  list(tolerance = 1e-03))

# Fitted values: prediction on the dataset used for fitting the model
pred1.m0 <- predict(m0, newdata = wheatdata)
pred1.m0[1:5,]

# Genotype prediction
pred2.m0 <- predict(m0, which = "geno")
pred2.m0[1:5,]


SpATS documentation built on Nov. 10, 2022, 5:58 p.m.