I am trying to estimate a simple CFA and get a warning ("all observed variables are exogenous") and an error ("cov(X[[g]], use = "pairwise") : 'x' is empty), neither of which I understand.
Below the code I am using - I would be very grateful for any pointers in the right direction (my actual model has more factors and indicators, but the messages stay the same).
``` r
cfa_model <- ("
PolSup := DivPol1 + DivPol2 + DivPol3 + DivPol4
DivValI := DivValInstr1 + DivValInstr2R + DivValInstr3
")
cfa_dat <- tibble::tribble(
~DivPol1, ~DivPol2, ~DivPol3, ~DivPol4, ~DivValInstr1, ~DivValInstr2R, ~DivValInstr3, ~DivValInstr4,
2, 2, 4, 5, 4, 4, 4, 4,
6, 6, 6, 7, 6, 2, 5, 6,
5, 5, 4, 4, 7, 3, 4, 7,
7, 7, 7, 4, 3, 4, 4, 4,
2, 2, 3, 4, 5, 4, 2, 4,
4, 4, 4, 5, 2, 7, 1, 1,
6, 7, 5, 5, 7, 5, 7, 6,
5, 4, 7, 4, 6, 5, 7, 6,
5, 5, 7, 5, 6, 2, 4, 6,
5, 7, 6, 7, 1, 6, 4, 4,
4, 4, 4, 4, 4, 1, 5, 5,
5, 4, 7, 3, 6, 2, 5, 6,
4, 7, 7, 4, 4, 4, 4, 7,
4, 4, 4, 5, 4, 1, 5, 7,
6, 6, 4, 6, 6, 6, 6, 6
)
require(lavaan)
#> Loading required package: lavaan
#> This is lavaan 0.6-5
#> lavaan is BETA software! Please report any bugs.
fit <- cfa(cfa_model, data = cfa_dat)
#> Warning in lav_data_full(data = data, group = group, cluster = cluster, : lavaan
#> WARNING: all observed variables are exogenous; model may not be identified
#> Error in stats::cov(X[[g]], use = "pairwise"): 'x' is empty
```