Simulation and power analysis of generalized linear mixed models
[This article was first published on Educate-R - R, and kindly contributed to R-bloggers]. (You can report issue about the content on this page here)
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.
Simulation and power analysis of generalized linear mixed models
Brandon LeBeau
University of Iowa
Overview
- (G)LMMs
- Power
simglm
package- Demo Shiny App!
Linear Mixed Model (LMM)
Power
- Power is the ability to statistically detect a true effect (i.e. non-zero population effect).
- For simple models (e.g. t-tests, regression) there are closed form equations for generating power.
- R has routines for these:
power.t.test, power.anova.test
- Gpower3
- R has routines for these:
Power Example
n <- seq(4, 1000, 2) power <- sapply(seq_along(n), function(i) power.t.test(n = n[i], delta = .15, sd = 1, type = 'two.sample')$power)
Power for (G)LMM
- Power for more complex models is not as straightforward;
- particularly with messy real world data.
- There is software for the GLMM models to generate power:
- Optimal Design: http://hlmsoft.net/od/
- MLPowSim: http://www.bristol.ac.uk/cmm/software/mlpowsim/
- Snijders, Power and Sample Size in Multilevel Linear Models.
Power is hard
- In practice, power is hard.
- Need to make many assumptions on data that has not been collected.
- Therefore, data assumptions made for power computations will likely differ from collected sample.
- A power analysis needs to be flexible, exploratory, and well thought out.
simglm
Overview
simglm
aims to simulate (G)LMMs with up to three levels of nesting (aim to add more later).- Flexible data generation allows:
- any number of covariates and discrete covariates
- change random distribution
- unbalanced data
- missing data
- serial correlation.
- Also has routines to generate power.
Demo Shiny App
shiny::runGitHub('simglm', username = 'lebebr01', subdir = 'inst/shiny_examples/demo')
or
devtools::install_github('lebebr01/simglm') library(simglm) run_shiny()
- Must have following packages installed:
simglm, shiny, shinydashboard, ggplot2, lme4, DT
.
Questions?
- Twitter: @blebeau11
- Website: http://educate-r.org
- Slides: http://educate-r.org/2016/06/29/user2016.html
- GitHub: http://github.com/lebebr01
To leave a comment for the author, please follow the link and comment on their blog: Educate-R - R.
R-bloggers.com offers daily e-mail updates about R news and tutorials about learning R and many other topics. Click here if you're looking to post or find an R/data-science job.
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.