CFA Error Lavaan Help

84 views
Skip to first unread message

Anna Celine Guilas

unread,
Feb 29, 2024, 11:41:16 PM2/29/24
to lavaan
Hello! I am getting this error on my CFA analysis and not getting any outputs for standard error and P(>|z|):

Warning:

lavaan WARNING: some observed variances are (at least) a factor 1000 times larger than others; use varTable(fit) to investigateWarning: lavaan WARNING:
Could not compute standard errors! The information matrix could not be inverted. This may be a symptom that the model is not
identified.Warning: lavaan WARNING: some estimated ov variances are negative

Can someone explain this? Here is my code:

# Standardizing variables
df2_EFA_scaled <- as.data.frame(scale(df2_EFA))


#define your model
CFA_model <- '
  Physicallimitations =~ BikeRidingAbilityNumeric +Q9_2 +Q9_1 + Q9_4
  Attitudes =~ BikingComfortLevelNumeric + ParkingPermitUseNumericQ23 + Q3_numeric + Q18_numeric
  Commutingexperience =~ Transportation_Numeric + Q14_numeric + Q11_19
  Convenience =~ Q8_numeric + sum_Q13 + Q4_numeric
  Travelpreferences =~ Q26_6 + Q26_5 +Q26_2 + Q26_7 + Q26_3 + Q26_4
'
```


```{r}
#fit the model

fit <- cfa(model=CFA_model, data=df2_EFA)
```

```{r}
#summarizing the results

summary(fit, fit.measures = TRUE)


Shu Fai Cheung (張樹輝)

unread,
Mar 1, 2024, 12:56:05 AM3/1/24
to lavaan
As suggested by the warning message, use varTable(fit) to inspect the data. You may want to make one or more variables smaller (e.g., by dividing it by a constant) to address the computation problem.

Please find below an illustration. The model in the cfa() example can produce the same two warnings if x1 is multiplied by 1000:

``` r
library(lavaan)
#> This is lavaan 0.6-17
#> lavaan is FREE software! Please report any bugs.

# Original data
HS.model <- ' visual  =~ x1 + x2 + x3
              textual =~ x4 + x5 + x6
              speed   =~ x7 + x8 + x9 '
HolzingerSwineford1939$x1 <- HolzingerSwineford1939$x1
fit <- cfa(HS.model, data = HolzingerSwineford1939)

# Multiply x1 by 1000
HolzingerSwineford1939$x1 <- HolzingerSwineford1939$x1 * 1000
fit <- cfa(HS.model, data = HolzingerSwineford1939)
#> Warning in lav_data_full(data = data, group = group, cluster = cluster, :
#> lavaan WARNING: some observed variances are (at least) a factor 1000 times
#> larger than others; use varTable(fit) to investigate
#> Warning in lav_data_full(data = data, group = group, cluster = cluster, : lavaan WARNING: some observed variances are larger than 1000000
#>   lavaan NOTE: use varTable(fit) to investigate
#> Warning 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
#>     identified.
varTable(fit)
#>   name idx nobs    type exo user     mean         var nlev lnam
#> 1   x1   7  301 numeric   0    0 4935.770 1362897.745    0    
#> 2   x2   8  301 numeric   0    0    6.088       1.386    0    
#> 3   x3   9  301 numeric   0    0    2.250       1.279    0    
#> 4   x4  10  301 numeric   0    0    3.061       1.355    0    
#> 5   x5  11  301 numeric   0    0    4.341       1.665    0    
#> 6   x6  12  301 numeric   0    0    2.186       1.200    0    
#> 7   x7  13  301 numeric   0    0    4.186       1.187    0    
#> 8   x8  14  301 numeric   0    0    5.527       1.025    0    
#> 9   x9  15  301 numeric   0    0    5.374       1.018    0
```

<sup>Created on 2024-03-01 with [reprex v2.1.0](https://reprex.tidyverse.org)</sup>

Hope this helps.

-- Shu Fai
Reply all
Reply to author
Forward
0 new messages