Learn R Programming

⚠️There's a newer version (0.8.9) of this package.Take me there.

Regression simulation function

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

234

Version

0.8.0

License

MIT + file LICENSE

Issues

Pull Requests

Stars

Forks

Maintainer

Brandon LeBeau

Last Published

June 12th, 2020

Functions in simglm (0.8.0)

generate_response

Simulate response variable
generate_missing

Tidy Missing Data Function
replicate_simulation

Replicate Simulation
extract_coefficients

Extract Coefficients
rbimod

Simulating mixture normal distributions
parse_randomeffect

Parses random effect specification
sim_fixef_nested

Simulates design matrix.
parse_varyarguments

Parse varying arguments
sim_factor2

Simulate categorical, factor, or discrete variables
parse_power

Parse power specifications
parse_formula

Parses tidy formula simulation syntax
sim_glm_nested3

Function to simulate three level nested data
sim_glm

Master generalized simulation function.
sim_glm_nested

Simulate two level logistic regression model
sim_pow_glm

Master power simulation function for glm models.
run_shiny

Run Shiny Application Demo
model_fit

Tidy Model Fitting Function
sim_continuous

Simulate continuous variables
parse_crossclass

Parse Cross-classified Random Effects
sim_pow_glm_nested

Power simulation for nested designs
data_reg_nested3

Simulates three level nested data with a single third level random effect
sim_err_single

Function that simulates errors.
sim_pow_glm_single

Function to simulate power.
sim_pow_glm_nested3

Power simulation for nested designs
sim_reg_nested3

Function to simulate three level nested data
simulate_error

Tidy error simulation
missing_data

Missing Data Functions
simulate_fixed

Tidy fixed effect formula simulation
sim_continuous2

Simulate continuous variables
sim_factor

Simulate categorical, factor, or discrete variables
sim_reg_single

Master function to simulate single level data.
sim_err_nested

Function that simulates errors.
simulate_heterogeneity

Tidy heterogeneity of variance simulation
simulate_randomeffect

Tidy random effect formula simulation
sim_knot

Simulate knot locations
sim_pow_single

Function to simulate power.
sim_pow

Master power simulation function.
sim_rand_eff

Function to simulate random effects.
sim_glm_single

Simulation single level logistic regression model
sim_fixef_nested3

Simulates design matrix.
sim_time

Simulate Time
sim_fixef_single

Simulates design matrix for single level model.
sim_reg

Master continuous simulation function.
simglm

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

Power simulation for nested designs
sim_pow_nested

Power simulation for nested designs
sim_reg_nested

Function to simulate nested data
varcov_randeff

Function to create random effect variance-covariance matrices
transform_outcome

Transform response variable
data_glm_nested

Generate logistic regression outcome
data_reg_nested

Simulates two level nested data
data_reg_single

Simulates single level data
corr_variables

Function to correlate variables
compute_statistics

Compute Power, Type I Error, or Precision Statistics
data_glm_nested3

Simulates three level nested data with a single third level random effect
cross_class

Cross Classified Generation
desireVar

Computes mixture normal variance
data_glm_single

Generate logistic regression outcome