mechanisms {mlmpower}R Documentation

Helper functions for producing Missing Data Mechanisms

Description

Functions to generate data that always follows a specific mechanism in accordance to a single-level model.

Usage

# Generate MCAR data on outcome
MCAR(mis.rate)

# Generate MAR data on outcome due to `cause`
MAR(mis.rate, cause, r2, lower = TRUE)

Arguments

mis.rate

A proportion for the missing data rate at population level

cause

A character for a variable name that is the cause of missingness

r2

A proportion of variance explained by the cause in the missing data indicator's latent propensity

lower

A logical for the lower or upper tail being more likely to be missing

See Also

power_analysis

Examples

# Create Model
model <- (
    outcome('Y')
    + within_predictor('X')
    + effect_size(icc = 0.1)
)

# Induce MCAR data on outcome
set.seed(19723)
model |> power_analysis(50, 5, 50, mechanism = MCAR(0.25)) -> powersim_mcar

# Induce MAR data on outcome
set.seed(19723)
model |> power_analysis(
   50, 5, 50,
   mechanism = MAR(0.25, 'X', 0.6)
) -> powersim_mar

[Package mlmpower version 1.0.8 Index]