Unlimited learning, half price | 50% off

Last chance! 50% off unlimited learning

Sale ends in


gremlin (version 1.0.1)

covFun: (Co)variance parameter transformations.

Description

Converts lists of (co)variance parameters either between list and vector format or between the theta and nu scales.

Usage

stTrans(x)

conTrans(Gcon, Rcon)

start2theta(Gstart, Rstart, name = NULL)

matlist2vech(theta)

vech2matlist(vech, skeleton)

theta2nu_trans(theta)

nu2theta_trans(nu)

theta2nu_lambda(theta, thetaG, thetaR)

nu2theta_lambda(nu, sigma2e, thetaG, thetaR)

nuVar2thetaVar_lambda(object)

nuAI2thetaAIinv_lambda(object)

nu2theta_noTrans(nu, thetaG, thetaR)

Arguments

x, theta, nu

A list of matrices containing the (co)variance parameters of the model.

Gcon, Rcon

A list of starting (co)variance constraints for the G-structure (random effects terms) or R-structure (residual).

Gstart, Rstart

A list of starting (co)variance values for the G-structure (random effects terms) or R-structure (residual).

name

An (optional) character vector containing the (co)variance component names.

vech

A vector of (co)variance parameters.

skeleton

An example structure to map vech onto.

thetaG, thetaR

A vector indexing the G-structure or R-structure components, respectively.

sigma2e

A numeric estimate of the factored out residual variance from the mixed model equations (i.e., the ‘lambda’ scale) σe2.

object

An object of class ‘gremlin’.

Value

Functions are specified to mostly return either a list of matrices (structure as defined by the “skel” attribute or in the skeleton object) or a vector containing the (co)variance parameters of the model. Additional list elements returned can be:

thetaG

A vector indexing the G-structure components.

thetaR

A vector indexing the R-structure components.

Alternatively, nuVar2thetaVar_lambda and nuAI2thetaAIinv_lambda return a vector and matrix, respectively, holding the sampling (co)variances of the model (co)variance parameters both on the theta scale. These are elements of the inverse Average Information matrix.

Details

  • stTrans Transform start parameters into lower triangle matrices of class dsCMatrix.

  • conTrans Transformation of starting constraints to correct format.

  • start2theta Converts lists of starting values for (co)variance parameters to a theta object used to structure the (co)variance components within gremlin.

  • matlist2vech Converts a list of (co)variance parameter matrices to a vector with a “skel” attribute.

  • vech2matlist Converts a vector of (co)variance parameters to a list of covariance matrices.

  • theta2nu_trans Transforms theta to nu scale by taking the Cholesky factor of each covariance matrix and then replacing the diagonals with their (natural) logarithms. Done to ensure matrices are positive definite.

  • nu2theta_trans Back transformation from theta2nu_trans: exponentiates the diagonal elements of each matrix then calculates the cross-product.

  • theta2nu_lambda Transformation that factors out a residual variance so that nu contains the ‘lambda’ parameterization: ratios of variance parameters with the residual variance.

  • nu2theta_lambda Back transformation from theta2nu_lambda.

  • nuVar2thetaVar_lambda Transformation of Sampling Variances from lambda Scale for theta.

  • nuAI2thetaAIinv_lambda Transform AI matrix from lambda Scale to AI-inverse of theta.

  • nu2theta_noTrans Structures theta when not transformed.

Examples

Run this code
# NOT RUN {
  # User-specified starting parameters
  thetaOut <- start2theta(Gstart = list(matrix(1), matrix(2)),
    Rstart = matrix(3))
  ## convert to a vector and then back into a matrix list
  thetav <- matlist2vech(thetaOut$theta)
  theta <- vech2matlist(thetav, attr(thetav, "skel"))
    identical(thetaOut$theta, theta)  #<-- should be TRUE
  # lambda parameterization transformation
  nu <- theta2nu_lambda(theta, thetaOut$thetaG, thetaOut$thetaR)
  # back-transform from (lambda scale) nu to theta
  ## For example, when the sigma2e estimate=0.5
  theta2 <- nu2theta_lambda(nu, sigma2e = 0.5, thetaOut$thetaG, thetaOut$thetaR)
# }

Run the code above in your browser using DataLab