library(powerlmm)
res <- readRDS("simres.rds")

Power results

cmp <- pmap_dfr(list(x = res, 
              title = c("1. 4 clusters",
                        "2. 4 clusters, PN",
                        "3. 12 clusters",
                        "4. 12 unequal clusters",
                        "5. Random clusters"),
              R = c(1, 1, 1, 50, 100), 
              cores = c(1, 1, 1, 30, 30)),
            compare_power)
kable(cmp, digits = 3)
title get_power_Satt sim_Satt diff % sim_Wald sim_BW
1. 4 clusters 0.762 0.762 0.071 0.872 0.871
2. 4 clusters, PN 0.746 0.748 -0.176 0.870 0.869
3. 12 clusters 0.707 0.710 -0.298 0.746 0.744
4. 12 unequal clusters 0.572 0.573 -0.130 0.615 0.612
5. Random clusters 0.913 0.911 0.192 0.924 0.924

1. 4 clusters

res[[1]]$p
## 
##      Study setup (three-level) 
## 
##               n1 = 11
##               n2 = 50 x 4 (treatment)
##                    50 x 4 (control)
##               n3 = 4      (treatment)
##                    4      (control)
##                    8      (total)
##          total_n = 200    (treatment)
##                    200    (control)
##                    400    (total)
##          dropout =  0,  1,  2,  3,  4,  5,  6,  7,  8,  9, 10 (time)
##                     0, 11, 15, 18, 20, 22, 24, 26, 27, 29, 30 (%, control)
##                     0, 11, 15, 18, 20, 22, 24, 26, 27, 29, 30 (%, treatment)
## icc_pre_subjects = 0.54
## icc_pre_clusters = 0
##        icc_slope = 0.1
##        var_ratio = 0.03
##           cohend = -0.9
summary(res[[1]])
## Model:  correct 
##   Random effects
## 
##          parameter   M_est   theta prop_zero
##  subject_intercept  7.8404  7.8400    0.0000
##      subject_slope  0.1598  0.1600    0.0000
##      cluster_slope  0.0181  0.0178    0.0287
##              error  6.7616  6.7600    0.0000
##        cor_subject -0.1969 -0.2000    0.0000
## 
##   Fixed effects
## 
##       parameter    M_est  theta   M_se SD_est Power Power_bw Power_satt
##     (Intercept) 37.00338 37.000 0.2290 0.2316 1.000       NA        NaN
##       treatment -0.00356 -0.640 0.3238 0.3223 0.050       NA        NaN
##            time -0.64039  0.000 0.0743 0.0765 1.000       NA        NaN
##  time:treatment -0.34333 -0.344 0.1051 0.1083 0.873    0.871      0.761
## ---
## Number of simulations: 10000  | alpha:  0.05
## Time points (n1):  11
## Subjects per cluster (n2 x n3):  50 x 4 (treatment)
##                                  50 x 4 (control)
## Total number of subjects:  400

2. 4 clusters, partially nested

res[[2]]$p
## 
##      Study setup (three-level, partially nested) 
## 
##               n1 = 11
##               n2 = 50 x 5  (treatment)
##                    250 x 1 (control)
##               n3 = 5       (treatment)
##                    0       (control)
##                    5       (total)
##          total_n = 250     (treatment)
##                    250     (control)
##                    500     (total)
##          dropout = No missing data
## icc_pre_subjects = 0.54
## icc_pre_clusters = 0
##        icc_slope = 0.1
##        var_ratio = 0.03
##           cohend = 0.6
summary(res[[2]])
## Model:  correct 
##   Random effects
## 
##          parameter   M_est   theta prop_zero
##  subject_intercept  7.8415  7.8400    0.0000
##      subject_slope  0.1600  0.1600    0.0000
##      cluster_slope  0.0177  0.0178    0.0479
##              error  6.7611  6.7600    0.0000
##        cor_subject -0.1984 -0.2000    0.0000
## 
##   Fixed effects
## 
##       parameter    M_est  theta   M_se SD_est  Power Power_bw Power_satt
##     (Intercept) 36.99954 37.000 0.1998 0.2015 1.0000       NA        NaN
##       treatment -0.00016 -0.640 0.2826 0.2861 0.0515       NA        NaN
##            time -0.63978  0.000 0.0297 0.0296 1.0000       NA        NaN
##  time:treatment  0.23012  0.229 0.0703 0.0727 0.8697    0.869      0.748
## ---
## Number of simulations: 10000  | alpha:  0.05
## Time points (n1):  11
## Subjects per cluster (n2 x n3):  50 x 5 (treatment)
##                                  250 x 1 (control)
## Total number of subjects:  500
## [Model: correct] 0.01% of the Satterthwaite calculations failed
## [Model: correct] 0.01% of the models threw convergence warnings

3. 12 clusters

res[[3]]$p
## 
##      Study setup (three-level) 
## 
##               n1 = 11
##               n2 = 20 x 12 (treatment)
##                    20 x 12 (control)
##               n3 = 12      (treatment)
##                    12      (control)
##                    24      (total)
##          total_n = 240     (treatment)
##                    240     (control)
##                    480     (total)
##          dropout =  0,  1,  2,  3,  4,  5,  6,  7,  8,  9, 10 (time)
##                     0, 11, 15, 18, 20, 22, 24, 26, 27, 29, 30 (%, control)
##                     0, 11, 15, 18, 20, 22, 24, 26, 27, 29, 30 (%, treatment)
## icc_pre_subjects = 0.54
## icc_pre_clusters = 0
##        icc_slope = 0.1
##        var_ratio = 0.03
##           cohend = 0.5
summary(res[[3]])
## Model:  correct 
##   Random effects
## 
##          parameter  M_est   theta prop_zero
##  subject_intercept  7.855  7.8400    0.0000
##      subject_slope  0.160  0.1600    0.0000
##      cluster_slope  0.018  0.0178    0.0083
##              error  6.758  6.7600    0.0000
##        cor_subject -0.199 -0.2000    0.0000
## 
##   Fixed effects
## 
##       parameter    M_est  theta   M_se SD_est  Power Power_bw Power_satt
##     (Intercept) 37.00660 37.000 0.2092 0.2113 1.0000       NA        NaN
##       treatment -0.00913 -0.640 0.2959 0.2991 0.0501       NA        NaN
##            time -0.64074  0.000 0.0514 0.0516 1.0000       NA        NaN
##  time:treatment  0.19235  0.191 0.0727 0.0732 0.7465    0.744       0.71
## ---
## Number of simulations: 10000  | alpha:  0.05
## Time points (n1):  11
## Subjects per cluster (n2 x n3):  20 x 12 (treatment)
##                                  20 x 12 (control)
## Total number of subjects:  480
## [Model: correct] 0.01% of the Satterthwaite calculations failed
## [Model: correct] 0.01% of the models threw convergence warnings

4. Unequal clusters

res[[4]]$p
## 
##      Study setup (three-level) 
## 
##               n1 = 11
##               n2 = 5, 5, 5, 6, 7, 10, 10, 15, 20, 20, 25, 30 (treatment)
##                    5, 5, 5, 6, 7, 10, 10, 15, 20, 20, 25, 30 (control)
##               n3 = 12                                        (treatment)
##                    12                                        (control)
##                    24                                        (total)
##          total_n = 158                                       (treatment)
##                    158                                       (control)
##                    316                                       (total)
##          dropout =  0,  1,  2,  3,  4,  5,  6,  7,  8,  9, 10 (time)
##                     0, 11, 15, 18, 20, 22, 24, 26, 27, 29, 30 (%, control)
##                     0, 11, 15, 18, 20, 22, 24, 26, 27, 29, 30 (%, treatment)
## icc_pre_subjects = 0.54
## icc_pre_clusters = 0
##        icc_slope = 0.1
##        var_ratio = 0.03
##           cohend = 0.5
summary(res[[4]])
## Model:  correct 
##   Random effects
## 
##          parameter   M_est   theta prop_zero
##  subject_intercept  7.8575  7.8400    0.0000
##      subject_slope  0.1600  0.1600    0.0000
##      cluster_slope  0.0179  0.0178    0.0438
##              error  6.7595  6.7600    0.0000
##        cor_subject -0.1986 -0.2000    0.0000
## 
##   Fixed effects
## 
##       parameter    M_est  theta   M_se SD_est  Power Power_bw Power_satt
##     (Intercept) 36.99902 37.000 0.2578 0.2579 1.0000       NA        NaN
##       treatment  0.00631 -0.640 0.3646 0.3623 0.0478       NA        NaN
##            time -0.64043  0.000 0.0593 0.0607 1.0000       NA        NaN
##  time:treatment  0.19130  0.191 0.0839 0.0857 0.6151    0.612      0.573
## ---
## Number of simulations: 10000  | alpha:  0.05
## Time points (n1):  11
## Subjects per cluster:  5, 5, 5, 6, 7, 10, 10, 15, 20, 20, 25, 30 (treatment)
##                        5, 5, 5, 6, 7, 10, 10, 15, 20, 20, 25, 30 (control)
## Total number of subjects:  316
## [Model: correct] 0.14% of the Satterthwaite calculations failed
## [Model: correct] 0.14% of the models threw convergence warnings

5. Random clusters

res[[5]]$p
## 
##      Study setup (three-level) 
## 
##               n1 = 11
##               n2 = rnorm(18, 5, 15) (treatment)
##                    rnorm(18, 5, 15) (control)
##               n3 = 18               (treatment)
##                    18               (control)
##                    36               (total)
##          total_n = 127              (treatment)
##                    127              (control)
##                    254              (total)
##          dropout =  0,  1,  2,  3,  4,  5,  6,  7,  8,  9, 10 (time)
##                     0, 11, 15, 18, 20, 22, 24, 26, 27, 29, 30 (%, control)
##                     0, 11, 15, 18, 20, 22, 24, 26, 27, 29, 30 (%, treatment)
## icc_pre_subjects = 0.54
## icc_pre_clusters = 0
##        icc_slope = 0.1
##        var_ratio = 0.03
##           cohend = 0.7
## 
## NOTE: n2 is randomly sampled
summary(res[[5]])
## Model:  correct 
##   Random effects
## 
##          parameter   M_est   theta prop_zero
##  subject_intercept  7.8373  7.8400    0.0000
##      subject_slope  0.1599  0.1600    0.0000
##      cluster_slope  0.0179  0.0178    0.0473
##              error  6.7609  6.7600    0.0000
##        cor_subject -0.1984 -0.2000    0.0000
## 
##   Fixed effects
## 
##       parameter     M_est  theta   M_se SD_est Power Power_bw Power_satt
##     (Intercept) 36.999483 37.000 0.2418 0.2468 1.000       NA        NaN
##       treatment -0.000795 -0.640 0.3419 0.3479 0.055       NA        NaN
##            time -0.640834  0.000 0.0541 0.0556 1.000       NA        NaN
##  time:treatment  0.267504  0.267 0.0764 0.0786 0.924    0.924      0.911
## ---
## Number of simulations: 10000  | alpha:  0.05
## Time points (n1):  11
## Subjects per cluster:  rnorm(18, 5, 15) (treatment)
##                        rnorm(18, 5, 15) (control)
## Total number of subjects:  371.4 (mean) 366 (median) 78.53 (SD)
## [Model: correct] 0.15% of the Satterthwaite calculations failed
## [Model: correct] 0.15% of the models threw convergence warnings