Hi to all.
I have a problem with a CFA in lavaan.
I have a 16 items questionnaire and 92 participants (not so good).
Data are ordinal (items with likert 0 to 4).
Item '9' has no variance: all participants replied '0' on the item (which refers, indeed, to a rather rare occurrence).
Since data were ordinal, I used estimator="DWLS".
However, the model did not converge: "Error in lav_data_full(data = data, group = group, cluster = cluster, :
lavaan ERROR: some variables have no values (only missings) or no variance".
Is there anything I can do?
Some imputation as in meta-analysis for studies with zero cases, or in penalized regression?
Thank you in advance for your attention.
Antonello
### example of data and codes
dat <- structure(list(ls1 = c(1, 0, 0, 0, 0, 0, 3, 0, 0, 2, 0, 0, 0,
1, 0, 3, 2, 0, 0, 1, 1, 1, 2, 2, 0, 0, 0, 0, 3, 0, 0, 2, 1, 1,
1, 0, 0, 0, 1, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 1,
0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 1, 3, 0, 0, 3, 2, 0, 0, 0, 0,
0, 0, 1, 0, 0, 2, 0, 1, 1, 0, 2, 0, 0, 0, 0, 0), ls2 = c(1, 1,
1, 0, 0, 0, 1, 0, 0, 2, 0, 0, 0, 3, 0, 2, 1, 0, 1, 1, 0, 0, 1,
0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 2, 0, 0, 0, 1, 3, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 3, 0, 0, 3,
0, 0, 0, 0, 0, 3, 1, 0, 1, 2, 0, 0, 0, 0, 1, 0, 3, 0, 0, 1, 0,
2, 0, 0, 0, 0, 1), ls3 = c(3, 4, 3, 2, 4, 1, 0, 1, 0, 3, 3, 3,
1, 1, 0, 3, 2, 3, 1, 0, 3, 1, 2, 0, 4, 3, 0, 1, 3, 4, 3, 3, 3,
3, 0, 4, 0, 0, 3, 0, 3, 0, 3, 3, 1, 0, 0, 2, 3, 3, 2, 2, 1, 1,
3, 3, 3, 3, 3, 3, 2,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 0, 0, 0, 0, 0, 0, 3, 0, 0, 1, 0, 0, 0,
2, 3, 1, 0, 0, 0, 0, 1, 4, 0, 0, 1, 0, 2, 0, 1, 1, 0, 0, 0, 0,
0, 0, 2, 0, 0, 0, 0), ls15 = c(0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 2, 0, 0, 1, 0, 1, 0, 0, 2, 0, 0, 0, 0, 0, 0, 3,
1, 2, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 3, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0,
0, 0, 0, 0, 2, 0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0), ls16 = c(0,
1, 0, 3, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 2, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 4, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2,
0, 0, 0, 0, 0, 0, 0)), .Names = c("ls1", "ls2", "ls3", "ls4",
"ls5", "ls6", "ls7", "ls8", "ls9", "ls10", "ls11", "ls12", "ls13",
"ls14", "ls15", "ls16"), class = "data.frame", row.names = 3883:3974)
### check data
dim(dat); head(dat)
#############################################
### CFA
#############################################
### call the library
library(lavaan)
library(semTools)
#############################################
### modello a 4 fattori correlati
#############################################
Model4<- 'intrusive=~ls1+ls2+ls3
vivid=~ls5+ls6+ls7
audiovisual=~ls4+ls8+ls9+ls10+ls16
multisensory=~ls11+ls12+ls13+ls14+ls15'
fit <- cfa(Model4, data=dat, estimator="DWLS")
summary(fit, fit.measures=TRUE, standardized=TRUE)
reliability(fit)
### sessionInfo()
R version 3.4.1 (2017-06-30)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 7 x64 (build 7601) Service Pack 1
Matrix products: default
locale:
[1] LC_COLLATE=Italian_Italy.1252 LC_CTYPE=Italian_Italy.1252 LC_MONETARY=Italian_Italy.1252 LC_NUMERIC=C
[5] LC_TIME=Italian_Italy.1252
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] semTools_0.4-14 lavaan_0.5-23.1097
loaded via a namespace (and not attached):
[1] compiler_3.4.1 mnormt_1.5-5 pbivnorm_0.6.0 stats4_3.4.1 quadprog_1.5-5