statgenSTA (version 1.0.2)

fitTD: Fit Single Trial Mixed Model

Description

Perform REML analysis given a specific experimental design using either SpATS, lme4 or asreml. SpATS is used as a default method when design is rowcol or res.rowcol, lme4 for other designs. See details for the exact models fitted.

Usage

fitTD(
  TD,
  trials = names(TD),
  design = NULL,
  traits,
  what = c("fixed", "random"),
  covariates = NULL,
  useCheckId = FALSE,
  spatial = FALSE,
  engine = NA,
  control = NULL,
  progress = FALSE,
  ...
)

Arguments

TD

An object of class TD.

trials

A character vector specifying the trials for modeling.

design

A character string specifying the experimental design. Either "ibd" (incomplete block design), "res.ibd" (resolvable incomplete block design), "rcbd" (randomized complete block design), "rowcol" (row column design) or "res.rowcol" (resolvable row column design).

traits

A character vector specifying the traits for modeling.

what

A character vector specifying whether "genotype" should be fitted as "fixed" or "random" effect. If not specified, both models are fitted.

covariates

A character vector specifying covariates to be fitted as extra fixed effects in the model.

useCheckId

Should checkId be used as a fixed effect in the model? If TRUE, TD has to contain a column 'checkId'.

spatial

Should spatial models be tried? Spatial models can only be fitted with SpATS and asreml. If SpATS is used for modeling, only spatial models can be fitted and spatial is always set to TRUE. If asreml is used, fitting spatial models is optional.

engine

A string specifying the name of the mixed modeling engine to use, either "SpATS", "lme4" or "asreml." For spatial models, "SpaTS" is used as default, for other models "lme4".

control

An optional list with control parameters to be passed to the actual fitting functions. Currently nSeg and nestDiv are valid parameters when fitting a model using SpATS. They pass a value to nseg and nest.div in PSANOVA respectively. For nSeg also a named list can be supplied containing values for nSeg per trial. criterion is a valid parameter when fitting a spatial model using asreml. It may be used to pass a goodness-of-fit criterion for comparing different spatial models. See also in details. Other parameters are ignored.

progress

Should the progress of the modeling be printed. If TRUE, for every trial a line is output indicating the traits fitted for the particular trial.

...

Further arguments to be passed to SpATS, lme4 or asreml.

Value

An object of class STA, a list containing, per trial that has been analyzed, a list of:

mRand

A list of models with fitted with genotype as random effect.

mFix

A list of models fitted with genotype as fixed effect.

TD

An object of class TD containing the data on which mRand and mFix are based.

traits

A character vector indicating the traits for which the analysis is done.

design

A character string containing the design of the trial. (see fitTD for the possible designs).

spatial

A character string indicating the spatial part of the model. FALSE if no spatial design has been used.

engine

A character string containing the engine used for the analysis.

predicted

A character string indicating the variable that has been predicted.

Details

The actual model fitted depends on the design. For the supported designs, the following models are used:

ibd

trait = genotype + subBlock + e

res.ibd

trait = genotype + repId + repId:subBlock + e

rcbd

trait = genotype + repId + e

rowcol

trait = genotype + rowId + colId + e

res.rowcol

trait = genotype + repId + repId:rowId + repId:colId + e

In the above models fixed effects are indicated in bold, random effects in italics. genotype is fitted as fixed or random effect depending on the value of what. In case useCheckId = TRUE, an extra fixed effect checkId is included in the model. Variables in covariates are fitted as extra fixed effects. When SpATS is used for modeling, an extra spatial term is included in the model. This term is constructed using the function PSANOVA from the SpATS package as PSANOVA(colCoord, rowCoord, nseg = nSeg, nest.div = 2) where nSeg = (number of columns / 2, number of rows / 2). nseg and nest.div can be modified using the control parameter. When asreml is used for modeling and spatial is TRUE six models are fitted with different random terms and covariance structure. The best model is determined based on a goodness-of-fit criterion, either AIC or BIC. This can be set using the control parameter criterion, default is AIC. The fitted random terms depend on the structure of the data. If the design has a regular structure, i.e. all replicates appear the same amount of times in the design, the following combinations of random and spatial terms are fitted

  • random = NULL, spatial = exp(rowCoord):colCoord

  • random = NULL, spatial = rowCoord:exp(colCoord)

  • random = NULL, spatial = iexp(rowCoord,colCoord)

  • random = repId:rowId, spatial = exp(rowCoord):colCoord

  • random = repId:colId, spatial = rowCoord:exp(colCoord)

  • random = repId:rowId + repId:colId, spatial = iexp(rowCoord,colCoord)

If the design is not regular the following combinations of random and spatial terms are fitted

  • random = NULL, spatial = ar1(rowId):colId

  • random = NULL, spatial = rowId:ar1(colId)

  • random = NULL, spatial = ar1(rowId):ar1(colId)

  • random = repId:rowId, spatial = ar1(rowId):colId

  • random = repId:colId, spatial = rowId:ar1(colId)

  • random = repId:rowId + repId:colId, spatial = ar1(rowId):ar1(colId)

If there are no replicates in the model, repId is left out from the random parts above.

References

Maria Xose Rodriguez-Alvarez, Martin P. Boer, Fred A. van Eeuwijk, Paul H.C. Eilers (2017). Correcting for spatial heterogeneity in plant breeding experiments with P-splines. Spatial Statistics https://doi.org/10.1016/j.spasta.2017.10.003

Butler, D. G., et al. (2010). Analysis of Mixed Models for S language environments: ASReml-R reference manual. Brisbane, DPI Publications

Douglas Bates, Martin Maechler, Ben Bolker, Steve Walker (2015). Fitting Linear Mixed-Effects Models Using lme4. Journal of Statistical Software, 67(1), 1-48. https://www.jstatsoft.org/article/view/v067i01/0.

Examples

Run this code
# NOT RUN {
## Fit model using lme4.
myModel1 <- fitTD(TD = TDHeat05, design = "ibd", traits = "yield",
                      what = "fixed")

## Summarize results.
summary(myModel1)

## Create base plots of the results.
plot(myModel1)

## Create a pdf report summarizing results.
# }
# NOT RUN {
report(myModel1, outfile = tempfile(fileext = ".pdf"))
# }
# NOT RUN {
## Fit model using SpATS.
myModel2 <- fitTD(TD = TDHeat05, design = "res.rowcol", traits = "yield",
                      what = "fixed")
summary(myModel2)

## Create spatial plots of the results.
plot(myModel2, plotType = "spatial")
# }
# NOT RUN {
report(myModel2, outfile = tempfile(fileext = ".pdf"))
# }
# NOT RUN {
## Fit model using asreml.
if (requireNamespace("asreml", quietly = TRUE)) {
  myModel3 <- fitTD(TD = TDHeat05, design = "res.rowcol", traits = "yield",
                   what = "fixed", engine = "asreml")
  summary(myModel3)

  
# }
# NOT RUN {
  report(myModel3, outfile = tempfile(fileext = ".pdf"))
  
# }
# NOT RUN {
}
# }

Run the code above in your browser using DataCamp Workspace