sem_appl function

Structural equation modeling approach

Structural equation modeling approach

Function which uses the sem function in the lavaan package to fit the model [REMOVE_ME]L=α0+α1X+ϵ1,ϵ1N(0,σ12)L=α0+α1X+ϵ1,ϵ1 N(0,σ12)[REMOVEME2] L = \alpha_0 + \alpha_1 \cdot X + \epsilon_1, \epsilon_1 \sim N(0,\sigma_1^2)L = \alpha0 + \alpha1*X + \epsilon1, \epsilon1 ~ N(0,\sigma1^2) [REMOVE_ME_2]

[REMOVE_ME]K=α2+α3X+α4L+ϵ2,ϵ2 N(0,σ22)K=α2+α3X+α4L+ϵ2,ϵ2 N(0,σ22)[REMOVEME2] K = \alpha_2 + \alpha_3 \cdot X + \alpha_4 \cdot L + \epsilon_2, \epsilon_2 \sim~ N(0,\sigma_2^2)K = \alpha2 + \alpha3*X + \alpha4*L + \epsilon2, \epsilon2 ~ N(0,\sigma2^2) [REMOVE_ME_2]

[REMOVE_ME]Y=α5+α6K+αXYX+ϵ3,ϵ3N(0,σ32)Y=α5+α6K+\alphaXYX+ϵ3,ϵ3 N(0,σ32)[REMOVEME2] Y = \alpha_5 + \alpha_6 \cdot K + \alpha_{XY} \cdot X + \epsilon_3, \epsilon_3 \sim N(0,\sigma_3^2)Y = \alpha5 + \alpha6*K + \alphaXY*X + \epsilon3, \epsilon3 ~ N(0,\sigma3^2) [REMOVE_ME_2]

in order to obtain point and standard error estimates of the parameters α1,α3,α4,α6,\alphaXY\alpha1, \alpha3, \alpha4, \alpha6, \alphaXY

for the GLM setting. See the vignette for more details.

sem_appl(Y = NULL, X = NULL, K = NULL, L = NULL)

Arguments

  • Y: Numeric input vector for the primary outcome.
  • X: Numeric input vector for the exposure variable.
  • K: Numeric input vector for the intermediate outcome.
  • L: Numeric input vector for the observed confounding factor.

Returns

Returns a list with point estimates of the parameters (point_estimates), standard error estimates (SE_estimates) and p-values from large-sample Wald-type tests (pvalues).

Description

Function which uses the sem function in the lavaan package to fit the model

L=α0+α1X+ϵ1,ϵ1N(0,σ12)L=α0+α1X+ϵ1,ϵ1 N(0,σ12) L = \alpha_0 + \alpha_1 \cdot X + \epsilon_1, \epsilon_1 \sim N(0,\sigma_1^2)L = \alpha0 + \alpha1*X + \epsilon1, \epsilon1 ~ N(0,\sigma1^2) K=α2+α3X+α4L+ϵ2,ϵ2 N(0,σ22)K=α2+α3X+α4L+ϵ2,ϵ2 N(0,σ22) K = \alpha_2 + \alpha_3 \cdot X + \alpha_4 \cdot L + \epsilon_2, \epsilon_2 \sim~ N(0,\sigma_2^2)K = \alpha2 + \alpha3*X + \alpha4*L + \epsilon2, \epsilon2 ~ N(0,\sigma2^2) Y=α5+α6K+αXYX+ϵ3,ϵ3N(0,σ32)Y=α5+α6K+\alphaXYX+ϵ3,ϵ3 N(0,σ32) Y = \alpha_5 + \alpha_6 \cdot K + \alpha_{XY} \cdot X + \epsilon_3, \epsilon_3 \sim N(0,\sigma_3^2)Y = \alpha5 + \alpha6*K + \alphaXY*X + \epsilon3, \epsilon3 ~ N(0,\sigma3^2)

in order to obtain point and standard error estimates of the parameters α1,α3,α4,α6,\alphaXY\alpha1, \alpha3, \alpha4, \alpha6, \alphaXY

for the GLM setting. See the vignette for more details.

Examples

dat <- generate_data(setting = "GLM") sem_appl(Y = dat$Y, X = dat$X, K = dat$K, L = dat$L)
  • Maintainer: Stefan Konigorski
  • License: GPL-2
  • Last published: 2018-03-19

Useful links