med_simple_lav: Simple Mediation Model (lavaan)

Description Usage Arguments Author(s) Examples

View source: R/med.R

Description

Estimates the indirect effect in a simple mediation model, that is the product of α and β from M_i = δ_M + α X_i + ε_{M_i} and Y_i = δ_Y + τ^{\prime} X_i + β M_i + ε_{Y_i} using lavaan.

Usage

1
med_simple_lav(data, scale = FALSE, minimal = TRUE, est = FALSE, ...)

Arguments

data

A matrix with variables X, M, and Y.

scale

Logical. If TRUE, scales the data before fitting the model.

minimal

Logical. If TRUE, returns the indirect effect of X on Y through M. If FALSE, returns all the regression coefficients estimated.

est

Logical. If TRUE, returns a vector of parameter estimates and standard errors. If FALSE, returns the lavaan object.

...

Arguments to pass to lavaan::sem.

Author(s)

Ivan Jacob Agaloos Pesigan

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
Sigma <- matrix(
  data = c(
    225, 112.50, 56.25,
    112.5, 225, 112.5,
    56.25, 112.50, 225
  ),
  ncol = 3
)
mu <- c(100, 100, 100)
data <- gendat_mvn(
  n = 100,
  Sigma = Sigma,
  mu = mu
)
med_simple_lav(data = data, minimal = FALSE)

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