Path analysis with binary endogenous variable

351 views
Skip to first unread message

Kris

unread,
Dec 15, 2022, 5:31:56 AM12/15/22
to lavaan

Hi!

I'm estimating a path model in lavaan with a mediating variable that is binary. I have both binary and continuous exogenous variables. I have more variables, but this is a simplified version of my syntax in lavaan:

path_model = '

ln_A ~ b1*ln_B + b2*ln_C + b3*D + b4*E + b5*F

D ~ b6*E + b7*F

# indirect effects

indirect_E := b3*b6

indirect_F := b3*b7

# total effects

total_E := b4 + (b3*b6)

total_F := b5 + (b3*b7)

# Fit the models

fit = sem(path_model, data = df, ordered = "D")

Everything looks fine when I estimate the model like this using the DWLS estimator. 

I wanted to add covariances between the exogenous variables, but I get an error message when I try to do it in R. It seems that it's because fixed.x = TRUE and conditional.x = TRUE. I tried changing to fixed.x = FALSE, but then I also have to change to conditional.x = FALSE. When I do this I get a negative variance, so I know that the estimation is incorrect. 

I'm new to statistics and lavaan, so I would highly appreciate help!


This is the error message that I get in R when I try to add covariances:

Warning messages:
1: In muthen1984(Data = X[[g]], wt = WT[[g]], ov.names = ov.names[[g]],  :
  lavaan WARNING: trouble constructing W matrix; used generalized inverse for A11 submatrix
2: In lav_model_vcov(lavmodel = lavmodel, lavsamplestats = lavsamplestats,  :
  lavaan WARNING:
    The variance-covariance matrix of the estimated parameters (vcov)
    does not appear to be positive definite! The smallest eigenvalue
    (= -1.422309e-18) is smaller than zero. This may be a symptom that
    the model is not identified.
3: In lav_object_post_check(object) :
  lavaan WARNING: some estimated ov variances are negative

Terrence Jorgensen

unread,
Dec 15, 2022, 6:48:03 AM12/15/22
to lavaan

I wanted to add covariances between the exogenous variables

They are already there.  By default, exogenous variables' summary statistics are taken as given, not estimated.  There is no need to estimate them because those variables are not explained within the model.  The assumption is that you do not have hypotheses about predictors, only about outcomes.  fixed.x=TRUE also allows you to avoid assuming normality of the predictors (one of yours is binary).

Terrence D. Jorgensen
Assistant Professor, Methods and Statistics
Research Institute for Child Development and Education, the University of Amsterdam

Yves Rosseel

unread,
Dec 30, 2022, 12:10:28 PM12/30/22
to lav...@googlegroups.com
On 12/15/22 11:31, Kris wrote:
> I wanted to add covariances between the exogenous variables

No need! When fixed.x = TRUE (or conditional.x = TRUE), this is done
automatically.

Adding this manually is possible (if you set fixed.x = FALSE), but care
is needed for binary variables, as in this case the mean is related to
the variance, and only one parameter can be estimated.

Yves.
Reply all
Reply to author
Forward
0 new messages