library(psych)
library(tidyverse)
## ── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ──
## ✔ dplyr 1.1.4 ✔ readr 2.1.5
## ✔ forcats 1.0.0 ✔ stringr 1.5.2
## ✔ ggplot2 4.0.0 ✔ tibble 3.3.0
## ✔ lubridate 1.9.4 ✔ tidyr 1.3.1
## ✔ purrr 1.1.0
## ── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
## ✖ ggplot2::%+%() masks psych::%+%()
## ✖ ggplot2::alpha() masks psych::alpha()
## ✖ dplyr::filter() masks stats::filter()
## ✖ dplyr::lag() masks stats::lag()
## ℹ Use the conflicted package (<http://conflicted.r-lib.org/>) to force all conflicts to become errors
library(ggplot2)
library(lavaan)
## This is lavaan 0.6-20
## lavaan is FREE software! Please report any bugs.
##
## Attaching package: 'lavaan'
##
## The following object is masked from 'package:psych':
##
## cor2cov
library(stats)
library(lavaanPlot)
## Warning: package 'lavaanPlot' was built under R version 4.5.2
region_revd_educ <- read.csv("251120_region_educ.csv", header = TRUE)
table(region_revd_educ$region)
##
## 1 2 3 4 5 6
## 4260 803 1503 788 1789 1166
Monrovia <- region_revd_educ %>%
filter(region == "1")
`
mean(Monrovia$wi_continuous)
## [1] 159328.6
Northwest<- region_revd_educ %>%
filter(region == "2")
mean(Northwest$wi_continuous)
## [1] -16697.58
So_Central <- region_revd_educ %>%
filter(region == "3")
mean(So_Central$wi_continuous)
## [1] 90770.46
So_Easta <- region_revd_educ %>%
filter(region == "4")
mean(So_Easta$wi_continuous)
## [1] 1185.193
So_Eastb <- region_revd_educ %>%
filter(region == "5")
mean(So_Eastb$wi_continuous)
## [1] 17560.73
No_Central <- region_revd_educ %>%
filter(region == "6")
mean(No_Central$wi_continuous)
## [1] 50960.07
mean(region_revd_educ$wi_continuous)
## [1] 86674.66
#Run the cfa model with the full dataset.
pov.model <- '
health =~ h2o_source + share_toilet
educ =~ p1_educ + p2_educ
wealth =~ radio + watch + car_truck + cell_phone + computer + sewing_machine
health ~~ educ
wealth ~ health
wealth ~ educ'
fit <- cfa(pov.model, std.lv = TRUE, ordered = c("share_toilet", "radio", "watch", "car_truck", "cell_phone", "computer", "sewing_machine"), data = region_revd_educ)
## Warning: lavaan->lav_object_post_check():
## some estimated ov variances are negative
summary(fit, fit.measures = TRUE, standardized = TRUE)
## lavaan 0.6-20 ended normally after 49 iterations
##
## Estimator DWLS
## Optimization method NLMINB
## Number of model parameters 26
##
## Number of observations 10309
##
## Model Test User Model:
## Standard Scaled
## Test Statistic 179.919 214.709
## Degrees of freedom 32 32
## P-value (Chi-square) 0.000 0.000
## Scaling correction factor 0.847
## Shift parameter 2.306
## simple second-order correction
##
## Model Test Baseline Model:
##
## Test statistic 18471.120 15649.402
## Degrees of freedom 45 45
## P-value 0.000 0.000
## Scaling correction factor 1.181
##
## User Model versus Baseline Model:
##
## Comparative Fit Index (CFI) 0.992 0.988
## Tucker-Lewis Index (TLI) 0.989 0.984
##
## Robust Comparative Fit Index (CFI) NA
## Robust Tucker-Lewis Index (TLI) NA
##
## Root Mean Square Error of Approximation:
##
## RMSEA 0.021 0.024
## 90 Percent confidence interval - lower 0.018 0.021
## 90 Percent confidence interval - upper 0.024 0.027
## P-value H_0: RMSEA <= 0.050 1.000 1.000
## P-value H_0: RMSEA >= 0.080 0.000 0.000
##
## Robust RMSEA NA
## 90 Percent confidence interval - lower NA
## 90 Percent confidence interval - upper NA
## P-value H_0: Robust RMSEA <= 0.050 NA
## P-value H_0: Robust RMSEA >= 0.080 NA
##
## Standardized Root Mean Square Residual:
##
## SRMR 0.043 0.043
##
## Parameter Estimates:
##
## Parameterization Delta
## Standard errors Robust.sem
## Information Expected
## Information saturated (h1) model Unstructured
##
## Latent Variables:
## Estimate Std.Err z-value P(>|z|) Std.lv Std.all
## health =~
## h2o_source 1.307 0.172 7.601 0.000 1.307 0.106
## share_toilet -1.072 0.103 -10.369 0.000 -1.072 -1.072
## educ =~
## p1_educ 1.665 0.088 18.874 0.000 1.665 1.078
## p2_educ -0.846 0.048 -17.733 0.000 -0.846 -0.417
## wealth =~
## radio 0.609 0.022 28.289 0.000 0.726 0.726
## watch 0.620 0.021 28.873 0.000 0.739 0.739
## car_truck 0.695 0.027 26.081 0.000 0.828 0.828
## cell_phone 0.710 0.024 29.423 0.000 0.847 0.847
## computer 0.716 0.031 23.382 0.000 0.853 0.853
## sewing_machine 0.426 0.023 18.454 0.000 0.508 0.508
##
## Regressions:
## Estimate Std.Err z-value P(>|z|) Std.lv Std.all
## wealth ~
## health 0.574 0.076 7.526 0.000 0.482 0.482
## educ 0.228 0.021 11.055 0.000 0.191 0.191
##
## Covariances:
## Estimate Std.Err z-value P(>|z|) Std.lv Std.all
## health ~~
## educ 0.154 0.020 7.789 0.000 0.154 0.154
##
## Intercepts:
## Estimate Std.Err z-value P(>|z|) Std.lv Std.all
## .h2o_source 75.135 0.177 424.365 0.000 75.135 6.095
## .p1_educ 1.708 0.018 93.850 0.000 1.708 1.106
## .p2_educ 2.731 0.040 69.086 0.000 2.731 1.346
##
## Thresholds:
## Estimate Std.Err z-value P(>|z|) Std.lv Std.all
## share_toilt|t1 -0.430 0.013 -33.659 0.000 -0.430 -0.430
## radio|t1 -0.640 0.013 -48.061 0.000 -0.640 -0.640
## watch|t1 -0.324 0.013 -25.729 0.000 -0.324 -0.324
## car_truck|t1 1.640 0.021 79.051 0.000 1.640 1.640
## cell_phone|t1 -0.135 0.012 -10.899 0.000 -0.135 -0.135
## computer|t1 1.953 0.026 74.654 0.000 1.953 1.953
## sewing_mchn|t1 1.643 0.021 79.034 0.000 1.643 1.643
##
## Variances:
## Estimate Std.Err z-value P(>|z|) Std.lv Std.all
## .h2o_source 150.247 1.202 124.995 0.000 150.247 0.989
## .share_toilet -0.150 -0.150 -0.150
## .p1_educ -0.387 0.274 -1.413 0.158 -0.387 -0.162
## .p2_educ 3.399 0.137 24.751 0.000 3.399 0.826
## .radio 0.473 0.473 0.473
## .watch 0.454 0.454 0.454
## .car_truck 0.314 0.314 0.314
## .cell_phone 0.283 0.283 0.283
## .computer 0.272 0.272 0.272
## .sewing_machine 0.742 0.742 0.742
## health 1.000 1.000 1.000
## educ 1.000 1.000 1.000
## .wealth 1.000 0.703 0.703
# This code did not run. Uncomment it to see the errors.
#res <- resid(fit, type = "standardized")
#res
#Error: lavaan->lav_residuals_se():
#not ready yet!
lavaanPlot(model = fit, node_options = list(shape = "box", fontname = "Helvetica"), edge_options = list(color = "grey"), coefs = TRUE, stars = "latent")
### Run the cfa model for Monrovia
pov.model.monroe <- '
health =~ h2o_source + share_toilet
educ =~ p1_educ + p2_educ
wealth =~ radio + watch + car_truck+ cell_phone + computer + sewing_machine
health ~~ educ
wealth ~ health
wealth ~ educ'
fit <- cfa(pov.model.monroe, std.lv = TRUE, ordered = c("share_toilet", "radio", "watch", "car_truck", "cell_phone", "computer", "sewing_machine"), data = Monrovia)
## Warning: lavaan->lav_object_post_check():
## some estimated ov variances are negative
summary(fit, fit.measures = TRUE, standardized = TRUE)
## lavaan 0.6-20 ended normally after 48 iterations
##
## Estimator DWLS
## Optimization method NLMINB
## Number of model parameters 26
##
## Number of observations 4260
##
## Model Test User Model:
## Standard Scaled
## Test Statistic 111.555 130.287
## Degrees of freedom 32 32
## P-value (Chi-square) 0.000 0.000
## Scaling correction factor 0.872
## Shift parameter 2.314
## simple second-order correction
##
## Model Test Baseline Model:
##
## Test statistic 5925.709 5086.726
## Degrees of freedom 45 45
## P-value 0.000 0.000
## Scaling correction factor 1.166
##
## User Model versus Baseline Model:
##
## Comparative Fit Index (CFI) 0.986 0.981
## Tucker-Lewis Index (TLI) 0.981 0.973
##
## Robust Comparative Fit Index (CFI) NA
## Robust Tucker-Lewis Index (TLI) NA
##
## Root Mean Square Error of Approximation:
##
## RMSEA 0.024 0.027
## 90 Percent confidence interval - lower 0.019 0.022
## 90 Percent confidence interval - upper 0.029 0.032
## P-value H_0: RMSEA <= 0.050 1.000 1.000
## P-value H_0: RMSEA >= 0.080 0.000 0.000
##
## Robust RMSEA NA
## 90 Percent confidence interval - lower NA
## 90 Percent confidence interval - upper NA
## P-value H_0: Robust RMSEA <= 0.050 NA
## P-value H_0: Robust RMSEA >= 0.080 NA
##
## Standardized Root Mean Square Residual:
##
## SRMR 0.049 0.049
##
## Parameter Estimates:
##
## Parameterization Delta
## Standard errors Robust.sem
## Information Expected
## Information saturated (h1) model Unstructured
##
## Latent Variables:
## Estimate Std.Err z-value P(>|z|) Std.lv Std.all
## health =~
## h2o_source 1.690 0.397 4.255 0.000 1.690 0.098
## share_toilet -1.027 0.167 -6.134 0.000 -1.027 -1.027
## educ =~
## p1_educ 1.873 0.315 5.951 0.000 1.873 1.143
## p2_educ -0.533 0.091 -5.872 0.000 -0.533 -0.298
## wealth =~
## radio 0.551 0.041 13.415 0.000 0.661 0.661
## watch 0.607 0.044 13.797 0.000 0.728 0.728
## car_truck 0.733 0.055 13.264 0.000 0.879 0.879
## cell_phone 0.677 0.049 13.911 0.000 0.812 0.812
## computer 0.670 0.052 12.830 0.000 0.804 0.804
## sewing_machine 0.322 0.036 8.903 0.000 0.386 0.386
##
## Regressions:
## Estimate Std.Err z-value P(>|z|) Std.lv Std.all
## wealth ~
## health 0.638 0.153 4.169 0.000 0.532 0.532
## educ 0.117 0.035 3.339 0.001 0.097 0.097
##
## Covariances:
## Estimate Std.Err z-value P(>|z|) Std.lv Std.all
## health ~~
## educ 0.128 0.035 3.671 0.000 0.128 0.128
##
## Intercepts:
## Estimate Std.Err z-value P(>|z|) Std.lv Std.all
## .h2o_source 75.087 0.405 185.441 0.000 75.087 4.371
## .p1_educ 2.127 0.026 81.246 0.000 2.127 1.299
## .p2_educ 2.505 0.054 46.275 0.000 2.505 1.400
##
## Thresholds:
## Estimate Std.Err z-value P(>|z|) Std.lv Std.all
## share_toilt|t1 -0.133 0.019 -6.923 0.000 -0.133 -0.133
## radio|t1 -0.962 0.023 -42.168 0.000 -0.962 -0.962
## watch|t1 -0.672 0.021 -32.215 0.000 -0.672 -0.672
## car_truck|t1 1.340 0.027 49.641 0.000 1.340 1.340
## cell_phone|t1 -0.870 0.022 -39.364 0.000 -0.870 -0.870
## computer|t1 1.629 0.032 50.840 0.000 1.629 1.629
## sewing_mchn|t1 1.450 0.029 50.554 0.000 1.450 1.450
##
## Variances:
## Estimate Std.Err z-value P(>|z|) Std.lv Std.all
## .h2o_source 292.284 5.260 55.569 0.000 292.284 0.990
## .share_toilet -0.054 -0.054 -0.054
## .p1_educ -0.825 1.162 -0.709 0.478 -0.825 -0.307
## .p2_educ 2.918 0.152 19.183 0.000 2.918 0.911
## .radio 0.563 0.563 0.563
## .watch 0.470 0.470 0.470
## .car_truck 0.227 0.227 0.227
## .cell_phone 0.341 0.341 0.341
## .computer 0.353 0.353 0.353
## .sewing_machine 0.851 0.851 0.851
## health 1.000 1.000 1.000
## educ 1.000 1.000 1.000
## .wealth 1.000 0.695 0.695
lavaanPlot(model = fit, node_options = list(shape = "box", fontname = "Helvetica"), edge_options = list(color = "grey"), coefs = TRUE)
### Run the cfa model for So_Eastb. Computer removed b/c it had only 1 level.
pov.model.seb <- '
health =~ h2o_source + share_toilet
educ =~ p1_educ + p2_educ
wealth =~ radio + watch + car_truck + sewing_machine + cell_phone
health ~~ educ
wealth ~ health
wealth ~ educ'
fit <- cfa(pov.model.seb, std.lv = TRUE, ordered = c("share_toilet", "radio", "car_truck", "cell_phone", "watch", "sewing_machine"), data = So_Eastb)
## Warning: lavaan->lav_samplestats_step2():
## correlation between variables car_truck and share_toilet is (nearly) 1.0
## Warning: lavaan->lav_model_vcov():
## 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->lav_test_satorra_bentler():
## could not invert information matrix needed for robust test statistic
## Warning: lavaan->lav_object_post_check():
## some estimated ov variances are negative
summary(fit, fit.measures = TRUE, standardized = TRUE)
## lavaan 0.6-20 ended normally after 2324 iterations
##
## Estimator DWLS
## Optimization method NLMINB
## Number of model parameters 24
##
## Number of observations 1789
##
## Model Test User Model:
## Standard Scaled
## Test Statistic 146.506 NA
## Degrees of freedom 24 24
## P-value (Chi-square) 0.000 NA
## Scaling correction factor NA
## Shift parameter NA
##
##
## Model Test Baseline Model:
##
## Test statistic 2962.216 2195.213
## Degrees of freedom 36 36
## P-value 0.000 0.000
## Scaling correction factor 1.355
##
## User Model versus Baseline Model:
##
## Comparative Fit Index (CFI) 0.958 NA
## Tucker-Lewis Index (TLI) 0.937 NA
##
## Robust Comparative Fit Index (CFI) NA
## Robust Tucker-Lewis Index (TLI) NA
##
## Root Mean Square Error of Approximation:
##
## RMSEA 0.053 NA
## 90 Percent confidence interval - lower 0.045 NA
## 90 Percent confidence interval - upper 0.062 NA
## P-value H_0: RMSEA <= 0.050 0.236 NA
## P-value H_0: RMSEA >= 0.080 0.000 NA
##
## Robust RMSEA NA
## 90 Percent confidence interval - lower NA
## 90 Percent confidence interval - upper NA
## P-value H_0: Robust RMSEA <= 0.050 NA
## P-value H_0: Robust RMSEA >= 0.080 NA
##
## Standardized Root Mean Square Residual:
##
## SRMR 0.141 0.141
##
## Parameter Estimates:
##
## Parameterization Delta
## Standard errors Robust.sem
## Information Expected
## Information saturated (h1) model Unstructured
##
## Latent Variables:
## Estimate Std.Err z-value P(>|z|) Std.lv Std.all
## health =~
## h2o_source 0.712 NA 0.712 0.150
## share_toilet -0.428 NA -0.428 -0.428
## educ =~
## p1_educ 1.850 NA 1.850 1.354
## p2_educ -0.845 NA -0.845 -0.389
## wealth =~
## radio 0.002 NA 0.811 0.811
## watch 0.001 NA 0.751 0.751
## car_truck 0.001 NA 0.745 0.745
## sewing_machine 0.001 NA 0.699 0.699
## cell_phone 0.002 NA 0.850 0.850
##
## Regressions:
## Estimate Std.Err z-value P(>|z|) Std.lv Std.all
## wealth ~
## health 544.960 NA 1.011 1.011
## educ -30.677 NA -0.057 -0.057
##
## Covariances:
## Estimate Std.Err z-value P(>|z|) Std.lv Std.all
## health ~~
## educ 0.223 NA 0.223 0.223
##
## Intercepts:
## Estimate Std.Err z-value P(>|z|) Std.lv Std.all
## .h2o_source 74.670 NA 74.670 15.707
## .p1_educ 1.380 NA 1.380 1.010
## .p2_educ 2.874 NA 2.874 1.321
##
## Thresholds:
## Estimate Std.Err z-value P(>|z|) Std.lv Std.all
## share_toilt|t1 -0.849 NA -0.849 -0.849
## radio|t1 -0.370 NA -0.370 -0.370
## watch|t1 -0.098 NA -0.098 -0.098
## car_truck|t1 2.029 NA 2.029 2.029
## sewing_mchn|t1 1.653 NA 1.653 1.653
## cell_phone|t1 0.638 NA 0.638 0.638
##
## Variances:
## Estimate Std.Err z-value P(>|z|) Std.lv Std.all
## .h2o_source 22.093 NA 22.093 0.978
## .share_toilet 0.817 0.817 0.817
## .p1_educ -1.556 NA -1.556 -0.834
## .p2_educ 4.017 NA 4.017 0.849
## .radio 0.343 0.343 0.343
## .watch 0.435 0.435 0.435
## .car_truck 0.445 0.445 0.445
## .sewing_machine 0.511 0.511 0.511
## .cell_phone 0.277 0.277 0.277
## health 1.000 1.000 1.000
## educ 1.000 1.000 1.000
## .wealth 1.000 0.000 0.000
lavaanPlot(model = fit, node_options = list(shape = "box", fontname = "Helvetica"), edge_options = list(color = "grey"), coefs = TRUE)
#This is the message I got when I used So_Easta and So_Central
#Warning: lavaan->lav_object_summary():
# fit measures not available if model did not converge
#lavaan 0.6-20 did NOT end normally after 10000 iterations
#** WARNING ** Estimates below are most likely unreliable
#Same message w/ So_Central
#Error Message with Northwest and No_Central
#Warning: lavaan->lav_model_vcov():
# 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->lav_test_satorra_bentler():
# could not invert information matrix needed for robust test statistic
#Warning: lavaan->lav_object_post_check():
#some estimated ov variances are negative
#Run the SEM models for the whole file and Monrovia
#Run the SEM model for all of Liberia
pov.model <- '
health =~ h2o_source + share_toilet
educ =~ p1_educ + p2_educ
wealth =~ radio + watch + car_truck + cell_phone + computer + sewing_machine
health ~~ educ
wealth ~ health
wealth ~ educ'
fit <- sem(pov.model, std.lv = TRUE, ordered = c("share_toilet", "radio","watch", "car_truck", "cell_phone", "computer", "sewing_machine"), data = region_revd_educ)
## Warning: lavaan->lav_object_post_check():
## some estimated ov variances are negative
summary(fit, fit.measures = TRUE, standardized = TRUE)
## lavaan 0.6-20 ended normally after 49 iterations
##
## Estimator DWLS
## Optimization method NLMINB
## Number of model parameters 26
##
## Number of observations 10309
##
## Model Test User Model:
## Standard Scaled
## Test Statistic 179.919 214.709
## Degrees of freedom 32 32
## P-value (Chi-square) 0.000 0.000
## Scaling correction factor 0.847
## Shift parameter 2.306
## simple second-order correction
##
## Model Test Baseline Model:
##
## Test statistic 18471.120 15649.402
## Degrees of freedom 45 45
## P-value 0.000 0.000
## Scaling correction factor 1.181
##
## User Model versus Baseline Model:
##
## Comparative Fit Index (CFI) 0.992 0.988
## Tucker-Lewis Index (TLI) 0.989 0.984
##
## Robust Comparative Fit Index (CFI) NA
## Robust Tucker-Lewis Index (TLI) NA
##
## Root Mean Square Error of Approximation:
##
## RMSEA 0.021 0.024
## 90 Percent confidence interval - lower 0.018 0.021
## 90 Percent confidence interval - upper 0.024 0.027
## P-value H_0: RMSEA <= 0.050 1.000 1.000
## P-value H_0: RMSEA >= 0.080 0.000 0.000
##
## Robust RMSEA NA
## 90 Percent confidence interval - lower NA
## 90 Percent confidence interval - upper NA
## P-value H_0: Robust RMSEA <= 0.050 NA
## P-value H_0: Robust RMSEA >= 0.080 NA
##
## Standardized Root Mean Square Residual:
##
## SRMR 0.043 0.043
##
## Parameter Estimates:
##
## Parameterization Delta
## Standard errors Robust.sem
## Information Expected
## Information saturated (h1) model Unstructured
##
## Latent Variables:
## Estimate Std.Err z-value P(>|z|) Std.lv Std.all
## health =~
## h2o_source 1.307 0.172 7.601 0.000 1.307 0.106
## share_toilet -1.072 0.103 -10.369 0.000 -1.072 -1.072
## educ =~
## p1_educ 1.665 0.088 18.874 0.000 1.665 1.078
## p2_educ -0.846 0.048 -17.733 0.000 -0.846 -0.417
## wealth =~
## radio 0.609 0.022 28.289 0.000 0.726 0.726
## watch 0.620 0.021 28.873 0.000 0.739 0.739
## car_truck 0.695 0.027 26.081 0.000 0.828 0.828
## cell_phone 0.710 0.024 29.423 0.000 0.847 0.847
## computer 0.716 0.031 23.382 0.000 0.853 0.853
## sewing_machine 0.426 0.023 18.454 0.000 0.508 0.508
##
## Regressions:
## Estimate Std.Err z-value P(>|z|) Std.lv Std.all
## wealth ~
## health 0.574 0.076 7.526 0.000 0.482 0.482
## educ 0.228 0.021 11.055 0.000 0.191 0.191
##
## Covariances:
## Estimate Std.Err z-value P(>|z|) Std.lv Std.all
## health ~~
## educ 0.154 0.020 7.789 0.000 0.154 0.154
##
## Intercepts:
## Estimate Std.Err z-value P(>|z|) Std.lv Std.all
## .h2o_source 75.135 0.177 424.365 0.000 75.135 6.095
## .p1_educ 1.708 0.018 93.850 0.000 1.708 1.106
## .p2_educ 2.731 0.040 69.086 0.000 2.731 1.346
##
## Thresholds:
## Estimate Std.Err z-value P(>|z|) Std.lv Std.all
## share_toilt|t1 -0.430 0.013 -33.659 0.000 -0.430 -0.430
## radio|t1 -0.640 0.013 -48.061 0.000 -0.640 -0.640
## watch|t1 -0.324 0.013 -25.729 0.000 -0.324 -0.324
## car_truck|t1 1.640 0.021 79.051 0.000 1.640 1.640
## cell_phone|t1 -0.135 0.012 -10.899 0.000 -0.135 -0.135
## computer|t1 1.953 0.026 74.654 0.000 1.953 1.953
## sewing_mchn|t1 1.643 0.021 79.034 0.000 1.643 1.643
##
## Variances:
## Estimate Std.Err z-value P(>|z|) Std.lv Std.all
## .h2o_source 150.247 1.202 124.995 0.000 150.247 0.989
## .share_toilet -0.150 -0.150 -0.150
## .p1_educ -0.387 0.274 -1.413 0.158 -0.387 -0.162
## .p2_educ 3.399 0.137 24.751 0.000 3.399 0.826
## .radio 0.473 0.473 0.473
## .watch 0.454 0.454 0.454
## .car_truck 0.314 0.314 0.314
## .cell_phone 0.283 0.283 0.283
## .computer 0.272 0.272 0.272
## .sewing_machine 0.742 0.742 0.742
## health 1.000 1.000 1.000
## educ 1.000 1.000 1.000
## .wealth 1.000 0.703 0.703
lavaanPlot(model = fit, node_options = list(shape = "box", fontname = "Helvetica"), edge_options = list(color = "blue"), coefs = TRUE, stars = ("latent"))
#Run the SEM model for Monrovia
pov.model <- '
health =~ h2o_source + share_toilet
educ =~ p1_educ + p2_educ
wealth =~ radio + watch + car_truck + cell_phone + computer + sewing_machine
health ~~ educ
wealth ~ health
wealth ~ educ'
fit <- sem(pov.model, std.lv = TRUE, ordered = c("share_toilet", "radio", "watch", "car_truck", "cell_phone", "computer", "sewing_machine"), data = Monrovia)
## Warning: lavaan->lav_object_post_check():
## some estimated ov variances are negative
summary(fit, fit.measures = TRUE, standardized = TRUE)
## lavaan 0.6-20 ended normally after 48 iterations
##
## Estimator DWLS
## Optimization method NLMINB
## Number of model parameters 26
##
## Number of observations 4260
##
## Model Test User Model:
## Standard Scaled
## Test Statistic 111.555 130.287
## Degrees of freedom 32 32
## P-value (Chi-square) 0.000 0.000
## Scaling correction factor 0.872
## Shift parameter 2.314
## simple second-order correction
##
## Model Test Baseline Model:
##
## Test statistic 5925.709 5086.726
## Degrees of freedom 45 45
## P-value 0.000 0.000
## Scaling correction factor 1.166
##
## User Model versus Baseline Model:
##
## Comparative Fit Index (CFI) 0.986 0.981
## Tucker-Lewis Index (TLI) 0.981 0.973
##
## Robust Comparative Fit Index (CFI) NA
## Robust Tucker-Lewis Index (TLI) NA
##
## Root Mean Square Error of Approximation:
##
## RMSEA 0.024 0.027
## 90 Percent confidence interval - lower 0.019 0.022
## 90 Percent confidence interval - upper 0.029 0.032
## P-value H_0: RMSEA <= 0.050 1.000 1.000
## P-value H_0: RMSEA >= 0.080 0.000 0.000
##
## Robust RMSEA NA
## 90 Percent confidence interval - lower NA
## 90 Percent confidence interval - upper NA
## P-value H_0: Robust RMSEA <= 0.050 NA
## P-value H_0: Robust RMSEA >= 0.080 NA
##
## Standardized Root Mean Square Residual:
##
## SRMR 0.049 0.049
##
## Parameter Estimates:
##
## Parameterization Delta
## Standard errors Robust.sem
## Information Expected
## Information saturated (h1) model Unstructured
##
## Latent Variables:
## Estimate Std.Err z-value P(>|z|) Std.lv Std.all
## health =~
## h2o_source 1.690 0.397 4.255 0.000 1.690 0.098
## share_toilet -1.027 0.167 -6.134 0.000 -1.027 -1.027
## educ =~
## p1_educ 1.873 0.315 5.951 0.000 1.873 1.143
## p2_educ -0.533 0.091 -5.872 0.000 -0.533 -0.298
## wealth =~
## radio 0.551 0.041 13.415 0.000 0.661 0.661
## watch 0.607 0.044 13.797 0.000 0.728 0.728
## car_truck 0.733 0.055 13.264 0.000 0.879 0.879
## cell_phone 0.677 0.049 13.911 0.000 0.812 0.812
## computer 0.670 0.052 12.830 0.000 0.804 0.804
## sewing_machine 0.322 0.036 8.903 0.000 0.386 0.386
##
## Regressions:
## Estimate Std.Err z-value P(>|z|) Std.lv Std.all
## wealth ~
## health 0.638 0.153 4.169 0.000 0.532 0.532
## educ 0.117 0.035 3.339 0.001 0.097 0.097
##
## Covariances:
## Estimate Std.Err z-value P(>|z|) Std.lv Std.all
## health ~~
## educ 0.128 0.035 3.671 0.000 0.128 0.128
##
## Intercepts:
## Estimate Std.Err z-value P(>|z|) Std.lv Std.all
## .h2o_source 75.087 0.405 185.441 0.000 75.087 4.371
## .p1_educ 2.127 0.026 81.246 0.000 2.127 1.299
## .p2_educ 2.505 0.054 46.275 0.000 2.505 1.400
##
## Thresholds:
## Estimate Std.Err z-value P(>|z|) Std.lv Std.all
## share_toilt|t1 -0.133 0.019 -6.923 0.000 -0.133 -0.133
## radio|t1 -0.962 0.023 -42.168 0.000 -0.962 -0.962
## watch|t1 -0.672 0.021 -32.215 0.000 -0.672 -0.672
## car_truck|t1 1.340 0.027 49.641 0.000 1.340 1.340
## cell_phone|t1 -0.870 0.022 -39.364 0.000 -0.870 -0.870
## computer|t1 1.629 0.032 50.840 0.000 1.629 1.629
## sewing_mchn|t1 1.450 0.029 50.554 0.000 1.450 1.450
##
## Variances:
## Estimate Std.Err z-value P(>|z|) Std.lv Std.all
## .h2o_source 292.284 5.260 55.569 0.000 292.284 0.990
## .share_toilet -0.054 -0.054 -0.054
## .p1_educ -0.825 1.162 -0.709 0.478 -0.825 -0.307
## .p2_educ 2.918 0.152 19.183 0.000 2.918 0.911
## .radio 0.563 0.563 0.563
## .watch 0.470 0.470 0.470
## .car_truck 0.227 0.227 0.227
## .cell_phone 0.341 0.341 0.341
## .computer 0.353 0.353 0.353
## .sewing_machine 0.851 0.851 0.851
## health 1.000 1.000 1.000
## educ 1.000 1.000 1.000
## .wealth 1.000 0.695 0.695
lavaanPlot(model = fit, node_options = list(shape = "box", fontname = "Helvetica"), edge_options = list(color = "blue"), coefs = TRUE, covs = TRUE, stars = "covs")
``