I have tried to make a few adjustments to this model but its failing give me the good fit even thought its able to give estimates. The first message its gives is some variances are negative. See the commands below and further the output.
semMed2 <- '
###Measuremement models
Underlying_causes =~bord+ m_educa+ mo_age
Basic_causes =~ HH_members+N_under5+ w_index
# direct effect
Haz ~ c*Basic_causes
# mediator
Underlying_causes ~ b*Basic_causes
Haz ~ a*Underlying_causes
# indirect effect
ab := a*b
# total effect
total := c + (a*b)
###Residual correlation
bord~~mo_age
mo_age~~HH_members
'
fitsem2 <- sem (semMed2, data=data4R, estimator = "MLR", test = "bootstrap")
summary (fitsem2, fit.measures=TRUE, standardized=TRUE)
Warning message:
In lav_object_post_check(object) :
lavaan WARNING: some estimated ov variances are negative
> summary (fitsem2, fit.measures=TRUE, standardized=TRUE)
lavaan 0.6-2 ended normally after 94 iterations
Optimization method NLMINB
Number of free parameters 18
Number of observations 3047
Estimator ML Robust
Model Fit Test Statistic 815.270 820.407
Degrees of freedom 10 10
P-value (Chi-square) 0.000 0.000
Scaling correction factor 0.994
for the Yuan-Bentler correction (Mplus variant)
Model test baseline model:
Minimum Function Test Statistic 6493.250 5470.808
Degrees of freedom 21 21
P-value 0.000 0.000
User model versus baseline model:
Comparative Fit Index (CFI) 0.876 0.851
Tucker-Lewis Index (TLI) 0.739 0.688
Robust Comparative Fit Index (CFI) 0.875
Robust Tucker-Lewis Index (TLI) 0.739
Loglikelihood and Information Criteria:
Loglikelihood user model (H0) -37374.708 -37374.708
Scaling correction factor 1.428
for the MLR correction
Loglikelihood unrestricted model (H1) -36967.072 -36967.072
Scaling correction factor 1.273
for the MLR correction
Number of free parameters 18 18
Akaike (AIC) 74785.415 74785.415
Bayesian (BIC) 74893.810 74893.810
Sample-size adjusted Bayesian (BIC) 74836.616 74836.616
Root Mean Square Error of Approximation:
RMSEA 0.163 0.163
90 Percent Confidence Interval 0.153 0.172 0.154 0.173
P-value RMSEA <= 0.05 0.000 0.000
Robust RMSEA 0.163
90 Percent Confidence Interval 0.153 0.172
Standardized Root Mean Square Residual:
SRMR 0.091 0.091
Parameter Estimates:
Information Observed
Observed information based on Hessian
Standard Errors Robust.huber.white
Latent Variables:
Estimate Std.Err z-value P(>|z|) Std.lv Std.all
Underlying_causes =~
bord 1.000 2.833 1.408
m_educa -0.046 0.012 -3.825 0.000 -0.130 -0.211
mo_age 1.338 0.129 10.401 0.000 3.791 0.571
Basic_causes =~
HH_members 1.000 2.349 1.121
N_under5 0.135 0.014 9.461 0.000 0.317 0.436
w_index 0.084 0.008 10.503 0.000 0.197 0.141
Regressions:
Estimate Std.Err z-value P(>|z|) Std.lv Std.all
Haz ~
Basic_cass (c) 0.017 0.010 1.670 0.095 0.041 0.027
Underlying_causes ~
Basic_cass (b) 0.334 0.045 7.396 0.000 0.277 0.277
Haz ~
Undrlyng_c (a) 0.005 0.005 1.015 0.310 0.015 0.010
Covariances:
Estimate Std.Err z-value P(>|z|) Std.lv Std.all
.bord ~~
.mo_age 0.366 2.802 0.131 0.896 0.366 0.034
.mo_age ~~
.HH_members 2.573 0.222 11.583 0.000 2.573 0.445
Variances:
Estimate Std.Err z-value P(>|z|) Std.lv Std.all
.bord -3.978 1.991 -1.998 0.046 -3.978 -0.982
.m_educa 0.360 0.011 32.998 0.000 0.360 0.955
.mo_age 29.635 4.407 6.725 0.000 29.635 0.673
.HH_members -1.127 0.610 -1.847 0.065 -1.127 -0.257
.N_under5 0.428 0.020 21.104 0.000 0.428 0.810
.w_index 1.924 0.031 61.725 0.000 1.924 0.980
.Haz 2.269 0.090 25.268 0.000 2.269 0.999
.Underlying_css 7.412 1.988 3.728 0.000 0.923 0.923
Basic_causes 5.516 0.669 8.243 0.000 1.000 1.000
Defined Parameters:
Estimate Std.Err z-value P(>|z|) Std.lv Std.all
ab 0.002 0.002 1.034 0.301 0.004 0.003
total 0.019 0.010 1.886 0.059 0.045 0.030