Learn R Programming

simglm: Tidy simulation and power analyses

Package Installation

This package can be directly installed through CRAN:

install.packages("simglm")

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

library(devtools)
install_github("lebebr01/simglm")

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:

browseVignettes()
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)

Features

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: https://github.com/lebebr01/simglm/issues. I'm also open to pull requests.

Enjoy!

Copy Link

Version

Install

install.packages('simglm')

Monthly Downloads

285

Version

0.8.9

License

MIT + file LICENSE

Issues

Pull Requests

Stars

Forks

Maintainer

Brandon LeBeau

Last Published

February 7th, 2022

Functions in simglm (0.8.9)

generate_response

Simulate response variable
parse_power

Parse power specifications
simulate_randomeffect

Tidy random effect formula simulation
simulate_knot

Simulate knot locations
parse_formula

Parses tidy formula simulation syntax
sim_factor2

Simulate categorical, factor, or discrete variables
simglm

simglm: A package to simulate and perform power by simulation for models based on the generalized linear model.
simulate_error

Tidy error simulation
sim_time

Simulate Time
sim_continuous2

Simulate continuous variables
run_shiny

Run Shiny Application Demo
parse_randomeffect

Parses random effect specification
replicate_simulation

Replicate Simulation
rbimod

Simulating mixture normal distributions
parse_varyarguments

Parse varying arguments
transform_outcome

Transform response variable
simulate_heterogeneity

Tidy heterogeneity of variance simulation
simulate_fixed

Tidy fixed effect formula simulation
missing_data

Missing Data Functions
parse_correlation

Parse correlation arguments
compute_statistics

Compute Power, Type I Error, or Precision Statistics
desireVar

Computes mixture normal variance
correlate_variables

Correlate elements
parse_crossclass

Parse Cross-classified Random Effects
model_fit

Tidy Model Fitting Function
extract_coefficients

Extract Coefficients
generate_missing

Tidy Missing Data Function