View source: R/dataGeneration.R
generateMed | R Documentation |
This function generates a dataset from an x -> M -> y model, where M may be of any size with any correlation matrix.
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
)
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
|
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. |
A data frame with columns x, M.1 - M.p, y
# 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))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.