Structural equation modeling approach
Function which uses the sem
function in the lavaan
package to fit the model [REMOVE_ME]L=α0+α1⋅X+ϵ1,ϵ1∼N(0,σ12)L=α0+α1∗X+ϵ1,ϵ1 N(0,σ12)[REMOVEME2]
[REMOVE_ME]K=α2+α3⋅X+α4⋅L+ϵ2,ϵ2∼ N(0,σ22)K=α2+α3∗X+α4∗L+ϵ2,ϵ2 N(0,σ22)[REMOVEME2]
[REMOVE_ME]Y=α5+α6⋅K+αXY⋅X+ϵ3,ϵ3∼N(0,σ32)Y=α5+α6∗K+\alphaXY∗X+ϵ3,ϵ3 N(0,σ32)[REMOVEME2]
in order to obtain point and standard error estimates of the parameters α1,α3,α4,α6,\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+α1⋅X+ϵ1,ϵ1∼N(0,σ12)L=α0+α1∗X+ϵ1,ϵ1 N(0,σ12)
K=α2+α3⋅X+α4⋅L+ϵ2,ϵ2∼ N(0,σ22)K=α2+α3∗X+α4∗L+ϵ2,ϵ2 N(0,σ22)
Y=α5+α6⋅K+αXY⋅X+ϵ3,ϵ3∼N(0,σ32)Y=α5+α6∗K+\alphaXY∗X+ϵ3,ϵ3 N(0,σ32)
in order to obtain point and standard error estimates of the parameters α1,α3,α4,α6,\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)