pass.lme.CLb.test: Calculate Power or Sample Size required for Contrasts of...

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

View source: R/pass.lme.R

Description

Interested parameters/linear combinations LB from more than one independent populations can be aggregrate togeter by appending mu vertically and Sigma/n diagonally

Consider Lb~N(MU,SIGMA) as the aggregrated estimates
Any comparison of interested parameters can be formulated by multiplying a contrast matrix C on LB and set

H0: C*LB=d for any vector of value d to be tested

We then have

C*Lb~N(C*MU,C*SIGMA*C')

and

(C*Lb-d)'*inv(C*SIGMA*C')*(C*Lb-d)~chisq(q,lambda)

where degree of freedom q=rank(C*SIGMA*C'),
non-centrality parameter lambda=(C*LB-d)'*inv(C*SIGMA*C')*(C*LB-d)


Power of the test H0 is given by 1-beta=P(chisq(q,lambda)>qchisq(1-alpha,lambda))
Required sample size for desired power can be obtained by bisection method.

Usage

1
2
pass.lme.CLb.test(thetas, C = NULL, d = NULL, alpha = 0.05,
  power = NULL, n = NULL)

Arguments

thetas

list of theta (LB and VLb), can be different for each group

C

Contrast of Matrix

d

Value vector to be tested for all contrast

alpha

significant level

power

desired power for sample size calculation

n

sample size for power calculation /
or sample size ratio with power for sample size calculation (NULL for balanced design)

Details

Technical note

Value

solved.power given sample size n, this gives the power for testing H0
solved.n given the desired power, this gives the sample size for H0

Note

License: GPL-3

Author(s)

Marco Chak Yan YU
Maintainer: Marco Chak Yan YU <[email protected]>

See Also

lme.Lb.dist.theta

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#Example 1 (test fixed effect coefficient 2=0) with power of 80%
# for 1-level LME model, with covariates X, Z: (1,t), t=1,2,3
# for both fixed and random effects, with fixed effect coefficients B: (100,-0.5),
# random effect variance D: (2 1;1 2), residual variance R: 0.2
B <- matrix(c(100,-0.5),2,1)
D <- matrix(c(2,1,1,2),2,2)
R <- 0.2
X <- cbind(rep(1,3),1:3)
Z <- X
theta <- lme.Lb.dist.theta(B,D,R,X,Z)
pass.lme.CLb.test(list(theta),alpha=0.05,power=0.8)
pass.lme.CLb.test(list(theta),alpha=0.05,n=66)

#Example 2 (compare two fixed effect coefficient 2) with power of 80%
# Consider above model as a control group model,
# with an independent treatment group with model same as the control
# except a different fixed effect coefficient 2 for treatment
# = fixed effect coefficient 2 for control x 0.7
theta2 <- theta
theta2$mu <- theta$mu *0.7
C <- matrix(c(1,-1),1,2)
pass.lme.CLb.test(list(theta,theta2),C,alpha=0.05,power=0.8)
pass.lme.CLb.test(list(theta,theta2),C,alpha=0.05,n=1468)

#Example 3 (compare two fixed effect coefficient 2) with power of 80%
# with sample size ratio, control:treatment = 1:2
pass.lme.CLb.test(list(theta,theta2),C,alpha=0.05,power=0.8,n=c(1,2))
pass.lme.CLb.test(list(theta,theta2),C,alpha=0.05,n=c(1101,2202))

#Example 4 (repeated-measures ANOVA for comparing 3 group means) with power of 80%
# for 1-level LME model with mean for group 1, 2 and 3 are 100, 99, 102, respectively,
# each subject to be measured 2 times, with within-subject variance = 15, residual variance = 10
B <- 100
D <- 15
R <- 10
X <- matrix(1,2,1)
Z <- X
theta <- lme.Lb.dist.theta(B,D,R,X,Z)
theta2 <- theta
theta3 <- theta
theta2$mu <- 99
theta3$mu <- 102
C <- rbind(c(1,-1,0),c(1,0,-1))
pass.lme.CLb.test(list(theta,theta2,theta3),C,alpha=0.05,power=0.8)
pass.lme.CLb.test(list(theta,theta2,theta3),C,alpha=0.05,n=41)

pass.lme documentation built on Aug. 20, 2019, 5:13 p.m.