randomEffectsMatrix: Calculates the variance covariance matrix for a multivariate...

Description Usage Arguments Details Value Author(s) See Also Examples

View source: R/powslopes_new2.R View source: R/powslopes_new1.R

Description

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

Usage

1
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}=μ_t+Σ γ_j z_{t,j}+σ^2 ε, where γ_j are random variables with mean 0 and and variance covariance vs, and z is zMatrix, ε 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

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
 #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)

LPower documentation built on Dec. 12, 2019, 1:06 a.m.