Simulate Models Based on the Generalized Linear Model

Simulates regression models, including both simple regression and generalized linear mixed models with up to three level of nesting. Power simulations that are flexible allowing the specification of missing data, unbalanced designs, and different random error distributions are built into the package.

Build Status AppVeyor build status CRAN_Status_Badge

Package Installation

This package can be directly installed through CRAN:


The development version of the package can be installed by using the devtools package.


Introduction to the simglm package

The best way to become oriented with the simglm package is through the package vignette. There are two ways to get to the vignettes (both will open a browser to view the vignette). Below is an example loading the "Intro" vignette directly:

vignette("Intro", package = "simglm")

Note: If you install the development version of the package, you may need to tell R to build the vignettes when installing the simglm package by doing the following:

install_github("lebebr01/simglm", build_vignettes = TRUE)


A flexible suite of functions to simulate nested data.
Currently supports the following features:

  • Longitudinal data simulation
  • Three levels of nesting
  • Specification of distribution of random components (random effects and random error)
  • Specification of serial correlation
  • Specification of the number of variables
    • Ability to add time-varying covariates
    • Specify the mean and variance of fixed covariate variables
    • Factor variable simulation
    • Ordinal variable simulation
  • Generation of mixture normal distributions
  • Cross sectional data simulation
  • Single level simulation
  • Power by simulation
    • Vary parameters for a factorial simulation design.
    • Can vary model fitted to the data to misspecify directly.
  • Simulation of missing data
  • Include other distributions for covariate simulation.
  • Continuous, Logistic (dichotomous), and Poisson (count) outcome variables.
  • Cross classified simulation and power

Bugs/Feature Requests

Bugs and feature requests are welcomed. Please track these on GitHub here: I'm also open to pull requests.



simglm 0.7.2

  • Small maintenance fix for incoming 0.8 dplyr.

simglm 0.7.1

  • Release for new tidy simulation framework
  • New vignettes showing this functionality

simglm 0.6.3

  • Add piecewise linear simulation.

simglm 0.6.2

  • Add cross classified model simulation
  • Add option to specify any model to fit for power analysis
    • This brought about a change to use broom::tidy.

simglm 0.6.1

  • Generalize fact_vars code
    • This now is similar to cov_param

simglm 0.6.0

  • Shiny Application works again!
    • Can now simulate and run power.
    • Able to download simulation and power tables (I think).

simglm 0.5.3

  • Fixed basic functionality of Shiny application
    • This includes simulation and power
      • Needs more testing at this stage.

simglm 0.5.2

  • Addition of count outcome from sim_glm.
    • This added an additional argument that must be specified:
      • outcome_type = 'logistic' = 0/1 dichotomous simulation
      • outcome_type = 'poisson' = count outcomes.

simglm 0.5.1

  • Bug fix for sim_glm when using fact_vars generation options.

simglm 0.5.0

  • Heterogeneity of variance simulation
  • Flexible time specification for longitudinal models
  • Change 'lvl' to 'level' throughout package
  • Flexible specification of unbalanced simulation
  • Misspecification of model for power analysis
  • Expand power output.

simglm 0.4.0

  • Update to add ability to simulate covariates from any R distribution function
    • Old code will no longer work with this new version.
    • Added new opts argument to cov_param for optional distribution arguments.
  • Adjusted vignettes to follow new code
  • Adjusted unit tests.
  • Added documentation for changes, including in vignettes.

simglm 0.3.4

  • Added a file to track changes to the package.

Reference manual

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


0.8.8 by Brandon LeBeau, 5 months ago

Report a bug at

Browse source code at

Authors: Brandon LeBeau [aut, cre]

Documentation:   PDF Manual  

Task views: Clinical Trial Design, Monitoring, and Analysis

MIT + file LICENSE license

Imports stats, methods, Matrix, rlang, dplyr, purrr, broom, future.apply

Suggests knitr, lme4, nlme, testthat, shiny, e1071, ggplot2, tidyr, geepack, rmarkdown, future, splines, covr

See at CRAN