spatial.single
Fit the spatial model according to the specification of conditions
given a provided dataset. It also calculates goodness-of-fit statisitcs to later compare
with other spatial model. This routine works best for replicated genotypes.
Some checks on data are incorporated, but data is assumed to come in a full grid.
spatial.single(
data = NULL,
gen = NULL,
block = NULL,
ibk = NULL,
row = NULL,
col = NULL,
cov1 = NULL,
cov2 = NULL,
resp = NULL,
add.block = FALSE,
add.ibk = FALSE,
add.row = FALSE,
add.col = FALSE,
add.spl.row = FALSE,
add.spl.col = FALSE,
add.cov1 = FALSE,
add.cov2 = FALSE,
add.nugget = FALSE,
type.gen = "random",
type.block = "fixed",
type.residual = "ar1"
)
dataframe with all relevant columns for spatial model and response variables.
factor name for genotypes (or treatments)
factor name for full block (or replicates) (optional)
factor name for incomplete block (optional) (optional)
column name for row coordinates of each experimental unit
column name for column coordinates of each experimental unit
column name with additional covariate 1 (optional)
column name with additional covariate 2 (optional)
column name for the response variable to analyze
logical to add to model block effects (default = FALSE)
logical to fit incomplete block random effects (default = FALSE)
logical to fit row within block random effects (default = FALSE)
logical to fit column within block random effects (default = FALSE)
logical to fit splines across rows (default = FALSE)
logical to fit splines across columns (default = FALSE)
logical to fit additional covariate 1 (default = FALSE)
logical to fit additional covariate 2 (default = FALSE)
logical to fit nugget random effects (only for autoregressive errors) (default = FALSE)
model assumption for genotypes: 'random' or 'fixed' (default = 'random')
model assumption for full blocks: 'random' or 'fixed' (default = 'fixed')
model assumption for residual terms: 'indep' or 'ar1' (default = 'ar1')
Several objects with details of the fitted model. aov: Wald-test (mixed model ANOVA-like table) call: String with the ASReml-R call used to fit the requested model gt: Goodness-of-fit statistics for the model evaluated are reported as summary. This includes columns: number of variance components in the model (n.VC), log-likelihood (logL), Akaike information criteria (AIC), Bayesian information criteria (BIC), A-optimality value, logarithm of the D-optimality value, and heritability based on predictor error variance (heritPEV, only for genotypes 'random') mod: ASReml-R object with all information from the fitted model predictions: Predictions for all genotypes, with an additional column of 'weight' is to be used on a on a second-stage analysis. These weights are the diagonal of the inverse of the variance- covariance matrix of predictions
# Example 1: Replicated Trial - Genotype random + spatial terms
# library(agridat)
# testREP <- durban.rowcol
# testREP$bed <- as.factor(testREP$bed)
# testREP$row <- as.factor(testREP$row)
# testREP$gen <- as.factor(testREP$gen)
# head(testREP)
# output.REP <- spatial.single(data=testREP, gen='gen', row='row', col='bed', resp='yield',
# add.block=TRUE, add.row=TRUE, add.col=TRUE,
# type.gen='random', type.block='fixed', type.residual='ar1')
# output.REP$gt$herit.PEV # Heritability-PEV
# output.REP$aov # Wald Test
# summary(output.REP$mod)$varcomp # Variance Components
# head(output.REP$predictions)
#
# # Example 2: Simpler model - independent errors
# output.ID <- spatial.single(data=testREP, gen='gen', row='row', col='bed', resp='yield',
# add.block=TRUE, add.row=TRUE, add.col=TRUE,
# type.gen='random', type.block='fixed', type.residual='indep')
# output.ID$gt$herit.PEV # Heritability-PEV
# output.ID$aov # Wald Test
# summary(output.ID$mod)$varcomp # Variance Components
# head(output.ID$predictions)
#
# # Example 3: Comparing Models with a LRT
# lrt.asreml(output.REP$mod, output.ID$mod, boundary=FALSE)