dat <- read.csv("senol2010.csv")
head(dat)
## ptgi1 ptgi2 ptgi3 ptgi4 ptgi5 fa fr si comt
## 1 15.8617 7.0800 9.4997 7.2756 7.2680 28.7726 16.9739 20.4296 12.4859
## 2 19.6334 13.1096 12.3745 6.9255 6.2475 16.0773 9.7708 6.5726 10.1819
## 3 24.6786 18.5167 14.6082 18.2842 10.4416 34.5587 23.8234 21.7633 12.2450
## 4 26.9459 15.3288 14.5654 9.9698 8.3321 24.3256 33.4157 31.2910 10.8508
## 5 18.0531 13.3321 14.5088 11.6376 10.3924 22.6827 9.4061 3.1562 11.2533
## 6 31.3798 17.5496 18.4890 12.8566 7.1857 29.0508 23.1035 26.1498 11.9943
## con cha es lo pro th time em ind
## 1 10.9396 10.1292 36.8005 52.8915 2.8763 2.6852 -0.8918 52.0948 17.2888
## 2 12.5612 9.6461 31.4333 98.4248 2.9732 2.0234 5.2705 29.8632 24.3148
## 3 10.6007 11.7502 27.9093 101.7361 1.8429 2.3620 8.3544 50.4500 7.2650
## 4 6.8631 11.3476 25.9313 78.5248 2.2862 2.7916 7.5874 52.5123 17.4150
## 5 7.8138 11.3474 39.1906 99.5560 2.3429 1.5655 -11.4437 52.2498 23.9244
## 6 10.9793 8.6953 43.8300 76.8719 3.9703 0.8496 13.7793 40.7333 21.3375
## ru av hy rb
## 1 13.7673 10.0187 12.5244 2.0344
## 2 17.4315 18.7440 10.8034 4.9841
## 3 15.6340 20.8238 13.3176 4.4496
## 4 18.6266 8.9949 9.5156 4.7464
## 5 13.6645 8.4527 8.4414 4.2300
## 6 11.8501 10.2377 7.7889 2.7087
##########################
####Part 1
##Fit the path analysis implied by Figure 1 in the paper
##########################
library(psych)
## Warning: package 'psych' was built under R version 4.2.2
######## Calculate the alpha-coefficient for each scale
#alpha-coefficient for each ERSS_scale
alpha(dat[c("fa","fr","si")],check.keys=TRUE)$total
## Number of categories should be increased in order to count frequencies.
## raw_alpha std.alpha G6(smc) average_r S/N ase mean sd
## 0.6262383 0.6242778 0.576102 0.356436 1.661541 0.04854985 21.03 4.556611
## median_r
## 0.3267338
#alpha-coefficient for each IR_scale
alpha(dat[c("lo","comt","con","cha","es")],check.keys=TRUE)$total
## Number of categories should be increased in order to count frequencies.
## Warning in alpha(dat[c("lo", "comt", "con", "cha", "es")], check.keys = TRUE): Some items were negatively correlated with total scale and were automatically reversed.
## This is indicated by a negative sign for the variable name.
## raw_alpha std.alpha G6(smc) average_r S/N ase mean sd
## 0.4369416 0.661696 0.6588184 0.2811879 1.955921 0.04261331 21.78866 4.903381
## median_r
## 0.2871283
#alpha-coefficient for each ERF_scale
alpha(dat[c("pro","th","time")],check.keys=TRUE)$total
## Number of categories should be increased in order to count frequencies.
## Warning in alpha(dat[c("pro", "th", "time")], check.keys = TRUE): Some items were negatively correlated with total scale and were automatically reversed.
## This is indicated by a negative sign for the variable name.
## raw_alpha std.alpha G6(smc) average_r S/N ase mean
## 0.06426069 0.3435068 0.2733099 0.1485122 0.5232449 0.04422656 3.737367
## sd median_r
## 2.795414 0.08910729
#alpha-coefficient for each CPC_scale
alpha(dat[c("em","ind","ru","av","hy","rb")],check.keys=TRUE)$total
## Number of categories should be increased in order to count frequencies.
## Warning in alpha(dat[c("em", "ind", "ru", "av", "hy", "rb")], check.keys = TRUE): Some items were negatively correlated with total scale and were automatically reversed.
## This is indicated by a negative sign for the variable name.
## raw_alpha std.alpha G6(smc) average_r S/N ase mean sd
## 0.7088734 0.7259453 0.7510934 0.3062706 2.648906 0.03352199 18.2549 4.532799
## median_r
## 0.2970295
#alpha-coefficient for each ptgi_scale
alpha(dat[c("ptgi1","ptgi2","ptgi3","ptgi4","ptgi5")],check.keys=TRUE)$total
## Number of categories should be increased in order to count frequencies.
## raw_alpha std.alpha G6(smc) average_r S/N ase mean sd
## 0.8655373 0.905243 0.8873872 0.6564356 9.553313 0.01320586 11.834 4.848053
## median_r
## 0.6584159
########
#Replace the latent variables with scale scores (standardize each variable then create sum or mean scores)
#ERSS_scale
dat$erss_scale= scale(dat$fa)+scale(dat$fr)+scale(dat$si)
#IR_scale
dat$ir_scale= scale(dat$comt)+scale(dat$con)+scale(dat$cha)+scale(dat$es)-scale(dat$lo)
#ERF_scale
dat$erf_scale= scale(dat$pro)-scale(dat$th)+scale(dat$time)
#CPC_scale
dat$cpc_scale= scale(dat$em)-scale(dat$ind)+scale(dat$ru)+scale(dat$av)+scale(dat$hy)+scale(dat$rb)
#ptgi_scale
dat$ptgi_scale= scale(dat$ptgi1)+scale(dat$ptgi2)+scale(dat$ptgi3)+scale(dat$ptgi4)+scale(dat$ptgi5)
colnames(dat)
## [1] "ptgi1" "ptgi2" "ptgi3" "ptgi4" "ptgi5"
## [6] "fa" "fr" "si" "comt" "con"
## [11] "cha" "es" "lo" "pro" "th"
## [16] "time" "em" "ind" "ru" "av"
## [21] "hy" "rb" "erss_scale" "ir_scale" "erf_scale"
## [26] "cpc_scale" "ptgi_scale"
library(lavaan)
## Warning: package 'lavaan' was built under R version 4.2.3
## This is lavaan 0.6-15
## lavaan is FREE software! Please report any bugs.
##
## Attaching package: 'lavaan'
## The following object is masked from 'package:psych':
##
## cor2cov
######
# Fit the path analysis using the scale scores.
senol_pa <- "
erf_scale ~ erss_scale +ir_scale
cpc_scale ~ erf_scale
ptgi_scale ~ erss_scale + ir_scale +cpc_scale"
senol_pa <- sem(model = senol_pa, data = dat)
senol_pa
## lavaan 0.6.15 ended normally after 1 iteration
##
## Estimator ML
## Optimization method NLMINB
## Number of model parameters 9
##
## Number of observations 132
##
## Model Test User Model:
##
## Test statistic 5.465
## Degrees of freedom 3
## P-value (Chi-square) 0.141
summary(senol_pa, header = FALSE, ci = TRUE, rsquare = TRUE ,fit.measures=TRUE)
##
## Model Test Baseline Model:
##
## Test statistic 68.704
## Degrees of freedom 9
## P-value 0.000
##
## User Model versus Baseline Model:
##
## Comparative Fit Index (CFI) 0.959
## Tucker-Lewis Index (TLI) 0.876
##
## Loglikelihood and Information Criteria:
##
## Loglikelihood user model (H0) -989.236
## Loglikelihood unrestricted model (H1) -986.504
##
## Akaike (AIC) 1996.473
## Bayesian (BIC) 2022.418
## Sample-size adjusted Bayesian (SABIC) 1993.951
##
## Root Mean Square Error of Approximation:
##
## RMSEA 0.079
## 90 Percent confidence interval - lower 0.000
## 90 Percent confidence interval - upper 0.183
## P-value H_0: RMSEA <= 0.050 0.251
## P-value H_0: RMSEA >= 0.080 0.582
##
## Standardized Root Mean Square Residual:
##
## SRMR 0.051
##
## Parameter Estimates:
##
## Standard errors Standard
## Information Expected
## Information saturated (h1) model Structured
##
## Regressions:
## Estimate Std.Err z-value P(>|z|) ci.lower ci.upper
## erf_scale ~
## erss_scale -0.016 0.075 -0.207 0.836 -0.163 0.132
## ir_scale 0.179 0.052 3.427 0.001 0.077 0.281
## cpc_scale ~
## erf_scale -0.369 0.169 -2.184 0.029 -0.700 -0.038
## ptgi_scale ~
## erss_scale 0.349 0.142 2.457 0.014 0.071 0.627
## ir_scale 0.196 0.099 1.987 0.047 0.003 0.390
## cpc_scale 0.500 0.080 6.273 0.000 0.344 0.657
##
## Variances:
## Estimate Std.Err z-value P(>|z|) ci.lower ci.upper
## .erf_scale 3.533 0.435 8.124 0.000 2.681 4.386
## .cpc_scale 14.547 1.791 8.124 0.000 11.038 18.057
## .ptgi_scale 12.618 1.553 8.124 0.000 9.574 15.662
##
## R-Square:
## Estimate
## erf_scale 0.085
## cpc_scale 0.035
## ptgi_scale 0.279
library(lavaanPlot)
## Warning: package 'lavaanPlot' was built under R version 4.2.2
lavaanPlot(model = senol_pa, coefs = TRUE, covs = TRUE, stars = "regress")
Scale Alpha
ERSS_scale 0.6242778
IR_scale 0.661696
ERF_scale 0.3435068
CPC_scale 0.7259453
ptgi_scale 0.905243
##########################
####Part 2
#Fit the SEM implied by Figure 1
senol_sem_syntax <- "
# Measurement model
er =~ fa + fr +si
ir =~ comt + con + cha + es + lo
erf =~ pro + time +th
cpc =~ em + ind +ru +av +hy +rb
ptgi =~ ptgi1 + ptgi2 +ptgi3 +ptgi4 +ptgi5
# Structural model
erf ~ er + ir
cpc ~ erf
ptgi ~ er + ir +cpc
"
senol_sem_fit <- sem(
senol_sem_syntax,
data = dat, # dataset
std.lv = TRUE # standardize latent variables
)
summary(senol_sem_fit, fit.measures = TRUE, standardize = TRUE, rsquare = TRUE)
## lavaan 0.6.15 ended normally after 54 iterations
##
## Estimator ML
## Optimization method NLMINB
## Number of model parameters 51
##
## Number of observations 132
##
## Model Test User Model:
##
## Test statistic 337.682
## Degrees of freedom 202
## P-value (Chi-square) 0.000
##
## Model Test Baseline Model:
##
## Test statistic 1172.516
## Degrees of freedom 231
## P-value 0.000
##
## User Model versus Baseline Model:
##
## Comparative Fit Index (CFI) 0.856
## Tucker-Lewis Index (TLI) 0.835
##
## Loglikelihood and Information Criteria:
##
## Loglikelihood user model (H0) -8036.650
## Loglikelihood unrestricted model (H1) -7867.809
##
## Akaike (AIC) 16175.301
## Bayesian (BIC) 16322.323
## Sample-size adjusted Bayesian (SABIC) 16161.010
##
## Root Mean Square Error of Approximation:
##
## RMSEA 0.071
## 90 Percent confidence interval - lower 0.058
## 90 Percent confidence interval - upper 0.084
## P-value H_0: RMSEA <= 0.050 0.006
## P-value H_0: RMSEA >= 0.080 0.143
##
## Standardized Root Mean Square Residual:
##
## SRMR 0.104
##
## Parameter Estimates:
##
## Standard errors Standard
## Information Expected
## Information saturated (h1) model Structured
##
## Latent Variables:
## Estimate Std.Err z-value P(>|z|) Std.lv Std.all
## er =~
## fa 1.356 0.367 3.692 0.000 1.356 0.350
## fr 5.683 0.744 7.640 0.000 5.683 0.935
## si 4.580 0.779 5.883 0.000 4.580 0.612
## ir =~
## comt 1.214 0.262 4.638 0.000 1.214 0.458
## con 1.709 0.319 5.354 0.000 1.709 0.522
## cha 1.252 0.240 5.222 0.000 1.252 0.510
## es 2.949 0.581 5.080 0.000 2.949 0.498
## lo -12.019 1.738 -6.915 0.000 -12.019 -0.663
## erf =~
## pro 0.324 0.094 3.440 0.001 0.407 0.549
## time 1.506 0.787 1.912 0.056 1.890 0.235
## th -0.406 0.126 -3.235 0.001 -0.510 -0.447
## cpc =~
## em 4.455 0.946 4.710 0.000 4.753 0.416
## ind -2.435 0.569 -4.276 0.000 -2.597 -0.380
## ru 6.196 0.567 10.936 0.000 6.610 0.879
## av 2.243 0.455 4.925 0.000 2.393 0.434
## hy 5.144 0.447 11.503 0.000 5.488 0.923
## rb 0.148 0.078 1.886 0.059 0.158 0.171
## ptgi =~
## ptgi1 6.705 0.582 11.522 0.000 7.821 0.871
## ptgi2 5.084 0.447 11.371 0.000 5.930 0.863
## ptgi3 3.304 0.357 9.246 0.000 3.854 0.739
## ptgi4 2.500 0.251 9.968 0.000 2.916 0.783
## ptgi5 2.074 0.204 10.166 0.000 2.419 0.794
##
## Regressions:
## Estimate Std.Err z-value P(>|z|) Std.lv Std.all
## erf ~
## er -0.254 0.191 -1.330 0.183 -0.202 -0.202
## ir 0.790 0.288 2.742 0.006 0.629 0.629
## cpc ~
## erf -0.296 0.123 -2.415 0.016 -0.348 -0.348
## ptgi ~
## er 0.234 0.113 2.072 0.038 0.200 0.200
## ir 0.276 0.130 2.132 0.033 0.237 0.237
## cpc 0.465 0.109 4.256 0.000 0.425 0.425
##
## Covariances:
## Estimate Std.Err z-value P(>|z|) Std.lv Std.all
## er ~~
## ir 0.280 0.109 2.573 0.010 0.280 0.280
##
## Variances:
## Estimate Std.Err z-value P(>|z|) Std.lv Std.all
## .fa 13.173 1.684 7.822 0.000 13.173 0.877
## .fr 4.636 7.174 0.646 0.518 4.636 0.126
## .si 35.107 6.368 5.513 0.000 35.107 0.626
## .comt 5.565 0.769 7.235 0.000 5.565 0.791
## .con 7.796 1.137 6.857 0.000 7.796 0.727
## .cha 4.449 0.642 6.935 0.000 4.449 0.740
## .es 26.430 3.768 7.014 0.000 26.430 0.752
## .lo 184.659 33.730 5.475 0.000 184.659 0.561
## .pro 0.383 0.077 4.977 0.000 0.383 0.699
## .time 61.380 7.952 7.719 0.000 61.380 0.945
## .th 1.042 0.165 6.310 0.000 1.042 0.800
## .em 107.905 13.571 7.951 0.000 107.905 0.827
## .ind 40.012 5.011 7.985 0.000 40.012 0.856
## .ru 12.839 3.266 3.930 0.000 12.839 0.227
## .av 24.704 3.115 7.932 0.000 24.704 0.812
## .hy 5.253 2.062 2.548 0.011 5.253 0.149
## .rb 0.824 0.102 8.100 0.000 0.824 0.971
## .ptgi1 19.484 3.432 5.677 0.000 19.484 0.242
## .ptgi2 12.106 2.067 5.857 0.000 12.106 0.256
## .ptgi3 12.332 1.712 7.205 0.000 12.332 0.454
## .ptgi4 5.370 0.777 6.908 0.000 5.370 0.387
## .ptgi5 3.420 0.502 6.807 0.000 3.420 0.369
## er 1.000 1.000 1.000
## ir 1.000 1.000 1.000
## .erf 1.000 0.634 0.634
## .cpc 1.000 0.879 0.879
## .ptgi 1.000 0.735 0.735
##
## R-Square:
## Estimate
## fa 0.123
## fr 0.874
## si 0.374
## comt 0.209
## con 0.273
## cha 0.260
## es 0.248
## lo 0.439
## pro 0.301
## time 0.055
## th 0.200
## em 0.173
## ind 0.144
## ru 0.773
## av 0.188
## hy 0.851
## rb 0.029
## ptgi1 0.758
## ptgi2 0.744
## ptgi3 0.546
## ptgi4 0.613
## ptgi5 0.631
## erf 0.366
## cpc 0.121
## ptgi 0.265
4.Assess the resulting model for misspecification using global fit indices.
Chi-square(3)=5.465 df= 3 , P=0.141 Conventional preference: p > α=0.05
(CFI)=0.959 ;Conventional Reference: CFI>0.95
(TLI)= 0.876 ;Conventional Reference: TLI>0.95
RMSEA=0.079 :Conventional Reference: RMSEA<0.06
RMSEA = .079, 90% CI [.000,0.183], p(RMSEA >= .08)= 0.582 >0.05 not significant
SRMR=0.051 ;Conventional Reference: SRMR < .05
Conventional cut-offs:
Passed: Chi-square, CFI , SRMR ;
Failed: χ2, RMSEA ,TLI
#2. Fit the SEM implied by Figure 1.
2.1.Does lavaan report a correlation between any factors? If so, why?
Covariances:
Yes ,Lavaan reported a correlation between er and ir , er ~~ ir
Estimate 0.280
Std.Err 0.109
z-value 2.573
P(>|z|) 0.010
Std.lv 0.280
Std.all 0.280
correlation = sqrt (.280) = 0.52915026221 = 53%
Chi-square 337.682 (202), p < .001
RMSEA values(0.071) is larger than 0.06 which indicate that the model has not the best fit
CFI CFI values (0.856 ) isless than 0.95
TLI TLI values (0.835) is less than 0.95 which indicate no good model fit
SRMR 0.104
Conventional cut-offs:
Passed: SRMR
Failed:Chi-square, χ2, RMSEA ,CFI,TLI
the model have poor fit ###
#########
####Part 3.The model in 2. will have poor fit. Break this model down into the constituent unidimensional factor models.
##Steps
##3.1.Fit each constituent unidimensional factor model separately using a CFA. Start with the factors with fewer items.
##
er_cfa_syn <-"ercfa =~ fa + fr +si"
er_cfa_fit <-cfa(er_cfa_syn , data=dat, std.lv= TRUE)
## Warning in lav_object_post_check(object): lavaan WARNING: some estimated ov
## variances are negative
er_cfa_fit
## lavaan 0.6.15 ended normally after 24 iterations
##
## Estimator ML
## Optimization method NLMINB
## Number of model parameters 6
##
## Number of observations 132
##
## Model Test User Model:
##
## Test statistic 0.000
## Degrees of freedom 0
summary(er_cfa_fit, fit.measures = TRUE, standardize = TRUE, rsquare = TRUE)
## lavaan 0.6.15 ended normally after 24 iterations
##
## Estimator ML
## Optimization method NLMINB
## Number of model parameters 6
##
## Number of observations 132
##
## Model Test User Model:
##
## Test statistic 0.000
## Degrees of freedom 0
##
## Model Test Baseline Model:
##
## Test statistic 67.802
## Degrees of freedom 3
## P-value 0.000
##
## User Model versus Baseline Model:
##
## Comparative Fit Index (CFI) 1.000
## Tucker-Lewis Index (TLI) 1.000
##
## Loglikelihood and Information Criteria:
##
## Loglikelihood user model (H0) -1210.751
## Loglikelihood unrestricted model (H1) -1210.751
##
## Akaike (AIC) 2433.501
## Bayesian (BIC) 2450.798
## Sample-size adjusted Bayesian (SABIC) 2431.820
##
## Root Mean Square Error of Approximation:
##
## RMSEA 0.000
## 90 Percent confidence interval - lower 0.000
## 90 Percent confidence interval - upper 0.000
## P-value H_0: RMSEA <= 0.050 NA
## P-value H_0: RMSEA >= 0.080 NA
##
## Standardized Root Mean Square Residual:
##
## SRMR 0.000
##
## Parameter Estimates:
##
## Standard errors Standard
## Information Expected
## Information saturated (h1) model Structured
##
## Latent Variables:
## Estimate Std.Err z-value P(>|z|) Std.lv Std.all
## ercfa =~
## fa 1.199 0.408 2.941 0.003 1.199 0.309
## fr 6.416 1.335 4.807 0.000 6.416 1.056
## si 4.073 1.015 4.013 0.000 4.073 0.544
##
## Variances:
## Estimate Std.Err z-value P(>|z|) Std.lv Std.all
## .fa 13.574 1.768 7.679 0.000 13.574 0.904
## .fr -4.238 16.530 -0.256 0.798 -4.238 -0.115
## .si 39.491 8.244 4.790 0.000 39.491 0.704
## ercfa 1.000 1.000 1.000
##
## R-Square:
## Estimate
## fa 0.096
## fr NA
## si 0.296
##
#ir
##
ir_cfa_syn <-"ircfa =~ comt + con + cha + es + lo"
ir_cfa_fit <-cfa(ir_cfa_syn , data=dat, std.lv= TRUE)
ir_cfa_fit
## lavaan 0.6.15 ended normally after 33 iterations
##
## Estimator ML
## Optimization method NLMINB
## Number of model parameters 10
##
## Number of observations 132
##
## Model Test User Model:
##
## Test statistic 38.682
## Degrees of freedom 5
## P-value (Chi-square) 0.000
summary(ir_cfa_fit, fit.measures = TRUE, standardize = TRUE, rsquare = TRUE)
## lavaan 0.6.15 ended normally after 33 iterations
##
## Estimator ML
## Optimization method NLMINB
## Number of model parameters 10
##
## Number of observations 132
##
## Model Test User Model:
##
## Test statistic 38.682
## Degrees of freedom 5
## P-value (Chi-square) 0.000
##
## Model Test Baseline Model:
##
## Test statistic 116.649
## Degrees of freedom 10
## P-value 0.000
##
## User Model versus Baseline Model:
##
## Comparative Fit Index (CFI) 0.684
## Tucker-Lewis Index (TLI) 0.368
##
## Loglikelihood and Information Criteria:
##
## Loglikelihood user model (H0) -1918.755
## Loglikelihood unrestricted model (H1) -1899.414
##
## Akaike (AIC) 3857.509
## Bayesian (BIC) 3886.337
## Sample-size adjusted Bayesian (SABIC) 3854.707
##
## Root Mean Square Error of Approximation:
##
## RMSEA 0.226
## 90 Percent confidence interval - lower 0.163
## 90 Percent confidence interval - upper 0.295
## P-value H_0: RMSEA <= 0.050 0.000
## P-value H_0: RMSEA >= 0.080 1.000
##
## Standardized Root Mean Square Residual:
##
## SRMR 0.106
##
## Parameter Estimates:
##
## Standard errors Standard
## Information Expected
## Information saturated (h1) model Structured
##
## Latent Variables:
## Estimate Std.Err z-value P(>|z|) Std.lv Std.all
## ircfa =~
## comt 1.249 0.270 4.633 0.000 1.249 0.471
## con 1.640 0.332 4.943 0.000 1.640 0.501
## cha 1.276 0.248 5.141 0.000 1.276 0.520
## es 2.958 0.601 4.925 0.000 2.958 0.499
## lo -12.089 1.847 -6.546 0.000 -12.089 -0.666
##
## Variances:
## Estimate Std.Err z-value P(>|z|) Std.lv Std.all
## .comt 5.478 0.783 6.998 0.000 5.478 0.778
## .con 8.028 1.182 6.792 0.000 8.028 0.749
## .cha 4.388 0.661 6.642 0.000 4.388 0.729
## .es 26.376 3.876 6.806 0.000 26.376 0.751
## .lo 182.950 36.974 4.948 0.000 182.950 0.556
## ircfa 1.000 1.000 1.000
##
## R-Square:
## Estimate
## comt 0.222
## con 0.251
## cha 0.271
## es 0.249
## lo 0.444
##
modificationIndices(ir_cfa_fit, sort. = TRUE)
## lhs op rhs mi epc sepc.lv sepc.all sepc.nox
## 13 comt ~~ cha 29.738 2.975 2.975 0.607 0.607
## 16 con ~~ cha 12.392 -2.401 -2.401 -0.404 -0.404
## 18 con ~~ lo 11.776 -19.751 -19.751 -0.515 -0.515
## 12 comt ~~ con 7.657 -2.001 -2.001 -0.302 -0.302
## 17 con ~~ es 5.264 3.743 3.743 0.257 0.257
## 14 comt ~~ es 2.646 -2.128 -2.128 -0.177 -0.177
## 20 cha ~~ lo 2.587 7.112 7.112 0.251 0.251
## 15 comt ~~ lo 1.095 4.719 4.719 0.149 0.149
## 21 es ~~ lo 0.618 8.175 8.175 0.118 0.118
## 19 cha ~~ es 0.024 0.192 0.192 0.018 0.018
###
##
ir_cfa_mod_syn <-"ircfa =~ comt + con + cha + es + lo
comt ~~ cha "
ir_cfa_mod_fit <-cfa(ir_cfa_mod_syn , data=dat, std.lv= TRUE)
ir_cfa_mod_fit
## lavaan 0.6.15 ended normally after 39 iterations
##
## Estimator ML
## Optimization method NLMINB
## Number of model parameters 11
##
## Number of observations 132
##
## Model Test User Model:
##
## Test statistic 10.463
## Degrees of freedom 4
## P-value (Chi-square) 0.033
summary(ir_cfa_fit, fit.measures = TRUE, standardize = TRUE, rsquare = TRUE)
## lavaan 0.6.15 ended normally after 33 iterations
##
## Estimator ML
## Optimization method NLMINB
## Number of model parameters 10
##
## Number of observations 132
##
## Model Test User Model:
##
## Test statistic 38.682
## Degrees of freedom 5
## P-value (Chi-square) 0.000
##
## Model Test Baseline Model:
##
## Test statistic 116.649
## Degrees of freedom 10
## P-value 0.000
##
## User Model versus Baseline Model:
##
## Comparative Fit Index (CFI) 0.684
## Tucker-Lewis Index (TLI) 0.368
##
## Loglikelihood and Information Criteria:
##
## Loglikelihood user model (H0) -1918.755
## Loglikelihood unrestricted model (H1) -1899.414
##
## Akaike (AIC) 3857.509
## Bayesian (BIC) 3886.337
## Sample-size adjusted Bayesian (SABIC) 3854.707
##
## Root Mean Square Error of Approximation:
##
## RMSEA 0.226
## 90 Percent confidence interval - lower 0.163
## 90 Percent confidence interval - upper 0.295
## P-value H_0: RMSEA <= 0.050 0.000
## P-value H_0: RMSEA >= 0.080 1.000
##
## Standardized Root Mean Square Residual:
##
## SRMR 0.106
##
## Parameter Estimates:
##
## Standard errors Standard
## Information Expected
## Information saturated (h1) model Structured
##
## Latent Variables:
## Estimate Std.Err z-value P(>|z|) Std.lv Std.all
## ircfa =~
## comt 1.249 0.270 4.633 0.000 1.249 0.471
## con 1.640 0.332 4.943 0.000 1.640 0.501
## cha 1.276 0.248 5.141 0.000 1.276 0.520
## es 2.958 0.601 4.925 0.000 2.958 0.499
## lo -12.089 1.847 -6.546 0.000 -12.089 -0.666
##
## Variances:
## Estimate Std.Err z-value P(>|z|) Std.lv Std.all
## .comt 5.478 0.783 6.998 0.000 5.478 0.778
## .con 8.028 1.182 6.792 0.000 8.028 0.749
## .cha 4.388 0.661 6.642 0.000 4.388 0.729
## .es 26.376 3.876 6.806 0.000 26.376 0.751
## .lo 182.950 36.974 4.948 0.000 182.950 0.556
## ircfa 1.000 1.000 1.000
##
## R-Square:
## Estimate
## comt 0.222
## con 0.251
## cha 0.271
## es 0.249
## lo 0.444
##
##
modificationIndices(ir_cfa_mod_fit, sort. = TRUE)
## lhs op rhs mi epc sepc.lv sepc.all sepc.nox
## 21 es ~~ lo 8.023 42.666 42.666 0.656 0.656
## 16 con ~~ cha 3.521 -1.088 -1.088 -0.183 -0.183
## 17 con ~~ es 3.331 4.090 4.090 0.309 0.309
## 19 cha ~~ es 2.628 1.662 1.662 0.142 0.142
## 15 comt ~~ lo 1.543 -4.563 -4.563 -0.141 -0.141
## 18 con ~~ lo 1.090 -11.513 -11.513 -0.347 -0.347
## 14 comt ~~ es 0.645 -0.889 -0.889 -0.069 -0.069
## 13 comt ~~ con 0.448 -0.412 -0.412 -0.063 -0.063
## 20 cha ~~ lo 0.202 -1.575 -1.575 -0.054 -0.054
###
##
ir_cfa_mod_syn <-"ircfa =~ comt + con + cha + es + lo
comt ~~ cha
es ~~ lo"
ir_cfa_mod_fit <-cfa(ir_cfa_mod_syn , data=dat, std.lv= TRUE)
## Warning in lav_object_post_check(object): lavaan WARNING: some estimated ov
## variances are negative
ir_cfa_mod_fit
## lavaan 0.6.15 ended normally after 66 iterations
##
## Estimator ML
## Optimization method NLMINB
## Number of model parameters 12
##
## Number of observations 132
##
## Model Test User Model:
##
## Test statistic 1.443
## Degrees of freedom 3
## P-value (Chi-square) 0.695
summary(ir_cfa_mod_fit, fit.measures = TRUE, standardize = TRUE, rsquare = TRUE)
## lavaan 0.6.15 ended normally after 66 iterations
##
## Estimator ML
## Optimization method NLMINB
## Number of model parameters 12
##
## Number of observations 132
##
## Model Test User Model:
##
## Test statistic 1.443
## Degrees of freedom 3
## P-value (Chi-square) 0.695
##
## Model Test Baseline Model:
##
## Test statistic 116.649
## Degrees of freedom 10
## P-value 0.000
##
## User Model versus Baseline Model:
##
## Comparative Fit Index (CFI) 1.000
## Tucker-Lewis Index (TLI) 1.049
##
## Loglikelihood and Information Criteria:
##
## Loglikelihood user model (H0) -1900.135
## Loglikelihood unrestricted model (H1) -1899.414
##
## Akaike (AIC) 3824.271
## Bayesian (BIC) 3858.865
## Sample-size adjusted Bayesian (SABIC) 3820.908
##
## Root Mean Square Error of Approximation:
##
## RMSEA 0.000
## 90 Percent confidence interval - lower 0.000
## 90 Percent confidence interval - upper 0.110
## P-value H_0: RMSEA <= 0.050 0.789
## P-value H_0: RMSEA >= 0.080 0.118
##
## Standardized Root Mean Square Residual:
##
## SRMR 0.017
##
## Parameter Estimates:
##
## Standard errors Standard
## Information Expected
## Information saturated (h1) model Structured
##
## Latent Variables:
## Estimate Std.Err z-value P(>|z|) Std.lv Std.all
## ircfa =~
## comt 0.529 0.280 1.888 0.059 0.529 0.199
## con 1.216 0.526 2.310 0.021 1.216 0.371
## cha 0.631 0.311 2.031 0.042 0.631 0.257
## es 5.810 2.298 2.529 0.011 5.810 0.980
## lo -21.847 8.248 -2.649 0.008 -21.847 -1.204
##
## Covariances:
## Estimate Std.Err z-value P(>|z|) Std.lv Std.all
## .comt ~~
## .cha 3.082 0.647 4.766 0.000 3.082 0.500
## .es ~~
## .lo 93.934 94.326 0.996 0.319 93.934 6.590
##
## Variances:
## Estimate Std.Err z-value P(>|z|) Std.lv Std.all
## .comt 6.760 0.849 7.958 0.000 6.760 0.960
## .con 9.240 1.576 5.864 0.000 9.240 0.862
## .cha 5.619 0.749 7.497 0.000 5.619 0.934
## .es 1.371 26.349 0.052 0.959 1.371 0.039
## .lo -148.205 359.036 -0.413 0.680 -148.205 -0.450
## ircfa 1.000 1.000 1.000
##
## R-Square:
## Estimate
## comt 0.040
## con 0.138
## cha 0.066
## es 0.961
## lo NA
##
#erf
###
erf_cfa_syn <-"erfcfa =~ pro + time +th"
erf_cfa_fit <-cfa(erf_cfa_syn , data=dat, std.lv= TRUE)
erf_cfa_fit
## lavaan 0.6.15 ended normally after 26 iterations
##
## Estimator ML
## Optimization method NLMINB
## Number of model parameters 6
##
## Number of observations 132
##
## Model Test User Model:
##
## Test statistic 0.000
## Degrees of freedom 0
summary(erf_cfa_fit, fit.measures = TRUE, standardize = TRUE, rsquare = TRUE)
## lavaan 0.6.15 ended normally after 26 iterations
##
## Estimator ML
## Optimization method NLMINB
## Number of model parameters 6
##
## Number of observations 132
##
## Model Test User Model:
##
## Test statistic 0.000
## Degrees of freedom 0
##
## Model Test Baseline Model:
##
## Test statistic 12.037
## Degrees of freedom 3
## P-value 0.007
##
## User Model versus Baseline Model:
##
## Comparative Fit Index (CFI) 1.000
## Tucker-Lewis Index (TLI) 1.000
##
## Loglikelihood and Information Criteria:
##
## Loglikelihood user model (H0) -809.204
## Loglikelihood unrestricted model (H1) -809.204
##
## Akaike (AIC) 1630.408
## Bayesian (BIC) 1647.705
## Sample-size adjusted Bayesian (SABIC) 1628.727
##
## Root Mean Square Error of Approximation:
##
## RMSEA 0.000
## 90 Percent confidence interval - lower 0.000
## 90 Percent confidence interval - upper 0.000
## P-value H_0: RMSEA <= 0.050 NA
## P-value H_0: RMSEA >= 0.080 NA
##
## Standardized Root Mean Square Residual:
##
## SRMR 0.000
##
## Parameter Estimates:
##
## Standard errors Standard
## Information Expected
## Information saturated (h1) model Structured
##
## Latent Variables:
## Estimate Std.Err z-value P(>|z|) Std.lv Std.all
## erfcfa =~
## pro 0.414 0.267 1.552 0.121 0.414 0.558
## time 1.286 1.067 1.205 0.228 1.286 0.160
## th -0.567 0.368 -1.540 0.123 -0.567 -0.496
##
## Variances:
## Estimate Std.Err z-value P(>|z|) Std.lv Std.all
## .pro 0.378 0.220 1.717 0.086 0.378 0.688
## .time 63.301 8.064 7.850 0.000 63.301 0.975
## .th 0.982 0.421 2.332 0.020 0.982 0.754
## erfcfa 1.000 1.000 1.000
##
## R-Square:
## Estimate
## pro 0.312
## time 0.025
## th 0.246
####
#cpc =~ em + ind +ru +av +hy +rb
####
cpc_cfa_syn <-"cpccfa =~ pro + time +th"
cpc_cfa_fit <-cfa(cpc_cfa_syn , data=dat, std.lv= TRUE)
cpc_cfa_fit
## lavaan 0.6.15 ended normally after 26 iterations
##
## Estimator ML
## Optimization method NLMINB
## Number of model parameters 6
##
## Number of observations 132
##
## Model Test User Model:
##
## Test statistic 0.000
## Degrees of freedom 0
summary(cpc_cfa_fit, fit.measures = TRUE, standardize = TRUE, rsquare = TRUE)
## lavaan 0.6.15 ended normally after 26 iterations
##
## Estimator ML
## Optimization method NLMINB
## Number of model parameters 6
##
## Number of observations 132
##
## Model Test User Model:
##
## Test statistic 0.000
## Degrees of freedom 0
##
## Model Test Baseline Model:
##
## Test statistic 12.037
## Degrees of freedom 3
## P-value 0.007
##
## User Model versus Baseline Model:
##
## Comparative Fit Index (CFI) 1.000
## Tucker-Lewis Index (TLI) 1.000
##
## Loglikelihood and Information Criteria:
##
## Loglikelihood user model (H0) -809.204
## Loglikelihood unrestricted model (H1) -809.204
##
## Akaike (AIC) 1630.408
## Bayesian (BIC) 1647.705
## Sample-size adjusted Bayesian (SABIC) 1628.727
##
## Root Mean Square Error of Approximation:
##
## RMSEA 0.000
## 90 Percent confidence interval - lower 0.000
## 90 Percent confidence interval - upper 0.000
## P-value H_0: RMSEA <= 0.050 NA
## P-value H_0: RMSEA >= 0.080 NA
##
## Standardized Root Mean Square Residual:
##
## SRMR 0.000
##
## Parameter Estimates:
##
## Standard errors Standard
## Information Expected
## Information saturated (h1) model Structured
##
## Latent Variables:
## Estimate Std.Err z-value P(>|z|) Std.lv Std.all
## cpccfa =~
## pro 0.414 0.267 1.552 0.121 0.414 0.558
## time 1.286 1.067 1.205 0.228 1.286 0.160
## th -0.567 0.368 -1.540 0.123 -0.567 -0.496
##
## Variances:
## Estimate Std.Err z-value P(>|z|) Std.lv Std.all
## .pro 0.378 0.220 1.717 0.086 0.378 0.688
## .time 63.301 8.064 7.850 0.000 63.301 0.975
## .th 0.982 0.421 2.332 0.020 0.982 0.754
## cpccfa 1.000 1.000 1.000
##
## R-Square:
## Estimate
## pro 0.312
## time 0.025
## th 0.246
###########
#ptgi =~ ptgi1 + ptgi2 +ptgi3 +ptgi4 +ptgi5
#####
ptgi_cfa_syn <-"ptgicfa =~ ptgi1 + ptgi2 +ptgi3 +ptgi4 +ptgi5"
ptgi_cfa_fit <-cfa(ptgi_cfa_syn , data=dat, std.lv= TRUE)
ptgi_cfa_fit
## lavaan 0.6.15 ended normally after 16 iterations
##
## Estimator ML
## Optimization method NLMINB
## Number of model parameters 10
##
## Number of observations 132
##
## Model Test User Model:
##
## Test statistic 1.353
## Degrees of freedom 5
## P-value (Chi-square) 0.929
summary(ptgi_cfa_fit, fit.measures = TRUE, standardize = TRUE, rsquare = TRUE)
## lavaan 0.6.15 ended normally after 16 iterations
##
## Estimator ML
## Optimization method NLMINB
## Number of model parameters 10
##
## Number of observations 132
##
## Model Test User Model:
##
## Test statistic 1.353
## Degrees of freedom 5
## P-value (Chi-square) 0.929
##
## Model Test Baseline Model:
##
## Test statistic 409.896
## Degrees of freedom 10
## P-value 0.000
##
## User Model versus Baseline Model:
##
## Comparative Fit Index (CFI) 1.000
## Tucker-Lewis Index (TLI) 1.018
##
## Loglikelihood and Information Criteria:
##
## Loglikelihood user model (H0) -1816.899
## Loglikelihood unrestricted model (H1) -1816.223
##
## Akaike (AIC) 3653.799
## Bayesian (BIC) 3682.627
## Sample-size adjusted Bayesian (SABIC) 3650.996
##
## Root Mean Square Error of Approximation:
##
## RMSEA 0.000
## 90 Percent confidence interval - lower 0.000
## 90 Percent confidence interval - upper 0.036
## P-value H_0: RMSEA <= 0.050 0.964
## P-value H_0: RMSEA >= 0.080 0.012
##
## Standardized Root Mean Square Residual:
##
## SRMR 0.009
##
## Parameter Estimates:
##
## Standard errors Standard
## Information Expected
## Information saturated (h1) model Structured
##
## Latent Variables:
## Estimate Std.Err z-value P(>|z|) Std.lv Std.all
## ptgicfa =~
## ptgi1 7.870 0.637 12.350 0.000 7.870 0.873
## ptgi2 5.950 0.491 12.107 0.000 5.950 0.863
## ptgi3 3.832 0.403 9.513 0.000 3.832 0.733
## ptgi4 2.920 0.280 10.429 0.000 2.920 0.782
## ptgi5 2.451 0.226 10.838 0.000 2.451 0.803
##
## Variances:
## Estimate Std.Err z-value P(>|z|) Std.lv Std.all
## .ptgi1 19.255 3.458 5.568 0.000 19.255 0.237
## .ptgi2 12.179 2.096 5.810 0.000 12.179 0.256
## .ptgi3 12.632 1.749 7.222 0.000 12.632 0.462
## .ptgi4 5.417 0.786 6.893 0.000 5.417 0.388
## .ptgi5 3.317 0.495 6.702 0.000 3.317 0.356
## ptgicfa 1.000 1.000 1.000
##
## R-Square:
## Estimate
## ptgi1 0.763
## ptgi2 0.744
## ptgi3 0.538
## ptgi4 0.612
## ptgi5 0.644
############
#####Part3.4
##########
senolcfa_sem_syntax <- "
# Measurement model
ercfa =~ fa + fr +si
ircfa =~ comt + con + cha + es + lo
erfcfa =~ pro + time +th
cpccfa =~ em + ind +ru +av +hy +rb
ptgicfa =~ ptgi1 + ptgi2 +ptgi3 +ptgi4 +ptgi5
# Structural model
erfcfa ~ ercfa + ircfa
cpccfa ~ erfcfa
ptgicfa ~ ercfa + ircfa +cpccfa
comt ~~ cha
es ~~ lo"
senolcfa_sem_fit <- sem(
senol_sem_syntax,
data = dat, # dataset
std.lv = TRUE # standardize latent variables
)
summary(senol_sem_fit, fit.measures = TRUE, standardize = TRUE, rsquare = TRUE)
## lavaan 0.6.15 ended normally after 54 iterations
##
## Estimator ML
## Optimization method NLMINB
## Number of model parameters 51
##
## Number of observations 132
##
## Model Test User Model:
##
## Test statistic 337.682
## Degrees of freedom 202
## P-value (Chi-square) 0.000
##
## Model Test Baseline Model:
##
## Test statistic 1172.516
## Degrees of freedom 231
## P-value 0.000
##
## User Model versus Baseline Model:
##
## Comparative Fit Index (CFI) 0.856
## Tucker-Lewis Index (TLI) 0.835
##
## Loglikelihood and Information Criteria:
##
## Loglikelihood user model (H0) -8036.650
## Loglikelihood unrestricted model (H1) -7867.809
##
## Akaike (AIC) 16175.301
## Bayesian (BIC) 16322.323
## Sample-size adjusted Bayesian (SABIC) 16161.010
##
## Root Mean Square Error of Approximation:
##
## RMSEA 0.071
## 90 Percent confidence interval - lower 0.058
## 90 Percent confidence interval - upper 0.084
## P-value H_0: RMSEA <= 0.050 0.006
## P-value H_0: RMSEA >= 0.080 0.143
##
## Standardized Root Mean Square Residual:
##
## SRMR 0.104
##
## Parameter Estimates:
##
## Standard errors Standard
## Information Expected
## Information saturated (h1) model Structured
##
## Latent Variables:
## Estimate Std.Err z-value P(>|z|) Std.lv Std.all
## er =~
## fa 1.356 0.367 3.692 0.000 1.356 0.350
## fr 5.683 0.744 7.640 0.000 5.683 0.935
## si 4.580 0.779 5.883 0.000 4.580 0.612
## ir =~
## comt 1.214 0.262 4.638 0.000 1.214 0.458
## con 1.709 0.319 5.354 0.000 1.709 0.522
## cha 1.252 0.240 5.222 0.000 1.252 0.510
## es 2.949 0.581 5.080 0.000 2.949 0.498
## lo -12.019 1.738 -6.915 0.000 -12.019 -0.663
## erf =~
## pro 0.324 0.094 3.440 0.001 0.407 0.549
## time 1.506 0.787 1.912 0.056 1.890 0.235
## th -0.406 0.126 -3.235 0.001 -0.510 -0.447
## cpc =~
## em 4.455 0.946 4.710 0.000 4.753 0.416
## ind -2.435 0.569 -4.276 0.000 -2.597 -0.380
## ru 6.196 0.567 10.936 0.000 6.610 0.879
## av 2.243 0.455 4.925 0.000 2.393 0.434
## hy 5.144 0.447 11.503 0.000 5.488 0.923
## rb 0.148 0.078 1.886 0.059 0.158 0.171
## ptgi =~
## ptgi1 6.705 0.582 11.522 0.000 7.821 0.871
## ptgi2 5.084 0.447 11.371 0.000 5.930 0.863
## ptgi3 3.304 0.357 9.246 0.000 3.854 0.739
## ptgi4 2.500 0.251 9.968 0.000 2.916 0.783
## ptgi5 2.074 0.204 10.166 0.000 2.419 0.794
##
## Regressions:
## Estimate Std.Err z-value P(>|z|) Std.lv Std.all
## erf ~
## er -0.254 0.191 -1.330 0.183 -0.202 -0.202
## ir 0.790 0.288 2.742 0.006 0.629 0.629
## cpc ~
## erf -0.296 0.123 -2.415 0.016 -0.348 -0.348
## ptgi ~
## er 0.234 0.113 2.072 0.038 0.200 0.200
## ir 0.276 0.130 2.132 0.033 0.237 0.237
## cpc 0.465 0.109 4.256 0.000 0.425 0.425
##
## Covariances:
## Estimate Std.Err z-value P(>|z|) Std.lv Std.all
## er ~~
## ir 0.280 0.109 2.573 0.010 0.280 0.280
##
## Variances:
## Estimate Std.Err z-value P(>|z|) Std.lv Std.all
## .fa 13.173 1.684 7.822 0.000 13.173 0.877
## .fr 4.636 7.174 0.646 0.518 4.636 0.126
## .si 35.107 6.368 5.513 0.000 35.107 0.626
## .comt 5.565 0.769 7.235 0.000 5.565 0.791
## .con 7.796 1.137 6.857 0.000 7.796 0.727
## .cha 4.449 0.642 6.935 0.000 4.449 0.740
## .es 26.430 3.768 7.014 0.000 26.430 0.752
## .lo 184.659 33.730 5.475 0.000 184.659 0.561
## .pro 0.383 0.077 4.977 0.000 0.383 0.699
## .time 61.380 7.952 7.719 0.000 61.380 0.945
## .th 1.042 0.165 6.310 0.000 1.042 0.800
## .em 107.905 13.571 7.951 0.000 107.905 0.827
## .ind 40.012 5.011 7.985 0.000 40.012 0.856
## .ru 12.839 3.266 3.930 0.000 12.839 0.227
## .av 24.704 3.115 7.932 0.000 24.704 0.812
## .hy 5.253 2.062 2.548 0.011 5.253 0.149
## .rb 0.824 0.102 8.100 0.000 0.824 0.971
## .ptgi1 19.484 3.432 5.677 0.000 19.484 0.242
## .ptgi2 12.106 2.067 5.857 0.000 12.106 0.256
## .ptgi3 12.332 1.712 7.205 0.000 12.332 0.454
## .ptgi4 5.370 0.777 6.908 0.000 5.370 0.387
## .ptgi5 3.420 0.502 6.807 0.000 3.420 0.369
## er 1.000 1.000 1.000
## ir 1.000 1.000 1.000
## .erf 1.000 0.634 0.634
## .cpc 1.000 0.879 0.879
## .ptgi 1.000 0.735 0.735
##
## R-Square:
## Estimate
## fa 0.123
## fr 0.874
## si 0.374
## comt 0.209
## con 0.273
## cha 0.260
## es 0.248
## lo 0.439
## pro 0.301
## time 0.055
## th 0.200
## em 0.173
## ind 0.144
## ru 0.773
## av 0.188
## hy 0.851
## rb 0.029
## ptgi1 0.758
## ptgi2 0.744
## ptgi3 0.546
## ptgi4 0.613
## ptgi5 0.631
## erf 0.366
## cpc 0.121
## ptgi 0.265
#######
The model in 2. will have poor fit. Break this model down into the constituent unidimensional factor models. Steps:
Fit each constituent unidimensional factor model separately using a CFA. Start with the factors with fewer items.
Some of these models will have completely perfect fit (Chi^2 p-value = 1).
What do these models share in common? How many parameters? How many unique elements in variance-covariance matrix?
Models (er, erf , cpc ) have perfect fit(Chi^2 p-value = 1), CFI & TLI= 1
they have in common:
6 parameters , and 6 unique elements in variance-covariance matrix
Other models will not have less than perfect fit.
Which of these models have acceptable fit?
ptgi has acceptable fit
Use modification indices to improve the fit of these models individually.
Read the paper to check whether each modification makes sense on face-value. If you had subject-matter expertise, you could judge the adequacy of these
modifications yourselves.
#ir
##
ir_cfa_syn <-"ircfa =~ comt + con + cha + es + lo"
ir_cfa_fit <-cfa(ir_cfa_syn , data=dat, std.lv= TRUE)
ir_cfa_fit
## lavaan 0.6.15 ended normally after 33 iterations
##
## Estimator ML
## Optimization method NLMINB
## Number of model parameters 10
##
## Number of observations 132
##
## Model Test User Model:
##
## Test statistic 38.682
## Degrees of freedom 5
## P-value (Chi-square) 0.000
summary(ir_cfa_fit, fit.measures = TRUE, standardize = TRUE, rsquare = TRUE)
## lavaan 0.6.15 ended normally after 33 iterations
##
## Estimator ML
## Optimization method NLMINB
## Number of model parameters 10
##
## Number of observations 132
##
## Model Test User Model:
##
## Test statistic 38.682
## Degrees of freedom 5
## P-value (Chi-square) 0.000
##
## Model Test Baseline Model:
##
## Test statistic 116.649
## Degrees of freedom 10
## P-value 0.000
##
## User Model versus Baseline Model:
##
## Comparative Fit Index (CFI) 0.684
## Tucker-Lewis Index (TLI) 0.368
##
## Loglikelihood and Information Criteria:
##
## Loglikelihood user model (H0) -1918.755
## Loglikelihood unrestricted model (H1) -1899.414
##
## Akaike (AIC) 3857.509
## Bayesian (BIC) 3886.337
## Sample-size adjusted Bayesian (SABIC) 3854.707
##
## Root Mean Square Error of Approximation:
##
## RMSEA 0.226
## 90 Percent confidence interval - lower 0.163
## 90 Percent confidence interval - upper 0.295
## P-value H_0: RMSEA <= 0.050 0.000
## P-value H_0: RMSEA >= 0.080 1.000
##
## Standardized Root Mean Square Residual:
##
## SRMR 0.106
##
## Parameter Estimates:
##
## Standard errors Standard
## Information Expected
## Information saturated (h1) model Structured
##
## Latent Variables:
## Estimate Std.Err z-value P(>|z|) Std.lv Std.all
## ircfa =~
## comt 1.249 0.270 4.633 0.000 1.249 0.471
## con 1.640 0.332 4.943 0.000 1.640 0.501
## cha 1.276 0.248 5.141 0.000 1.276 0.520
## es 2.958 0.601 4.925 0.000 2.958 0.499
## lo -12.089 1.847 -6.546 0.000 -12.089 -0.666
##
## Variances:
## Estimate Std.Err z-value P(>|z|) Std.lv Std.all
## .comt 5.478 0.783 6.998 0.000 5.478 0.778
## .con 8.028 1.182 6.792 0.000 8.028 0.749
## .cha 4.388 0.661 6.642 0.000 4.388 0.729
## .es 26.376 3.876 6.806 0.000 26.376 0.751
## .lo 182.950 36.974 4.948 0.000 182.950 0.556
## ircfa 1.000 1.000 1.000
##
## R-Square:
## Estimate
## comt 0.222
## con 0.251
## cha 0.271
## es 0.249
## lo 0.444
##
modificationIndices(ir_cfa_fit, sort. = TRUE)
## lhs op rhs mi epc sepc.lv sepc.all sepc.nox
## 13 comt ~~ cha 29.738 2.975 2.975 0.607 0.607
## 16 con ~~ cha 12.392 -2.401 -2.401 -0.404 -0.404
## 18 con ~~ lo 11.776 -19.751 -19.751 -0.515 -0.515
## 12 comt ~~ con 7.657 -2.001 -2.001 -0.302 -0.302
## 17 con ~~ es 5.264 3.743 3.743 0.257 0.257
## 14 comt ~~ es 2.646 -2.128 -2.128 -0.177 -0.177
## 20 cha ~~ lo 2.587 7.112 7.112 0.251 0.251
## 15 comt ~~ lo 1.095 4.719 4.719 0.149 0.149
## 21 es ~~ lo 0.618 8.175 8.175 0.118 0.118
## 19 cha ~~ es 0.024 0.192 0.192 0.018 0.018
###
##
ir_cfa_mod_syn <-"ircfa =~ comt + con + cha + es + lo
comt ~~ cha "
ir_cfa_mod_fit <-cfa(ir_cfa_mod_syn , data=dat, std.lv= TRUE)
ir_cfa_mod_fit
## lavaan 0.6.15 ended normally after 39 iterations
##
## Estimator ML
## Optimization method NLMINB
## Number of model parameters 11
##
## Number of observations 132
##
## Model Test User Model:
##
## Test statistic 10.463
## Degrees of freedom 4
## P-value (Chi-square) 0.033
summary(ir_cfa_fit, fit.measures = TRUE, standardize = TRUE, rsquare = TRUE)
## lavaan 0.6.15 ended normally after 33 iterations
##
## Estimator ML
## Optimization method NLMINB
## Number of model parameters 10
##
## Number of observations 132
##
## Model Test User Model:
##
## Test statistic 38.682
## Degrees of freedom 5
## P-value (Chi-square) 0.000
##
## Model Test Baseline Model:
##
## Test statistic 116.649
## Degrees of freedom 10
## P-value 0.000
##
## User Model versus Baseline Model:
##
## Comparative Fit Index (CFI) 0.684
## Tucker-Lewis Index (TLI) 0.368
##
## Loglikelihood and Information Criteria:
##
## Loglikelihood user model (H0) -1918.755
## Loglikelihood unrestricted model (H1) -1899.414
##
## Akaike (AIC) 3857.509
## Bayesian (BIC) 3886.337
## Sample-size adjusted Bayesian (SABIC) 3854.707
##
## Root Mean Square Error of Approximation:
##
## RMSEA 0.226
## 90 Percent confidence interval - lower 0.163
## 90 Percent confidence interval - upper 0.295
## P-value H_0: RMSEA <= 0.050 0.000
## P-value H_0: RMSEA >= 0.080 1.000
##
## Standardized Root Mean Square Residual:
##
## SRMR 0.106
##
## Parameter Estimates:
##
## Standard errors Standard
## Information Expected
## Information saturated (h1) model Structured
##
## Latent Variables:
## Estimate Std.Err z-value P(>|z|) Std.lv Std.all
## ircfa =~
## comt 1.249 0.270 4.633 0.000 1.249 0.471
## con 1.640 0.332 4.943 0.000 1.640 0.501
## cha 1.276 0.248 5.141 0.000 1.276 0.520
## es 2.958 0.601 4.925 0.000 2.958 0.499
## lo -12.089 1.847 -6.546 0.000 -12.089 -0.666
##
## Variances:
## Estimate Std.Err z-value P(>|z|) Std.lv Std.all
## .comt 5.478 0.783 6.998 0.000 5.478 0.778
## .con 8.028 1.182 6.792 0.000 8.028 0.749
## .cha 4.388 0.661 6.642 0.000 4.388 0.729
## .es 26.376 3.876 6.806 0.000 26.376 0.751
## .lo 182.950 36.974 4.948 0.000 182.950 0.556
## ircfa 1.000 1.000 1.000
##
## R-Square:
## Estimate
## comt 0.222
## con 0.251
## cha 0.271
## es 0.249
## lo 0.444
##
##
modificationIndices(ir_cfa_mod_fit, sort. = TRUE)
## lhs op rhs mi epc sepc.lv sepc.all sepc.nox
## 21 es ~~ lo 8.023 42.666 42.666 0.656 0.656
## 16 con ~~ cha 3.521 -1.088 -1.088 -0.183 -0.183
## 17 con ~~ es 3.331 4.090 4.090 0.309 0.309
## 19 cha ~~ es 2.628 1.662 1.662 0.142 0.142
## 15 comt ~~ lo 1.543 -4.563 -4.563 -0.141 -0.141
## 18 con ~~ lo 1.090 -11.513 -11.513 -0.347 -0.347
## 14 comt ~~ es 0.645 -0.889 -0.889 -0.069 -0.069
## 13 comt ~~ con 0.448 -0.412 -0.412 -0.063 -0.063
## 20 cha ~~ lo 0.202 -1.575 -1.575 -0.054 -0.054
###
##
ir_cfa_mod_syn <-"ircfa =~ comt + con + cha + es + lo
comt ~~ cha
es ~~ lo"
ir_cfa_mod_fit <-cfa(ir_cfa_mod_syn , data=dat, std.lv= TRUE)
## Warning in lav_object_post_check(object): lavaan WARNING: some estimated ov
## variances are negative
ir_cfa_mod_fit
## lavaan 0.6.15 ended normally after 66 iterations
##
## Estimator ML
## Optimization method NLMINB
## Number of model parameters 12
##
## Number of observations 132
##
## Model Test User Model:
##
## Test statistic 1.443
## Degrees of freedom 3
## P-value (Chi-square) 0.695
summary(ir_cfa_mod_fit, fit.measures = TRUE, standardize = TRUE, rsquare = TRUE)
## lavaan 0.6.15 ended normally after 66 iterations
##
## Estimator ML
## Optimization method NLMINB
## Number of model parameters 12
##
## Number of observations 132
##
## Model Test User Model:
##
## Test statistic 1.443
## Degrees of freedom 3
## P-value (Chi-square) 0.695
##
## Model Test Baseline Model:
##
## Test statistic 116.649
## Degrees of freedom 10
## P-value 0.000
##
## User Model versus Baseline Model:
##
## Comparative Fit Index (CFI) 1.000
## Tucker-Lewis Index (TLI) 1.049
##
## Loglikelihood and Information Criteria:
##
## Loglikelihood user model (H0) -1900.135
## Loglikelihood unrestricted model (H1) -1899.414
##
## Akaike (AIC) 3824.271
## Bayesian (BIC) 3858.865
## Sample-size adjusted Bayesian (SABIC) 3820.908
##
## Root Mean Square Error of Approximation:
##
## RMSEA 0.000
## 90 Percent confidence interval - lower 0.000
## 90 Percent confidence interval - upper 0.110
## P-value H_0: RMSEA <= 0.050 0.789
## P-value H_0: RMSEA >= 0.080 0.118
##
## Standardized Root Mean Square Residual:
##
## SRMR 0.017
##
## Parameter Estimates:
##
## Standard errors Standard
## Information Expected
## Information saturated (h1) model Structured
##
## Latent Variables:
## Estimate Std.Err z-value P(>|z|) Std.lv Std.all
## ircfa =~
## comt 0.529 0.280 1.888 0.059 0.529 0.199
## con 1.216 0.526 2.310 0.021 1.216 0.371
## cha 0.631 0.311 2.031 0.042 0.631 0.257
## es 5.810 2.298 2.529 0.011 5.810 0.980
## lo -21.847 8.248 -2.649 0.008 -21.847 -1.204
##
## Covariances:
## Estimate Std.Err z-value P(>|z|) Std.lv Std.all
## .comt ~~
## .cha 3.082 0.647 4.766 0.000 3.082 0.500
## .es ~~
## .lo 93.934 94.326 0.996 0.319 93.934 6.590
##
## Variances:
## Estimate Std.Err z-value P(>|z|) Std.lv Std.all
## .comt 6.760 0.849 7.958 0.000 6.760 0.960
## .con 9.240 1.576 5.864 0.000 9.240 0.862
## .cha 5.619 0.749 7.497 0.000 5.619 0.934
## .es 1.371 26.349 0.052 0.959 1.371 0.039
## .lo -148.205 359.036 -0.413 0.680 -148.205 -0.450
## ircfa 1.000 1.000 1.000
##
## R-Square:
## Estimate
## comt 0.040
## con 0.138
## cha 0.066
## es 0.961
## lo NA
##
Fit the overall SEM including the modifications made to the individual components.
Assess the resulting model for misspecification using global fit indices.
2.Make final changes to the model if you wish.
3.Compare this final model to the path analysis results using:
1.standardized regression coefficients – how similar/different are they? Regressions:
Estimate Std.Err z-value P(>|z|) Std.lv Std.all
erf ~
er -0.254 0.191 -1.330 0.183 -0.202 -0.202
ir 0.790 0.288 2.742 0.006 0.629 0.629
cpc ~
erf -0.296 0.123 -2.415 0.016 -0.348 -0.348
ptgi ~
er 0.234 0.113 2.072 0.038 0.200 0.200
ir 0.276 0.130 2.132 0.033 0.237 0.237
cpc 0.465 0.109 4.256 0.000 0.425 0.425
2.Patterns of statistical significance.
3.R-square for outcome variables – how similar/different are they? they are similar to each result of r-square in path analysis.it is like combining the r-square in one table.
Estimate
fa 0.123
fr 0.874
si 0.374
comt 0.209
con 0.273
cha 0.260
es 0.248
lo 0.439
pro 0.301
time 0.055
th 0.200
em 0.173
ind 0.144
ru 0.773
av 0.188
hy 0.851
rb 0.029
ptgi1 0.758
ptgi2 0.744
ptgi3 0.546
ptgi4 0.613
ptgi5 0.631
erf 0.366
cpc 0.121
ptgi 0.265
############
#####Part4
##########
senolcfa_sem_syntax <- "
# Measurement model
ercfa =~ fa + fr +si
ircfa =~ comt + con + cha + es + lo
erfcfa =~ pro + time +th
cpccfa =~ em + ind +ru +av +hy +rb
ptgicfa =~ ptgi1 + ptgi2 +ptgi3 +ptgi4 +ptgi5
# Structural model
erfcfa ~ ercfa + ircfa
cpccfa ~ erfcfa
ptgicfa ~ ercfa + ircfa +cpccfa
comt ~~ cha
es ~~ lo"
senolcfa_sem_fit <- sem(
senol_sem_syntax,
data = dat, # dataset
std.lv = TRUE # standardize latent variables
)
summary(senol_sem_fit, fit.measures = TRUE, standardize = TRUE, rsquare = TRUE)
## lavaan 0.6.15 ended normally after 54 iterations
##
## Estimator ML
## Optimization method NLMINB
## Number of model parameters 51
##
## Number of observations 132
##
## Model Test User Model:
##
## Test statistic 337.682
## Degrees of freedom 202
## P-value (Chi-square) 0.000
##
## Model Test Baseline Model:
##
## Test statistic 1172.516
## Degrees of freedom 231
## P-value 0.000
##
## User Model versus Baseline Model:
##
## Comparative Fit Index (CFI) 0.856
## Tucker-Lewis Index (TLI) 0.835
##
## Loglikelihood and Information Criteria:
##
## Loglikelihood user model (H0) -8036.650
## Loglikelihood unrestricted model (H1) -7867.809
##
## Akaike (AIC) 16175.301
## Bayesian (BIC) 16322.323
## Sample-size adjusted Bayesian (SABIC) 16161.010
##
## Root Mean Square Error of Approximation:
##
## RMSEA 0.071
## 90 Percent confidence interval - lower 0.058
## 90 Percent confidence interval - upper 0.084
## P-value H_0: RMSEA <= 0.050 0.006
## P-value H_0: RMSEA >= 0.080 0.143
##
## Standardized Root Mean Square Residual:
##
## SRMR 0.104
##
## Parameter Estimates:
##
## Standard errors Standard
## Information Expected
## Information saturated (h1) model Structured
##
## Latent Variables:
## Estimate Std.Err z-value P(>|z|) Std.lv Std.all
## er =~
## fa 1.356 0.367 3.692 0.000 1.356 0.350
## fr 5.683 0.744 7.640 0.000 5.683 0.935
## si 4.580 0.779 5.883 0.000 4.580 0.612
## ir =~
## comt 1.214 0.262 4.638 0.000 1.214 0.458
## con 1.709 0.319 5.354 0.000 1.709 0.522
## cha 1.252 0.240 5.222 0.000 1.252 0.510
## es 2.949 0.581 5.080 0.000 2.949 0.498
## lo -12.019 1.738 -6.915 0.000 -12.019 -0.663
## erf =~
## pro 0.324 0.094 3.440 0.001 0.407 0.549
## time 1.506 0.787 1.912 0.056 1.890 0.235
## th -0.406 0.126 -3.235 0.001 -0.510 -0.447
## cpc =~
## em 4.455 0.946 4.710 0.000 4.753 0.416
## ind -2.435 0.569 -4.276 0.000 -2.597 -0.380
## ru 6.196 0.567 10.936 0.000 6.610 0.879
## av 2.243 0.455 4.925 0.000 2.393 0.434
## hy 5.144 0.447 11.503 0.000 5.488 0.923
## rb 0.148 0.078 1.886 0.059 0.158 0.171
## ptgi =~
## ptgi1 6.705 0.582 11.522 0.000 7.821 0.871
## ptgi2 5.084 0.447 11.371 0.000 5.930 0.863
## ptgi3 3.304 0.357 9.246 0.000 3.854 0.739
## ptgi4 2.500 0.251 9.968 0.000 2.916 0.783
## ptgi5 2.074 0.204 10.166 0.000 2.419 0.794
##
## Regressions:
## Estimate Std.Err z-value P(>|z|) Std.lv Std.all
## erf ~
## er -0.254 0.191 -1.330 0.183 -0.202 -0.202
## ir 0.790 0.288 2.742 0.006 0.629 0.629
## cpc ~
## erf -0.296 0.123 -2.415 0.016 -0.348 -0.348
## ptgi ~
## er 0.234 0.113 2.072 0.038 0.200 0.200
## ir 0.276 0.130 2.132 0.033 0.237 0.237
## cpc 0.465 0.109 4.256 0.000 0.425 0.425
##
## Covariances:
## Estimate Std.Err z-value P(>|z|) Std.lv Std.all
## er ~~
## ir 0.280 0.109 2.573 0.010 0.280 0.280
##
## Variances:
## Estimate Std.Err z-value P(>|z|) Std.lv Std.all
## .fa 13.173 1.684 7.822 0.000 13.173 0.877
## .fr 4.636 7.174 0.646 0.518 4.636 0.126
## .si 35.107 6.368 5.513 0.000 35.107 0.626
## .comt 5.565 0.769 7.235 0.000 5.565 0.791
## .con 7.796 1.137 6.857 0.000 7.796 0.727
## .cha 4.449 0.642 6.935 0.000 4.449 0.740
## .es 26.430 3.768 7.014 0.000 26.430 0.752
## .lo 184.659 33.730 5.475 0.000 184.659 0.561
## .pro 0.383 0.077 4.977 0.000 0.383 0.699
## .time 61.380 7.952 7.719 0.000 61.380 0.945
## .th 1.042 0.165 6.310 0.000 1.042 0.800
## .em 107.905 13.571 7.951 0.000 107.905 0.827
## .ind 40.012 5.011 7.985 0.000 40.012 0.856
## .ru 12.839 3.266 3.930 0.000 12.839 0.227
## .av 24.704 3.115 7.932 0.000 24.704 0.812
## .hy 5.253 2.062 2.548 0.011 5.253 0.149
## .rb 0.824 0.102 8.100 0.000 0.824 0.971
## .ptgi1 19.484 3.432 5.677 0.000 19.484 0.242
## .ptgi2 12.106 2.067 5.857 0.000 12.106 0.256
## .ptgi3 12.332 1.712 7.205 0.000 12.332 0.454
## .ptgi4 5.370 0.777 6.908 0.000 5.370 0.387
## .ptgi5 3.420 0.502 6.807 0.000 3.420 0.369
## er 1.000 1.000 1.000
## ir 1.000 1.000 1.000
## .erf 1.000 0.634 0.634
## .cpc 1.000 0.879 0.879
## .ptgi 1.000 0.735 0.735
##
## R-Square:
## Estimate
## fa 0.123
## fr 0.874
## si 0.374
## comt 0.209
## con 0.273
## cha 0.260
## es 0.248
## lo 0.439
## pro 0.301
## time 0.055
## th 0.200
## em 0.173
## ind 0.144
## ru 0.773
## av 0.188
## hy 0.851
## rb 0.029
## ptgi1 0.758
## ptgi2 0.744
## ptgi3 0.546
## ptgi4 0.613
## ptgi5 0.631
## erf 0.366
## cpc 0.121
## ptgi 0.265
#######
###
#######
5.Conclude with final thoughts about the modelling exercise.
General approach is to hope that the model will pass as much as possible of the conventional
cut-off criteria,
We can stop this the modification cycle once we have
good/acceptable model-data fit using global fit indices.
Recomendation:to continue until you address all misspecifications.
Addressing a misspecification does not mean you change the model.