randomEffectsMatrix {LPower}R Documentation

Calculates the variance covariance matrix for a multivariate normal vector when there are random effects.

Description

Computes the variance covariance matrix of an m vector which results from a random effects model.

Usage

randomEffectsMatrix(zMatrix, vs, sigma2)

Arguments

zMatrix

An m X p design matrix which specifies how p random variables with zero mean are linearly related to the m-dimensional normal vector.

vs

The p X p variance covariance matrix of the random effects,

sigma2

The error variance.

Details

We assume that y_{t}=\mu_t+\Sigma \gamma_j z_{t,j}+\sigma^2 \epsilon, where \gamma_j are random variables with mean 0 and and variance covariance vs, and z is zMatrix, \epsilon is a standard normal random variable. The zMatrix could be a list of matricies

Value

Either a single variance covariance matrix or a list of them if zMatrix is a list.

Author(s)

David A. Schoenfeld

See Also

LPower,randomSlopesMatrix

Examples

 #Creates random variance covariance matrix for random follow up model
 #where baseline is random among patients and all follow up have a compound symetry structure
 #from a common random effect
vars=randomEffectsMatrix(cbind(rep(1,5),matrix(c(0,rep(1,4)),5,1)),
            matrix(c(31.8,.8527,.8527,.6687),2,2),2.7085)
LPower(sample_size=40,power=.8,
          xMatrix=list(cbind(1,c(0,rep(1,4)),0),cbind(1,c(0,rep(1,4)),c(0,rep(1,4)))),vMatrix=vars)
#Creates random variance covariance matrix for random slopes model
vars=randomEffectsMatrix(cbind(rep(1,5),0:4),
            matrix(c(31.8,.8527,.8527,.6687),2,2),2.7085)
LPower(sample_size=40,power=.8,
       xMatrix=list(cbind(1,0:4,0),cbind(1,0:4,0:4)),vMatrix=vars)


[Package LPower version 0.1.1 Index]