Dear Dr. Patrick
Thank you so much for responding. I will try to explain the problem so that it may help in understanding the issue.
I am trying to look at Information and Communication Technology (ICT) like: (mobile phone, computer tv etc.) and its impact on some farming outcomes.
Now considering that I run a SEM or say CFA
I have the following construct for the measurement model where i am say constructing two latent variables
ICT_access = ownership_tv +
ownership_smartphone+
ownership_computer
ICT_capability = able_to_read_and_open_sms + use_mobile_banking+ use_online_phone_apps
Now each of these indicator/observed variables are binary in the form of yes(coded as 1) and no(coded as 0). So prior to running the SEM/CFA command, I directed R to consider each of the indicator variable as a factor using the following way
f_tv <- factor(tv, levels = c("0", "1"), ordered = TRUE)
levels(f_tv)
OR
f_tv1 <- tv
as.factor(f_tv1)
and then plugged in the factors into the CFA command
cfa1 <- 'ICT_access =~ 1*f_tv +
f_smartphone+ f_computer
ICT_capability =~ 1*f_ open _and_read_sms + f_mobile_banking+ f_online_phone_apps'
fit1 <- cfa(cfa1, data = eth)
summary(fit1, fit.measures=TRUE)
now I am getting the following error
Error in lavaan::lavaan(model = cfa1, data = eth, model.type = "cfa", :
lavaan ERROR: missing observed variables in dataset: f_tv f_smart_phone f_computer f_open_read_sms f_mobile_banking
f_online_phone_apps
(NOTE: there are no missing values in these indicator variables)
The similar error is happening with the ordered argument when I use the following command instead:
fit1 <- cfa(cfa1, data = eth, ordered = c("
ICT_access
", "
ICT_capability
"))
summary(fit1, fit.measures=TRUE)
Error in lav_data_full(data = data, group = group, cluster = cluster, :
lavaan ERROR: missing observed variables in dataset: f_tv f_smart_phone f_computer f_open_read_sms f_mobile_banking f_online_phone_apps
In addition: Warning message:
In lavaan::lavaan(model = sem1, data = eth, ordered = c("ict_access", :
lavaan WARNING: ordered variable(s): ICT_access ICT_capability
could not be found in the data and will be ignored
Now if I do not to declare the indicator variable as factor and simply run the CFA considering the indicator variable as numeric
cfa1 <- 'ict_access =~ 1*tv + smart_phone + computer
+ ict_cap =~ 1*open_read_sms + online_app + mobile_banking'
>
> fit2 <- cfa(cfa1, data = eth)
I am getting the following warning message:
Warning message:
In lav_object_post_check(object) :
lavaan WARNING: covariance matrix of latent variables
is not positive definite;
use lavInspect(fit, "cov.lv") to investigate.
but the model is running as followed:
> summary(fit2, fit.measures = TRUE)
lavaan 0.6-6 ended normally after 113 iterations
Estimator ML
Optimization method NLMINB
Number of free parameters 17
Number of observations 463
Model Test User Model:
Test statistic 308.643
Degrees of freedom 19
P-value (Chi-square) 0.000
Model Test Baseline Model:
Test statistic 882.042
Degrees of freedom 28
P-value 0.000
User Model versus Baseline Model:
Comparative Fit Index (CFI) 0.661
Tucker-Lewis Index (TLI) 0.500
Loglikelihood and Information Criteria:
Loglikelihood user model (H0) -1210.913
Loglikelihood unrestricted model (H1) -1056.591
Akaike (AIC) 2455.826
Bayesian (BIC) 2526.168
Sample-size adjusted Bayesian (BIC) 2472.214
Root Mean Square Error of Approximation:
RMSEA 0.181
90 Percent confidence interval - lower 0.164
90 Percent confidence interval - upper 0.200
P-value RMSEA <= 0.05 0.000
Standardized Root Mean Square Residual:
SRMR 0.103
Parameter Estimates:
Standard errors Standard
Information Expected
Information saturated (h1) model Structured
Latent Variables:
Estimate Std.Err z-value P(>|z|)
ICT_access =~
tv2017 1.000
smart_phon2017 8.272 3.879 2.133 0.033
cmptr_w___2017 2.198 1.105 1.988 0.047
ICT_capability =~
opn_rd_sms2017 1.000
online_app2017 3.655 0.616 5.931 0.000
mobl_bnkng2017 0.967 0.194 4.973 0.000
use_atm2017 2.352 0.439 5.354 0.000
us_dbtc___2017 1.098 0.218 5.033 0.000
Covariances:
Estimate Std.Err z-value P(>|z|)
ICT_access ~~
ICT_capability 0.004 0.002 2.005 0.045
Variances:
Estimate Std.Err z-value P(>|z|)
.tv2017 0.147 0.010 15.185 0.000
.smart_phon2017 0.079 0.019 4.177 0.000
.cmptr_w___2017 0.119 0.008 14.992 0.000
.opn_rd_sms2017 0.104 0.007 14.912 0.000
.online_app2017 0.064 0.009 7.383 0.000
.mobl_bnkng2017 0.051 0.003 14.633 0.000
.use_atm2017 0.180 0.013 14.228 0.000
.us_dbtc___2017 0.061 0.004 14.588 0.000
ICT_access 0.002 0.002 1.068 0.286
ICT_capability 0.010 0.003 3.013 0.003
I am not able to understand these error and warning messages. As I mentioned earlier, the data collected for the observed variable is in binary form (yes/no = 1/0) and therefore the ML method for CFA/SEM is not feasible neacuse data is not continuous. Now I am not able to figure out how to proceed further.
Any help in this direction will be much appreciated.
Kind regards
Priya Chetri
Doctoral Candidate
School of Public Policy
Indian Institute of Technology Delhi
Hauz Khas, New Delhi-110016