generateMed: Generate a high-dimensional mediation dataset

Description Usage Arguments Value Examples

View source: R/dataGeneration.R

Description

This function generates a dataset from an x -> M -> y model, where M may be of any size with any correlation matrix.

Usage

1
2
3
generateMed(n = 100L, a = 0.3, b = 0.3, r2y = 0.5, dir = 0,
  Sigma, residual = FALSE, empirical = FALSE, scaley = FALSE,
  forma = identity, formb = identity)

Arguments

n

Sample size

a

Vector of a path coefficients within 0 and 1

b

Vector of b path coefficients within 0 and 1

r2y

Proportion of explained variance in y. Set to b %*% Sigma %*% b for var(y) == 1.

dir

Direct path from x to y

Sigma

Desired true covariance matrix between the mediators M

residual

Whether Sigma indicates residual or marginal covariance

empirical

Ensure observed data matrix has exactly the requested covmat (only if Sigma is specified)

scaley

Whether to standardise y (changes b path coefficients)

forma

Functional form of the a paths. Function that accepts a matrix as input and transforms each column to the desired form.

formb

Functional form of the b paths. Function that accepts a vector.

Value

A data frame with columns x, M.1 - M.p, y

Examples

1
2
3
4
5
# Generate a suppression dataset where M.2 is suppressed
sup <- generateMed(n = 100,
                   a = c(-0.4, 0.4),
                   b = c(0.8, 0.48),
                   Sigma = matrix(c(1, -0.6, -0.6, 1), 2))

cmfilter documentation built on April 11, 2019, 5:07 p.m.