Power Analysis for Linear and Generalized Linear Mixed Models

Prospective power analysis and design planning using the "plug-in" approach described by Piepho et al. (2022) and Stroup, Ptukhina and Garai (2024) . Expected treatment means and the proposed experimental design are encoded in an artificial data set, and a model is "fit" to it with random effect variances, correlations and residual dispersion fixed at user-specified values rather than being estimated. The resulting standard errors are used to compute the power of F-tests and user-defined contrasts, as well as Type S (sign) and Type M (magnitude) error rates (Gelman and Carlin, 2014 ). Models are fit with 'glmmTMB', so the approach accommodates non-normal responses, heteroscedasticity, nested and crossed random effects, correlated random slopes, and structured covariances such as AR(1) and spatial correlation. Helper functions convert standard deviations and correlations into the internal parameterization of 'glmmTMB' and report the order in which random effect parameters must be supplied. Denominator degrees of freedom can be computed by the Kenward-Roger, residual or asymptotic methods (or can be specified by users), and contrasts are specified through 'emmeans'. Vignettes cover estimated marginal means, contrast specification, and worked examples for common agricultural designs.


powerutilities

This package provides some tools for power analysis when using what Piepho et. al (2022) called the "plug-in approach" to power analysis, as described in the chapter Precision, Power, Sample Size and Planning in Generalized Linear Mixed Models: Modern Concepts, Methods and Applications.

The basic idea is to encode information about sample size and expected treatment means (and differences) for the proposed experiment in a fake data set, to then specify a model encoding information about the design of the proposed experiment, and finally to "fit" the model while specifying (rather than estimating) the values for the random effects and dispersion parameters (based on pilot studies, previously published research or estimated guesswork). The result is that the mixed modelling software does all the requisite work of calculating standard errors upon which confidence intervals and statistical power can be derived. By manipulating the fake data set, model, or variance parameter values, it becomes possible to explore how differences in sample size, effect size, experimental design, or random effects will impact power.

A very important feature of the package are its vignettes (still under development), which serve to:

  • Provide a fuller, more detailed description of this approach to power analysis, as well as some useful background information on the use of estimated marginal means and contrasts in R

  • Present a variety of practical examples demonstrating the various ways this approach can serve the concrete needs of practicing researchers (especially those in the agricultural sciences)

  • Provide a vehicle for introducing and discussing a number of complexities related to the use of mixed models, and generalized linear mixed models in particular, which I think are not as fully or widely appreciated as they should be.

Please note that this effort remains very much a work in progress. Any issues, concerns, questions, bugs, feature requests, etc., can be posted on the Issues page (https://github.com/SimonShamusRiley/powerutilities/issues).

Installation

You can install the development version of powerutilities from Github with:

install.packages("devtools")
devtools::install_github('SimonShamusRiley/powerutilities', 
                          build_vignettes = T)

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("powerutilities")

0.7.1 by Simon Riley, 7 hours ago


https://github.com/SimonShamusRiley/powerutilities/tree/main


Report a bug at https://github.com/SimonShamusRiley/powerutilities/issues


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


Authors: Simon Riley [aut, cre]


Documentation:   PDF Manual  


BSD_3_clause + file LICENSE license


Imports dplyr, emmeans, glmmTMB, pbkrtest, reformulas, retrodesign, rlang

Suggests agridat, knitr, rmarkdown, testthat, tidyr


See at CRAN