Power Analysis for Longitudinal Multilevel Models

Calculate power for the 'time x treatment' effect in two- and three-level multilevel longitudinal studies with missing data. Both the third-level factor (e.g. therapists, schools, or physicians), and the second-level factor (e.g. subjects), can be assigned random slopes. Studies with partially nested designs, unequal cluster sizes, unequal allocation to treatment arms, and different dropout patterns per treatment are supported. For all designs power can be calculated both analytically and via simulations. The analytical calculations extends the method described in Galbraith et al. (2002) , to three-level models. Additionally, the simulation tools provides flexible ways to investigate bias, Type I errors and the consequences of model misspecification.


Travis-CI Build Status CRAN_Status_Badge

Power Calculations for Longitudinal Multilevel/Linear Mixed Models.

Overview

The purpose of powerlmm is to help design longitudinal treatment studies, with or without higher-level clustering (e.g. by therapists, groups, or physician), and missing data. The main features of the package are:

  • Longitudinal two- and three-level (nested) linear mixed models, and partially nested designs.
  • Random slopes at the subject- and cluster-level.
  • Missing data.
  • Unbalanced designs (both unequal cluster sizes, and treatment groups).
  • Design effect, and estimated type I error when the third-level is ignored.
  • Fast analytical power calculations for all designs.
  • Explore bias, type 1 error and model misspecification using convenient simulation methods.

Installation

powerlmm can be installed from CRAN and GitHub.

install.packages("powerlmm")
 
# GitHub
devtools::install_github("rpsychologist/powerlmm", build_vignettes = TRUE)

Example usage

This is an example of setting up a three-level longitudinal model with random slopes at both the subject- and cluster-level, with different missing data pattern per treatment arm. Here relative standardized inputs are used, but unstandardized raw parameters values can also be used.

library(powerlmm)
d <- per_treatment(control = dropout_weibull(0.3, 2),
              treatment = dropout_weibull(0.2, 2))
p <- study_parameters(n1 = 11,
                      n2 = 10,
                      n3 = 5,
                      icc_pre_subject = 0.5,
                      icc_pre_cluster = 0,
                      icc_slope = 0.05,
                      var_ratio = 0.02,
                      dropout = d,
                      cohend = -0.8)
 
p
#> 
#>      Study setup (three-level) 
#> 
#>               n1 = 11
#>               n2 = 10  (treatment)
#>                    10  (control)
#>               n3 = 5   (treatment)
#>                    5   (control)
#>                    10  (total)
#>          total_n = 50  (treatment)
#>                    50  (control)
#>                    100 (total)
#>          dropout =  0,  1,  2,  3,  4,  5,  6,  7,  8,  9, 10 (time)
#>                     0,  0,  1,  3,  6,  9, 12, 16, 20, 25, 30 (%, control)
#>                     0,  0,  1,  2,  4,  5,  8, 10, 13, 17, 20 (%, treatment)
#> icc_pre_subjects = 0.5
#> icc_pre_clusters = 0
#>        icc_slope = 0.05
#>        var_ratio = 0.02
#>           cohend = -0.8
plot(p)

get_power(p)
#> 
#>      Power calculation for longitudinal linear mixed model (three-level)
#>                            with missing data and unbalanced designs 
#> 
#>               n1 = 11
#>               n2 = 10  (treatment)
#>                    10  (control)
#>               n3 = 5   (treatment)
#>                    5   (control)
#>                    10  (total)
#>          total_n = 50  (treatment)
#>                    50  (control)
#>                    100 (total)
#>          dropout =  0,  1,  2,  3,  4,  5,  6,  7,  8,  9, 10 (time)
#>                     0,  0,  1,  3,  6,  9, 12, 16, 20, 25, 30 (%, control)
#>                     0,  0,  1,  2,  4,  5,  8, 10, 13, 17, 20 (%, treatment)
#> icc_pre_subjects = 0.5
#> icc_pre_clusters = 0
#>        icc_slope = 0.05
#>        var_ratio = 0.02
#>           cohend = -0.8
#>            power = 0.68

Several convenience functions are also included, e.g. for creating power curves.

x <- get_power_table(p, n2 = 5:10, n3 = c(4, 8, 12), cohend = c(0.5, 0.8))
plot(x)

Launch interactive web application

The package's basic functionality is also implemented in a Shiny web application, aimed at users that are less familiar with R. Launch the application by typing

library(powerlmm)
shiny_powerlmm()

News

Reference manual

It appears you don't have a PDF plugin for this browser. You can click here to download the reference manual.

install.packages("powerlmm")

0.3.0 by Kristoffer Magnusson, 2 months ago


https://github.com/rpsychologist/powerlmm


Report a bug at https://github.com/rpsychologist/powerlmm/issues


Browse source code at https://github.com/cran/powerlmm


Authors: Kristoffer Magnusson [aut, cre]


Documentation:   PDF Manual  


GPL (>= 3) license


Imports stats, methods, parallel, lme4, Matrix, MASS, scales, utils

Suggests testthat, dplyr, tidyr, knitr, rmarkdown, pbmcapply, lmerTest, ggplot2, ggsci, viridis, gridExtra, shiny, shinydashboard


See at CRAN