aiFun: Sampling (co)variances

View source: R/aiFun.R

aiFunR Documentation

Sampling (co)variances

Description

This function returns the sampling (co)variances of the variance components fitted in an mixed model solved using the Average Information algorithm

Usage

aiFun(model = NULL, AI.vec = NULL, inverse = TRUE, Dimnames = NULL)

Arguments

model

A model object returned by a call to the asreml function.

AI.vec

A numeric vector of the Average Information matrix. The order must be the row-wise lower triangle of the matrix (including the diagonal).

inverse

A logical indicating whether the elements of the inverse Average Information matrix are being provided. If FALSE, the Average Information matrix (and not its inverse) is being supplied.

Dimnames

A vector of characters if names are desired for the output (co)variance matrix. If not specified, either the default labels from the asreml object will be used or the rows and columns will be unlabeled.

Details

The inverse of the Average Information matrix provides the sampling (co)variance of each (co)variance component in the random portion of the mixed model. If a model from the ASReml-R function is supplied (model is not NULL), this function extracts the inverse of the AI matrix from an ASReml-R model and organizes it so that the sampling covariances between random terms are the off-diagonals and the sampling variances of random terms are located along the diagonal. The order of the variances along the diagonal is the same as the order entered in the random section of the asreml function. This is also the same order as the rows of a call to the summary function, summary(model)$varcomp.

If model is NULL then AI.vec should contain the vector of values from an Average Information matrix. The function will then reconstruct this matrix, invert it, and supply the sampling (co) variances for the random terms in the model as described above. Note, either model or AI.vec must be supplied, but not both.

Value

A matrix of k x k dimensions is returned, if k is the number of (co)variance components estimated in the model. Sampling covariances are above and below the diagonal while variances are located along the diagonal. If Dimnames is specified, the row and column names are assigned according the vector of names in this argument.

Note

The vector of Dimnames should match the same order of variance components specified in the model.

Author(s)

matthewwolak@gmail.com

References

Gilmour, A.R., Gogel, B.J., Cullis, B.R., & Thompson, R. 2009. ASReml User Guide Release 3.0. VSN International Ltd., Hemel Hempstead, UK.

Examples


  ## Not run: 
    library(asreml)
    ginvA <- ainverse(warcolak)
    ginvD <- makeD(warcolak[, 1:3])$listDinv
      attr(ginvD, "rowNames") <- as.character(warcolak[, 1])
      attr(ginvD, "INVERSE") <- TRUE
    warcolak$IDD <- warcolak$ID
    warcolak.mod <- asreml(trait1 ~ sex,
     random = ~ vm(ID, ginvA) + vm(IDD, ginvD), 
	data = warcolak) 
    summary(warcolak.mod)$varcomp
    aiFun(model = warcolak.mod, Dimnames = c("Va", "Vd", "Ve"), inverse = TRUE)    
   
## End(Not run)

  output <- c(7.3075921, 7.0635161, 12.3423380, 1.9539486, 2.7586340, 0.6626111)
  aiFun(AI.vec = output, inverse = FALSE, Dimnames = c("Va", "Vd", "Ve"))


nadiv documentation built on May 29, 2024, 10:40 a.m.