gendat_med_simple: Generate Simple Mediation Model Data

Description Usage Arguments Details Examples

View source: R/gendat.R

Description

Generates data from a simple mediation model.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
gendat_med_simple(
  n,
  alpha,
  tau_prime,
  beta,
  delta_M,
  delta_Y,
  sigma2_epsilon_M,
  sigma2_epsilon_Y,
  rFUN_X,
  ...
)

Arguments

n

Sample size.

alpha

Path from X to M (α).

tau_prime

Path from X to Y (τ^{\prime}).

beta

Path from M to Y (β).

delta_M

Intercept for the first equation (δ_M).

delta_Y

Intercept for the second equation (δ_Y).

sigma2_epsilon_M

Variance of ε_M (σ^{2}_{ε_{M}}).

sigma2_epsilon_Y

Variance of ε_Y (σ^{2}_{ε_{Y}}).

rFUN_X

The distribution function used to generate values of \mathbf{X}. The default value is rnorm for the Gaussian probability density function.

...

Arguments to pass to rFUN_X.

Details

The simple mediation model is defined by M_i = δ_M + α X_i + ε_{M_i}, and Y_i = δ_Y + τ^{\prime} X_i + β M_i + ε_{Y_i}. X is generated using distribution supplied by rFUN_X (rnorm is the default). Additional arguments to rFUN_X are supplied using the ... argument. M and Y are generated using X and the parameters provided using the regression equations above. Residuals are assumed to be normaly distribution with means of zero and provided variances σ^{2}_{ε_{M}} and σ^{2}_{ε_{Y}}.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
data <- gendat_med_simple(
  n = 100,
  alpha = 0.26^(1 / 2),
  tau_prime = 0,
  beta = 0.26^(1 / 2),
  delta_M = 0.490098,
  delta_Y = 0.490098,
  sigma2_epsilon_M = 0.74,
  sigma2_epsilon_Y = 0.74,
  rFUN_X = rnorm,
  mean = 0,
  sd = 1
)

jeksterslabds/jeksterslabRds documentation built on July 16, 2020, 3:41 p.m.