Skip to contents

Extract and calculate various results for fitted models such as BLUEs, BLUPs, unit errors and heritabilities. For a full list of results that can be extracted, see the table below.

The result(s) to extract can be specified in what.
If a single result is extracted, this result is returned as a data.frame, If this is not possible, because the format of the result is incompatible with the data.frame format, the result is returned as a list. E.g. if BLUEs are extracted, the output of the function is a data.frame with BLUEs. However if varCompF is extracted, the output of the function is a list.

Results that are returned as data.frame are marked as such in the asDataFrame column in the table. If the default return value for a result is a data.frame that can be overridden by the user by specifying asDataFrame = FALSE. When doing so the result will be returned as a list of data.frames, one per trial. They other way round is not possible. If a result is returned as a list according to the table, it cannot be returned as a data.frame.
If multiple results are extracted at the same time, these are always returned as a list.

Most results can only be calculated if a model is fitted with genotype as fixed or with genotype as random. E.g. to compute heritabilities a model should be fitted with genotype as random effect. This is indicated in the table in the column model with "F" and "R" respectively.

Possible options for what are:

resultmodeldescriptionasDataFrame
BLUEsFBest Linear Unbiased Estimatorsyes
seBLUEsFstandard errors of the BLUEsyes
ueFunit errors - only for lme4 and asremlyes
varCompFFvariance components for the model with genotype as fixed component
fittedFfitted values for the model with genotype as fixed componentyes
residFFresiduals for the model with genotype as fixed componentyes
stdResFFstandardized residuals for the model with genotype as fixed componentyes
waldFresults of the wald test - only for lme4 and asreml
CVFCoefficient of Variationyes
rDfFFresidual degrees of freedom for the model with genotype as fixed componentyes
sedFstandard error of difference - only for asreml
lsdFleast significant difference - only for asreml
BLUPsRBest Linear Unbiased Predictorsyes
seBLUPsRstandard errors of the BLUPsyes
heritabilityRgeneralized heritabilityyes
varCompRRvariance components for the model with genotype as random component
varGenRgenetic variance componentyes
varErrRresidual variance componentyes
varSpatRspatial variance components - only for SpATS
rMeansRfitted values for the model with genotype as random componentyes
ranEfRrandom genetic effectsyes
residRRresiduals for the model with genotype as random componentyes
stdResRRstandardized residuals for the model with genotype as random componentyes
rDfRRresidual degrees of freedom for the model with genotype as random componentyes
effDimReffective dimensions - only for SpATS
ratEffDimRratios of the effective dimensions - only for SpATS

Usage

extractSTA(
  STA,
  trials = names(STA),
  traits = NULL,
  what = "all",
  asDataFrame = length(what) == 1 && what != "all",
  keep = NULL,
  restoreColNames = FALSE
)

Arguments

STA

An object of class STA.

trials

A character vector of trials for which the statistics should be computed. If not supplied, statistics are computed for all trials that have been modeled.

traits

A character vector of traits for which the statistics should be computed. If not supplied, statistics are computed for all traits that have been modeled.

what

A character vector indicating which statistics should be computed. Most statistics are available for all models, some only for models fitted using a certain engine. If this is the case, this is indicated in the list with options in details.
If what = "all", all available statistics are computed.

asDataFrame

Should the output be reshaped to a data.frame. This is only possible if the number of statistics to extract is one.

keep

A character vector of column(s) in the object of class TD used for modeling. These columns will be kept as output when computing fitted values, residuals, standardized residuals and rMeans. Columns can also be kept when computing (se)BLUEs and (se)BLUPs but only if the column to keep contains unique values for the modeled variables, i.e. a column repId with several different values per genotype cannot be kept.

restoreColNames

Should the original column names be restored in the output of the extracted data?

Value

Depending on the input either a data.frame or a list with, per trial for which statistics have been extracted, a list of those statistics.

See also

Examples

## Fit model using SpATS.
modSp <- fitTD(TD = TDHeat05,
               design = "res.rowcol",
               traits = "yield")
#> Using SpATS for fitting models.

## Extract all available statistics from the fitted model.
extr <- extractSTA(modSp)

## Extract only the BLUEs from the fitted model.
BLUEs <- extractSTA(modSp,
                    what = "BLUEs")

## Extract only the BLUEs from the fitted model and keep trial as variable in
## the output.
BLUEs2 <- extractSTA(modSp,
                     what = "BLUEs",
                     keep = "trial")