I initially sent the message below to Yves, and he suggested I post it in the discussion group.
Using lavaan, I am reproducing SEM results produced through Mplus. The model has a single latent outcome variable predicted by a series of latent and manifest (primarily demographic) variables in a cross-sectional dataset. It appears that the primary difference between the models is that by default Mplus treats manifest exogenous variables as random variables and the syntax I’ve used in lavaan treats them as fixed variables. I am wondering what the implications of that modeling decision are. I’d be interested in feedback on the ideas behind lavaan/Mplus defaulting to fixed or random manifest exogenous variables and what an analyst should consider when deciding how to model manifest exogenous variables. Thank you!
Yves response included this: "The advantage of treating exogenous covariates as fixed is that we do not need to assume normality for them. Therefore, they can be binary variables (ie dummy variables), just like in regression. In addition, you need less 'free' parameters, as we do not estimate the (co)variances of those covariates.
The disadvantage is that you cannot handle missing values in those 'fixed' covariates."
I'd be interested in any additional thoughts the community might have.
library(lavaan)
#> This is lavaan 0.6-15
#> lavaan is FREE software! Please report any bugs.
set.seed(857105)
100
n <- .11
b1 <- .60
b2 <- .40
rho <- rnorm(n)
x1 <- rho * x1 + rnorm(n, 0, sqrt(1 - rho^2))
x2 <- sqrt(1 - (b1^2 + b2^2))
sd_e <- b1 * x1 + b2 * x2 + rnorm(n, 0, sd_e)
y <- rnorm(n)
y2 <- 2 * x1 + 10
x1 <- 3 * x2 + 20
x2 <- 40 + y
y <- data.frame(x1, x2, y)
dat <-head(dat)
#> x1 x2 y
#> 1 9.724924 21.03961 40.58337
#> 2 10.639568 20.36350 41.27968
#> 3 8.683245 20.94754 40.10021
#> 4 14.726216 26.91184 41.56065
#> 5 11.179734 16.45349 40.21687
#> 6 8.124515 22.32706 39.50138
mod <- "y ~ x1 + x2"
sem(mod, dat, fixed.x = TRUE)
fit_fixedx_true <- sem(mod, dat, fixed.x = FALSE)
fit_fixedx_false <-parameterEstimates(fit_fixedx_true)
#> lhs op rhs est se z pvalue ci.lower ci.upper
#> 1 y ~ x1 0.099 0.051 1.917 0.055 -0.002 0.199
#> 2 y ~ x2 0.188 0.034 5.557 0.000 0.122 0.254
#> 3 y ~~ y 0.814 0.115 7.071 0.000 0.588 1.040
#> 4 x1 ~~ x1 4.320 0.000 NA NA 4.320 4.320
#> 5 x1 ~~ x2 3.520 0.000 NA NA 3.520 3.520
#> 6 x2 ~~ x2 9.986 0.000 NA NA 9.986 9.986
parameterEstimates(fit_fixedx_false)
#> lhs op rhs est se z pvalue ci.lower ci.upper
#> 1 y ~ x1 0.099 0.051 1.917 0.055 -0.002 0.199
#> 2 y ~ x2 0.188 0.034 5.557 0.000 0.122 0.254
#> 3 y ~~ y 0.814 0.115 7.071 0.000 0.588 1.040
#> 4 x1 ~~ x1 4.320 0.611 7.071 0.000 3.122 5.517
#> 5 x1 ~~ x2 3.520 0.745 4.724 0.000 2.059 4.980
#> 6 x2 ~~ x2 9.986 1.412 7.071 0.000 7.218 12.754
standardizedSolution(fit_fixedx_true)
#> lhs op rhs est.std se z pvalue ci.lower ci.upper
#> 1 y ~ x1 0.177 0.091 1.946 0.052 -0.001 0.355
#> 2 y ~ x2 0.513 0.080 6.395 0.000 0.356 0.670
#> 3 y ~~ y 0.608 0.068 8.905 0.000 0.474 0.742
#> 4 x1 ~~ x1 1.000 0.000 NA NA 1.000 1.000
#> 5 x1 ~~ x2 0.536 0.000 NA NA 0.536 0.536
#> 6 x2 ~~ x2 1.000 0.000 NA NA 1.000 1.000
standardizedSolution(fit_fixedx_false)
#> lhs op rhs est.std se z pvalue ci.lower ci.upper
#> 1 y ~ x1 0.177 0.092 1.932 0.053 -0.003 0.357
#> 2 y ~ x2 0.513 0.084 6.140 0.000 0.349 0.677
#> 3 y ~~ y 0.608 0.076 7.985 0.000 0.459 0.757
#> 4 x1 ~~ x1 1.000 0.000 NA NA 1.000 1.000
#> 5 x1 ~~ x2 0.536 0.071 7.519 0.000 0.396 0.676
#> 6 x2 ~~ x2 1.000 0.000 NA NA 1.000 1.000
--
You received this message because you are subscribed to the Google Groups "lavaan" group.
To unsubscribe from this group and stop receiving emails from it, send an email to lavaan+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/lavaan/0435a25a-7ca2-49e2-b182-695a7d359c10n%40googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/lavaan/CAPVJd2VNkpSt0AxTLyAQTXt0n3GSJ7OECgc4NVCpHC2TuVH0mg%40mail.gmail.com.
set.seed(857105)
<- 100
n <- .11
b1 <- .60
b2 <- .40
rho <- rnorm(n)
x1 <- rho * x1 + rnorm(n, 0, sqrt(1 - rho^2))
x2
<- function(n, x1, x2) { gen_data
<- sqrt(1 - (b1^2 + b2^2))
sd_e <- b1 * x1 + b2 * x2 + rnorm(n, 0, sd_e)
y <- rnorm(n)
y2 <- 2 * x1 + 10
x1 <- 3 * x2 + 20
x2 <- 40 + y
y
data.frame(x1, x2, y)
}set.seed(415145)
head(gen_data(100, x1 = x1, x2 =x2))
#> x1 x2 y
#> 1 9.724924 21.03961 39.61278
#> 2 10.639568 20.36350 41.29758
#> 3 8.683245 20.94754 39.84185
#> 4 14.726216 26.91184 40.64332
#> 5 11.179734 16.45349 39.77236
#> 6 8.124515 22.32706 40.58855
head(gen_data(100, x1 = x1, x2 =x2))
#> x1 x2 y
#> 1 9.724924 21.03961 39.47348
#> 2 10.639568 20.36350 40.07889
#> 3 8.683245 20.94754 39.16790
#> 4 14.726216 26.91184 41.00427
#> 5 11.179734 16.45349 38.46486
#> 6 8.124515 22.32706 39.93895
head(gen_data(100, x1 = x1, x2 =x2))
#> x1 x2 y
#> 1 9.724924 21.03961 39.01510
#> 2 10.639568 20.36350 38.79520
#> 3 8.683245 20.94754 40.02613
#> 4 14.726216 26.91184 40.83357
#> 5 11.179734 16.45349 38.23792
#> 6 8.124515 22.32706 41.32508
To view this discussion on the web visit https://groups.google.com/d/msgid/lavaan/CAHxMgedfr%2BD%3DcoQ2SZ78Vo3jtSTvoK0gf6mO4KMPU3TFWSa2Mg%40mail.gmail.com.
mod <- "
fx =~ fx1 + fx2 + fx3
fy =~ fy1 + fy2 + fy3
fy ~ fx + x1
"
<- sem(mod, dat)
fit
fit#> lavaan 0.6.15 ended normally after 27 iterations
#> Estimator ML
#> Optimization method NLMINB
#> Number of model parameters 14
parameterEstimates(fit)
#> lhs op rhs est se z pvalue ci.lower ci.upper
#> 17 x1 ~~ x1 1.124 0.000 NA NA 1.124 1.124
You received this message because you are subscribed to a topic in the Google Groups "lavaan" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/lavaan/69H6ax6upMc/unsubscribe.
To unsubscribe from this group and all its topics, send an email to lavaan+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/lavaan/a43f392c-0988-44e0-99ab-cbc361bd043bn%40googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/lavaan/4245bbad-4279-4e14-abb5-8df77d7694e5n%40googlegroups.com.