# NOT RUN {
#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)
# }
Run the code above in your browser using DataLab