Linked Questions

Popular Questions

Why won't my lavaan model run, when it does run in AMOS?

Asked by At

I have been asked to transition from costly SPSS' AMOS to R to run structural equation models. We have a specific (and complicated) SEM model that I am trying to reproduce in R with the lavaan package. When running the model in AMOS, standard errors can be calculated, along with all other requested output. I have set likelihood to "wishart" to match the AMOS method. However, when I run what I think is the exact same model in R's lavaan, lavaan throws warnings (see below) and I get odd output. What am I missing or misspecifying in lavaan? Or, does lavaan have different thresholds or mechanisms than AMOS that I am not aware of?

Our model has three outcomes connected with an intentional feedback loop (i.e., is non-recursive). Two of those outcomes are single-item latents. The rest of the model contains 13 endogenous variables, quite a few of which are comprised of only two items. We do not set any covariances. We have known multicollinearity issues. Our data is non-normal (but has been tested in past and is accepted). We listwise-delete missing data. Despite all this, we are able to run the model in AMOS. Although we never achieve a non-significant p value, we do get decent fit statistics.

I went back to more basic models to see if I could at any point get both software to run a matching model. Up to a decent degree (included all but three endogenous variables), the lavaan software runs and the output matches that of AMOS and runs without any warnings.

lav_qs_for_latents <- '
  # latent variables
    ELM =~ Q7855_08S + Q7355_04S
    SLM =~ Q8227_06S + Q1266_06S + Q4234_06S + Q9806_15S + Q6979_13S
    SP  =~ Q8117_08S + Q8260_06S
    RE  =~ Q5074_04S + Q8641_13S + Q5704_13S + Q8511_04S
    PD  =~ Q3437_06S + Q9183_04S + Q9292_04S
    TM  =~ Q8179_04S + Q8355_04S + Q4882_06S
    TW  =~ Q4332_11S + Q5113_11S + Q7644_15S
    SW  =~ Q9958_04S + Q2928_06S
    PB  =~ Q1718_06S + Q2593_06S + Q8152_11S
    RC  =~ Q4636_08S + Q5601_06S
    JS  =~ Q5079_04S + Q1344_06S  
    EMP =~ Q8520_06S + Q8385_06S + Q3182_08S
    VMG =~ Q1782_04S + Q5178_04S
    COMMIT =~ Q3373_06S + Q6957_06S
  # regressions
    SLM ~ ELM
    SP ~ ELM + SLM
    RE ~ ELM + SLM + SP
    PD ~ ELM + SLM + SP + RE
    TM ~ SLM + RE
    TW ~ ELM + PD + TM
    SW ~ ELM + SLM + RE + PD + TW
    PB ~ ELM + SP + TW + SW
    RC ~ ELM + SLM + SP + RE + PD + SW + PB
    JS ~ ELM + SLM + PD + TM
    EMP ~ ELM + SLM + RE + PD + RC + JS
    VMG ~ ELM + PD + TM + TW
    Q2327_06S ~ SW + JS + EMP + COMMIT
    Q2958_06S ~ Q2327_06S + ELM + SW + PB + EMP + VMG
    COMMIT ~ Q2327_06S + Q2958_06S + TW + JS + PB + VMG
sem_qs_for_latents <- sem(model = lav_qs_for_latents, likelihood = "wishart", sample.cov = datacov, sample.nobs = data_N)

summary(sem_qs_for_latents, standardized=TRUE, rsquare=TRUE)

I expected the information matrix to be invertible and standard errors to be calculated. Instead, I got the following warnings:

Warning messages:
1: In lav_model_vcov(lavmodel = lavmodel, lavsamplestats = lavsamplestats,  :
  lavaan WARNING:
    Could not compute standard errors! The information matrix could
    not be inverted. This may be a symptom that the model is not

2: In lav_object_post_check(object) :
  lavaan WARNING: some estimated lv variances are negative

3: In lavaan::lavaan(model = lav_qs_for_latents, sample.cov = datacov,  :
  lavaan WARNING: not all elements of the gradient are (near) zero;
                  the optimizer may not have found a local solution;
                  use lavInspect(fit, "optim.gradient") to investigate

lavInspect(sem_qs_for_latents, "optim.gradient") gave me the value of 0.000 for all except the following:

TW~ELM = 0.005; TW~PD = 0.008; TW~TM = 0.002; JS~ELM = -0.002; JS~SLM = -0.002; JS~PD = -0.001; JS~TM = -0.001

I don't know how to upload my covariance matrix, but I don't think that is the problem as I can run more basic models in lavaan on that covariance matrix with output matching the corresponding AMOS models. My apologies if this is not an appropriate question. I have been stuck on this for weeks and don't know where to turn for help.

Related Questions