#knitr::opts_chunk$set(echo = TRUE)
library(readxl)
library(lavaan)
## This is lavaan 0.6-17
## lavaan is FREE software! Please report any bugs.
library(psych)
## 
## Attaching package: 'psych'
## The following object is masked from 'package:lavaan':
## 
##     cor2cov
library(ggplot2)
## 
## Attaching package: 'ggplot2'
## The following objects are masked from 'package:psych':
## 
##     %+%, alpha
library(MVN)
library(semPlot)
library(semTools)
## 
## ###############################################################################
## This is semTools 0.5-6
## All users of R (or SEM) are invited to submit functions or ideas for functions.
## ###############################################################################
## 
## Attaching package: 'semTools'
## The following objects are masked from 'package:psych':
## 
##     reliability, skew
library(GPArotation)
## 
## Attaching package: 'GPArotation'
## The following objects are masked from 'package:psych':
## 
##     equamax, varimin
sem <- read_excel("C:/Users/USER/Desktop/sem/plsem/sem.xlsx")
head(sem)

explore the data

structural model

subsetn<-data.frame(subset(sem,select = c(BT1,BT2,BT3,BT4,BT5,BT6,BT7,BD1,BD2,BD3,BD4,EMP1,EMP2,EMP3,EMP4,EMP5,CS1,CS2,CS3,EP1,EP2,EP3,EP4,LS1,LS2,LS3,LS4,LS5)))

normality test

mnormal<-mvn(subsetn)
mnormal
## $multivariateNormality
##            Test       HZ p value MVN
## 1 Henze-Zirkler 1.026133       0  NO
## 
## $univariateNormality
##                Test  Variable Statistic   p value Normality
## 1  Anderson-Darling    BT1       7.2262  <0.001      NO    
## 2  Anderson-Darling    BT2       8.0671  <0.001      NO    
## 3  Anderson-Darling    BT3       6.6800  <0.001      NO    
## 4  Anderson-Darling    BT4       6.4183  <0.001      NO    
## 5  Anderson-Darling    BT5       6.1728  <0.001      NO    
## 6  Anderson-Darling    BT6       8.6698  <0.001      NO    
## 7  Anderson-Darling    BT7       7.5770  <0.001      NO    
## 8  Anderson-Darling    BD1       5.9732  <0.001      NO    
## 9  Anderson-Darling    BD2       8.7052  <0.001      NO    
## 10 Anderson-Darling    BD3       5.9169  <0.001      NO    
## 11 Anderson-Darling    BD4       6.8989  <0.001      NO    
## 12 Anderson-Darling   EMP1       5.2108  <0.001      NO    
## 13 Anderson-Darling   EMP2       6.4303  <0.001      NO    
## 14 Anderson-Darling   EMP3       4.7131  <0.001      NO    
## 15 Anderson-Darling   EMP4       7.8380  <0.001      NO    
## 16 Anderson-Darling   EMP5       5.5762  <0.001      NO    
## 17 Anderson-Darling    CS1       6.9341  <0.001      NO    
## 18 Anderson-Darling    CS2       7.1469  <0.001      NO    
## 19 Anderson-Darling    CS3       6.2791  <0.001      NO    
## 20 Anderson-Darling    EP1       7.5913  <0.001      NO    
## 21 Anderson-Darling    EP2       7.3530  <0.001      NO    
## 22 Anderson-Darling    EP3       7.2375  <0.001      NO    
## 23 Anderson-Darling    EP4       6.5793  <0.001      NO    
## 24 Anderson-Darling    LS1       9.0564  <0.001      NO    
## 25 Anderson-Darling    LS2       8.2974  <0.001      NO    
## 26 Anderson-Darling    LS3       8.5914  <0.001      NO    
## 27 Anderson-Darling    LS4       6.9281  <0.001      NO    
## 28 Anderson-Darling    LS5       5.8779  <0.001      NO    
## 
## $Descriptives
##        n     Mean  Std.Dev Median Min Max 25th 75th        Skew    Kurtosis
## BT1  272 4.897059 1.307257      5   1   7    4 6.00 -0.41254431 -0.14823904
## BT2  272 4.871324 1.342598      5   1   7    4 6.00 -0.54057483 -0.13821529
## BT3  272 4.540441 1.550568      5   1   7    3 6.00 -0.24685876 -0.87882781
## BT4  272 4.757353 1.371811      5   1   7    4 6.00 -0.17498923 -0.57321521
## BT5  272 4.547794 1.416011      4   1   7    4 6.00 -0.10448505 -0.57213063
## BT6  272 5.150735 1.435990      5   1   7    4 6.00 -0.54708461 -0.43868563
## BT7  272 5.117647 1.500597      5   1   7    4 6.00 -0.62433083 -0.17711402
## BD1  272 4.588235 1.505074      5   1   7    4 6.00 -0.40835281 -0.38347131
## BD2  272 5.113971 1.418729      5   1   7    4 6.00 -0.64102981 -0.21095215
## BD3  272 4.514706 1.487886      5   1   7    3 6.00 -0.22263689 -0.68504836
## BD4  272 4.654412 1.341248      5   1   7    4 6.00 -0.11478964 -0.35230370
## EMP1 272 4.246324 1.628275      4   1   7    3 6.00 -0.24527887 -0.74671013
## EMP2 272 4.647059 1.447886      5   1   7    4 6.00 -0.41969844 -0.33308646
## EMP3 272 4.069853 1.687454      4   1   7    3 5.00 -0.05417392 -0.88787302
## EMP4 272 3.966912 1.345626      4   1   7    3 5.00 -0.18450837 -0.17021913
## EMP5 272 4.334559 1.476201      4   1   7    3 5.00 -0.20104328 -0.56563007
## CS1  272 4.448529 1.335410      4   1   7    4 5.00 -0.17728686 -0.06634707
## CS2  272 4.415441 1.300092      4   1   7    4 5.00 -0.17631873 -0.05861883
## CS3  272 4.426471 1.427884      4   1   7    4 5.25 -0.28794302 -0.24502398
## EP1  272 5.183824 1.388951      5   1   7    4 6.00 -0.43631709 -0.51113542
## EP2  272 5.106618 1.369014      5   2   7    4 6.00 -0.27766985 -0.78219332
## EP3  272 5.091912 1.388809      5   1   7    4 6.00 -0.33672045 -0.53268446
## EP4  272 4.988971 1.441308      5   1   7    4 6.00 -0.32707653 -0.53720876
## LS1  272 4.738971 1.239669      5   1   7    4 6.00 -0.60988129  0.29634604
## LS2  272 4.974265 1.249088      5   1   7    4 6.00 -0.48360113  0.04311961
## LS3  272 5.297794 1.309740      5   2   7    4 6.00 -0.54899072 -0.32742495
## LS4  272 4.941176 1.461762      5   1   7    4 6.00 -0.49879110 -0.37148784
## LS5  272 4.639706 1.554296      5   1   7    4 6.00 -0.38345201 -0.56146435

correlation matrix

cmat<-round(cor(subsetn),2)
cmat[upper.tri(cmat)]<-""
cmat<-as.data.frame(cmat)
cmat

number of factors

parallel<-fa.parallel(subsetn,fm="ml",fa="fa")

## Parallel analysis suggests that the number of factors =  7  and the number of components =  NA
parallel$fa.values
##  [1]  9.110306807  2.208726061  1.491265413  1.309686468  0.768926591
##  [6]  0.526673413  0.314718465 -0.007758516 -0.052360241 -0.059610721
## [11] -0.091891890 -0.179201766 -0.228243066 -0.242869845 -0.263162154
## [16] -0.298329457 -0.307033491 -0.317601216 -0.329593839 -0.350375636
## [21] -0.372287692 -0.381583472 -0.413413631 -0.449660305 -0.504054385
## [26] -0.543895350 -0.589671435 -0.681460711
sixfactor=fa(subsetn,nfactors = 6,rotate = "oblimin",fm="ml")
summary(sixfactor)
## 
## Factor analysis with Call: fa(r = subsetn, nfactors = 6, rotate = "oblimin", fm = "ml")
## 
## Test of the hypothesis that 6 factors are sufficient.
## The degrees of freedom for the model is 225  and the objective function was  1.51 
## The number of observations was  272  with Chi Square =  388.76  with prob <  7.2e-11 
## 
## The root mean square of the residuals (RMSA) is  0.03 
## The df corrected root mean square of the residuals is  0.04 
## 
## Tucker Lewis Index of factoring reliability =  0.939
## RMSEA index =  0.052  and the 10 % confidence intervals are  0.043 0.06
## BIC =  -872.55
##  With factor correlations of 
##      ML3  ML1  ML6  ML2  ML4  ML5
## ML3 1.00 0.27 0.29 0.28 0.23 0.19
## ML1 0.27 1.00 0.43 0.46 0.37 0.31
## ML6 0.29 0.43 1.00 0.48 0.56 0.29
## ML2 0.28 0.46 0.48 1.00 0.51 0.49
## ML4 0.23 0.37 0.56 0.51 1.00 0.48
## ML5 0.19 0.31 0.29 0.49 0.48 1.00
print(sixfactor,cut=.3,digits = 3,sort=T)
## Factor Analysis using method =  ml
## Call: fa(r = subsetn, nfactors = 6, rotate = "oblimin", fm = "ml")
## Standardized loadings (pattern matrix) based upon correlation matrix
##      item    ML3    ML1    ML6    ML2    ML4    ML5    h2     u2  com
## LS2    25  0.927                                    0.857 0.1430 1.01
## LS1    24  0.850                                    0.732 0.2675 1.01
## LS3    26  0.836                                    0.740 0.2601 1.06
## LS4    27  0.809                                    0.653 0.3471 1.04
## LS5    28  0.580                                    0.365 0.6354 1.04
## EP2    21         0.960                             0.957 0.0433 1.01
## EP1    20         0.949                             0.845 0.1545 1.01
## EP4    23         0.707                             0.622 0.3777 1.06
## EP3    22         0.657                             0.638 0.3617 1.21
## BT5     5                0.721                      0.545 0.4551 1.08
## BT1     1                0.697                      0.517 0.4830 1.03
## BT2     2                0.678                      0.515 0.4855 1.06
## BT6     6                0.586                      0.482 0.5183 1.08
## BT7     7                0.527                      0.479 0.5214 1.36
## BT4     4                0.493                      0.460 0.5399 1.41
## BT3     3                0.444                      0.336 0.6636 1.71
## CS2    18                       0.940               0.915 0.0853 1.00
## CS3    19                       0.887               0.797 0.2033 1.01
## CS1    17                       0.882               0.826 0.1741 1.01
## BD1     8                              0.792        0.623 0.3766 1.02
## BD3    10                              0.766        0.643 0.3570 1.01
## BD2     9                              0.676        0.578 0.4215 1.11
## BD4    11                              0.652        0.577 0.4225 1.07
## EMP1   12                                     0.722 0.534 0.4658 1.03
## EMP4   15                                     0.698 0.580 0.4203 1.10
## EMP3   14                                     0.686 0.435 0.5653 1.03
## EMP2   13                                     0.637 0.555 0.4455 1.16
## EMP5   16                                     0.411 0.483 0.5173 1.99
## 
##                         ML3   ML1   ML6   ML2   ML4   ML5
## SS loadings           3.409 3.123 2.989 2.816 2.624 2.327
## Proportion Var        0.122 0.112 0.107 0.101 0.094 0.083
## Cumulative Var        0.122 0.233 0.340 0.441 0.534 0.617
## Proportion Explained  0.197 0.181 0.173 0.163 0.152 0.135
## Cumulative Proportion 0.197 0.378 0.551 0.714 0.865 1.000
## 
##  With factor correlations of 
##       ML3   ML1   ML6   ML2   ML4   ML5
## ML3 1.000 0.272 0.289 0.279 0.234 0.186
## ML1 0.272 1.000 0.433 0.458 0.370 0.308
## ML6 0.289 0.433 1.000 0.480 0.561 0.291
## ML2 0.279 0.458 0.480 1.000 0.514 0.491
## ML4 0.234 0.370 0.561 0.514 1.000 0.482
## ML5 0.186 0.308 0.291 0.491 0.482 1.000
## 
## Mean item complexity =  1.1
## Test of the hypothesis that 6 factors are sufficient.
## 
## df null model =  378  with the objective function =  19.082 with Chi Square =  4977.246
## df of  the model are 225  and the objective function was  1.514 
## 
## The root mean square of the residuals (RMSR) is  0.029 
## The df corrected root mean square of the residuals is  0.037 
## 
## The harmonic n.obs is  272 with the empirical chi square  168.285  with prob <  0.998 
## The total n.obs was  272  with Likelihood Chi Square =  388.758  with prob <  7.24e-11 
## 
## Tucker Lewis Index of factoring reliability =  0.9392
## RMSEA index =  0.0516  and the 90 % confidence intervals are  0.043 0.0604
## BIC =  -872.548
## Fit based upon off diagonal values = 0.993
## Measures of factor score adequacy             
##                                                     ML3   ML1   ML6   ML2   ML4
## Correlation of (regression) scores with factors   0.966 0.984 0.924 0.976 0.932
## Multiple R square of scores with factors          0.934 0.968 0.855 0.952 0.868
## Minimum correlation of possible factor scores     0.867 0.936 0.709 0.903 0.736
##                                                     ML5
## Correlation of (regression) scores with factors   0.912
## Multiple R square of scores with factors          0.831
## Minimum correlation of possible factor scores     0.663
plot(sixfactor)

cor.plot(subsetn)

cronchbar

cfa model

cfamodel1<-'BT=~BT1+BT2+BT3+BT4+BT5+BT6+BT7
BD=~BD1+BD2+BD3+BD4
EMP=~EMP1+EMP2+EMP3+EMP4+EMP5
CS=~CS1+CS2+CS3
EP=~EP1+EP2+EP3+EP4
LS=~LS1+LS2+LS3+LS4+LS5

'

fit model

fit.cfamodel1<-cfa(cfamodel1,data=subsetn,estimator="MLR",mimic="Mplus")
summary(fit.cfamodel1,fit.measures=T,standardized=T,rsq=T)
## lavaan 0.6.17 ended normally after 50 iterations
## 
##   Estimator                                         ML
##   Optimization method                           NLMINB
##   Number of model parameters                        99
## 
##   Number of observations                           272
##   Number of missing patterns                         1
## 
## Model Test User Model:
##                                               Standard      Scaled
##   Test Statistic                               603.531     534.890
##   Degrees of freedom                               335         335
##   P-value (Chi-square)                           0.000       0.000
##   Scaling correction factor                                  1.128
##     Yuan-Bentler correction (Mplus variant)                       
## 
## Model Test Baseline Model:
## 
##   Test statistic                              5190.329    4254.558
##   Degrees of freedom                               378         378
##   P-value                                        0.000       0.000
##   Scaling correction factor                                  1.220
## 
## User Model versus Baseline Model:
## 
##   Comparative Fit Index (CFI)                    0.944       0.948
##   Tucker-Lewis Index (TLI)                       0.937       0.942
##                                                                   
##   Robust Comparative Fit Index (CFI)                         0.954
##   Robust Tucker-Lewis Index (TLI)                            0.949
## 
## Loglikelihood and Information Criteria:
## 
##   Loglikelihood user model (H0)             -11143.554  -11143.554
##   Scaling correction factor                                  1.353
##       for the MLR correction                                      
##   Loglikelihood unrestricted model (H1)     -10841.788  -10841.788
##   Scaling correction factor                                  1.180
##       for the MLR correction                                      
##                                                                   
##   Akaike (AIC)                               22485.107   22485.107
##   Bayesian (BIC)                             22842.082   22842.082
##   Sample-size adjusted Bayesian (SABIC)      22528.179   22528.179
## 
## Root Mean Square Error of Approximation:
## 
##   RMSEA                                          0.054       0.047
##   90 Percent confidence interval - lower         0.047       0.040
##   90 Percent confidence interval - upper         0.061       0.054
##   P-value H_0: RMSEA <= 0.050                    0.153       0.769
##   P-value H_0: RMSEA >= 0.080                    0.000       0.000
##                                                                   
##   Robust RMSEA                                               0.049
##   90 Percent confidence interval - lower                     0.041
##   90 Percent confidence interval - upper                     0.057
##   P-value H_0: Robust RMSEA <= 0.050                         0.591
##   P-value H_0: Robust RMSEA >= 0.080                         0.000
## 
## Standardized Root Mean Square Residual:
## 
##   SRMR                                           0.053       0.053
## 
## Parameter Estimates:
## 
##   Standard errors                             Sandwich
##   Information bread                           Observed
##   Observed information based on                Hessian
## 
## Latent Variables:
##                    Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
##   BT =~                                                                 
##     BT1               1.000                               0.916    0.702
##     BT2               1.030    0.078   13.284    0.000    0.943    0.704
##     BT3               0.929    0.124    7.503    0.000    0.851    0.550
##     BT4               0.999    0.099   10.129    0.000    0.915    0.668
##     BT5               1.077    0.102   10.549    0.000    0.986    0.698
##     BT6               1.091    0.116    9.440    0.000    0.999    0.697
##     BT7               1.115    0.122    9.153    0.000    1.021    0.682
##   BD =~                                                                 
##     BD1               1.000                               1.149    0.765
##     BD2               0.936    0.071   13.212    0.000    1.076    0.760
##     BD3               1.037    0.065   15.921    0.000    1.192    0.802
##     BD4               0.891    0.068   13.194    0.000    1.024    0.765
##   EMP =~                                                                
##     EMP1              1.000                               1.145    0.705
##     EMP2              0.923    0.078   11.872    0.000    1.057    0.732
##     EMP3              0.922    0.090   10.192    0.000    1.056    0.627
##     EMP4              0.867    0.081   10.699    0.000    0.993    0.739
##     EMP5              0.877    0.093    9.425    0.000    1.004    0.681
##   CS =~                                                                 
##     CS1               1.000                               1.212    0.909
##     CS2               1.023    0.040   25.698    0.000    1.240    0.955
##     CS3               1.045    0.043   24.111    0.000    1.267    0.889
##   EP =~                                                                 
##     EP1               1.000                               1.260    0.909
##     EP2               1.065    0.035   30.561    0.000    1.342    0.982
##     EP3               0.851    0.061   13.883    0.000    1.073    0.774
##     EP4               0.893    0.050   17.773    0.000    1.125    0.782
##   LS =~                                                                 
##     LS1               1.000                               1.058    0.855
##     LS2               1.091    0.055   19.794    0.000    1.155    0.926
##     LS3               1.051    0.096   10.996    0.000    1.112    0.851
##     LS4               1.102    0.069   15.904    0.000    1.166    0.799
##     LS5               0.875    0.090    9.675    0.000    0.926    0.597
## 
## Covariances:
##                    Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
##   BT ~~                                                                 
##     BD                0.721    0.101    7.171    0.000    0.685    0.685
##     EMP               0.489    0.080    6.154    0.000    0.466    0.466
##     CS                0.626    0.093    6.747    0.000    0.564    0.564
##     EP                0.621    0.095    6.531    0.000    0.538    0.538
##     LS                0.345    0.071    4.842    0.000    0.356    0.356
##   BD ~~                                                                 
##     EMP               0.802    0.112    7.167    0.000    0.609    0.609
##     CS                0.791    0.112    7.060    0.000    0.568    0.568
##     EP                0.643    0.106    6.080    0.000    0.444    0.444
##     LS                0.345    0.088    3.921    0.000    0.283    0.283
##   EMP ~~                                                                
##     CS                0.831    0.114    7.282    0.000    0.599    0.599
##     EP                0.596    0.099    5.998    0.000    0.413    0.413
##     LS                0.317    0.098    3.238    0.001    0.261    0.261
##   CS ~~                                                                 
##     EP                0.733    0.109    6.743    0.000    0.480    0.480
##     LS                0.385    0.077    5.023    0.000    0.300    0.300
##   EP ~~                                                                 
##     LS                0.368    0.094    3.919    0.000    0.276    0.276
## 
## Intercepts:
##                    Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
##    .BT1               4.897    0.079   61.895    0.000    4.897    3.753
##    .BT2               4.871    0.081   59.949    0.000    4.871    3.635
##    .BT3               4.540    0.094   48.383    0.000    4.540    2.934
##    .BT4               4.757    0.083   57.300    0.000    4.757    3.474
##    .BT5               4.548    0.086   53.066    0.000    4.548    3.218
##    .BT6               5.151    0.087   59.266    0.000    5.151    3.594
##    .BT7               5.118    0.091   56.350    0.000    5.118    3.417
##    .BD1               4.588    0.091   50.370    0.000    4.588    3.054
##    .BD2               5.114    0.086   59.558    0.000    5.114    3.611
##    .BD3               4.515    0.090   50.135    0.000    4.515    3.040
##    .BD4               4.654    0.081   57.338    0.000    4.654    3.477
##    .EMP1              4.246    0.099   43.089    0.000    4.246    2.613
##    .EMP2              4.647    0.088   53.031    0.000    4.647    3.215
##    .EMP3              4.070    0.102   39.850    0.000    4.070    2.416
##    .EMP4              3.967    0.081   48.709    0.000    3.967    2.953
##    .EMP5              4.335    0.089   48.516    0.000    4.335    2.942
##    .CS1               4.449    0.081   55.041    0.000    4.449    3.337
##    .CS2               4.415    0.079   56.116    0.000    4.415    3.403
##    .CS3               4.426    0.086   51.221    0.000    4.426    3.106
##    .EP1               5.184    0.084   61.666    0.000    5.184    3.739
##    .EP2               5.107    0.083   61.632    0.000    5.107    3.737
##    .EP3               5.092    0.084   60.579    0.000    5.092    3.673
##    .EP4               4.989    0.087   57.192    0.000    4.989    3.468
##    .LS1               4.739    0.075   63.163    0.000    4.739    3.830
##    .LS2               4.974    0.076   65.799    0.000    4.974    3.990
##    .LS3               5.298    0.079   66.833    0.000    5.298    4.052
##    .LS4               4.941    0.088   55.852    0.000    4.941    3.387
##    .LS5               4.640    0.094   49.322    0.000    4.640    2.991
## 
## Variances:
##                    Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
##    .BT1               0.864    0.119    7.243    0.000    0.864    0.507
##    .BT2               0.906    0.107    8.481    0.000    0.906    0.505
##    .BT3               1.672    0.158   10.572    0.000    1.672    0.698
##    .BT4               1.038    0.123    8.411    0.000    1.038    0.554
##    .BT5               1.025    0.120    8.526    0.000    1.025    0.513
##    .BT6               1.057    0.118    8.994    0.000    1.057    0.514
##    .BT7               1.201    0.137    8.771    0.000    1.201    0.535
##    .BD1               0.936    0.113    8.252    0.000    0.936    0.415
##    .BD2               0.848    0.116    7.336    0.000    0.848    0.423
##    .BD3               0.786    0.102    7.682    0.000    0.786    0.356
##    .BD4               0.744    0.095    7.801    0.000    0.744    0.415
##    .EMP1              1.330    0.146    9.123    0.000    1.330    0.503
##    .EMP2              0.971    0.115    8.426    0.000    0.971    0.465
##    .EMP3              1.723    0.180    9.572    0.000    1.723    0.607
##    .EMP4              0.818    0.099    8.301    0.000    0.818    0.454
##    .EMP5              1.163    0.142    8.185    0.000    1.163    0.536
##    .CS1               0.307    0.078    3.949    0.000    0.307    0.173
##    .CS2               0.147    0.041    3.629    0.000    0.147    0.088
##    .CS3               0.425    0.101    4.203    0.000    0.425    0.209
##    .EP1               0.334    0.059    5.637    0.000    0.334    0.174
##    .EP2               0.067    0.043    1.585    0.113    0.067    0.036
##    .EP3               0.771    0.142    5.414    0.000    0.771    0.401
##    .EP4               0.803    0.152    5.299    0.000    0.803    0.388
##    .LS1               0.411    0.078    5.273    0.000    0.411    0.268
##    .LS2               0.222    0.049    4.560    0.000    0.222    0.143
##    .LS3               0.472    0.125    3.789    0.000    0.472    0.276
##    .LS4               0.770    0.098    7.816    0.000    0.770    0.362
##    .LS5               1.549    0.180    8.583    0.000    1.549    0.644
##     BT                0.839    0.132    6.365    0.000    1.000    1.000
##     BD                1.321    0.175    7.561    0.000    1.000    1.000
##     EMP               1.312    0.188    6.986    0.000    1.000    1.000
##     CS                1.469    0.159    9.261    0.000    1.000    1.000
##     EP                1.588    0.138   11.541    0.000    1.000    1.000
##     LS                1.120    0.149    7.520    0.000    1.000    1.000
## 
## R-Square:
##                    Estimate
##     BT1               0.493
##     BT2               0.495
##     BT3               0.302
##     BT4               0.446
##     BT5               0.487
##     BT6               0.486
##     BT7               0.465
##     BD1               0.585
##     BD2               0.577
##     BD3               0.644
##     BD4               0.585
##     EMP1              0.497
##     EMP2              0.535
##     EMP3              0.393
##     EMP4              0.546
##     EMP5              0.464
##     CS1               0.827
##     CS2               0.912
##     CS3               0.791
##     EP1               0.826
##     EP2               0.964
##     EP3               0.599
##     EP4               0.612
##     LS1               0.732
##     LS2               0.857
##     LS3               0.724
##     LS4               0.638
##     LS5               0.356

predict

pred<-predict(fit.cfamodel1)
head(pred)
##              BT         BD         EMP         CS          EP         LS
## [1,]  0.4986380  0.9518435 -0.81464907 -0.4132022 -1.03434255 -3.1463068
## [2,] -0.6071380 -0.4902541 -0.38141687 -1.3082481 -0.13072573 -0.8675342
## [3,] -1.9079688 -1.7512811 -1.39078648 -1.2012873 -2.80567036 -0.9558520
## [4,]  1.4453643 -0.1115977 -0.55667130  0.3458193  0.01982881 -1.5611947
## [5,]  0.8128071  0.3573468 -0.03157638  0.1281985 -0.72243830  0.7326089
## [6,] -0.2078168 -0.3213221 -0.69389260 -1.3334496 -2.10653603 -0.9947009

inspect

inspect(fit.cfamodel1,"cor.lv")
##        BT    BD   EMP    CS    EP    LS
## BT  1.000                              
## BD  0.685 1.000                        
## EMP 0.466 0.609 1.000                  
## CS  0.564 0.568 0.599 1.000            
## EP  0.538 0.444 0.413 0.480 1.000      
## LS  0.356 0.283 0.261 0.300 0.276 1.000

discriminant validity

condisc<-function(x){std.loadings<-inspect(x,what = "std")$lambda}
condisc
## function(x){std.loadings<-inspect(x,what = "std")$lambda}

model

model1<-'BT=~BT1+BT2+BT3+BT4+BT5+BT6+BT7
BD=~BD1+BD2+BD3+BD4
EMP=~EMP1+EMP2+EMP3+EMP4+EMP5
CS=~CS1+CS2+CS3
EP=~EP1+EP2+EP3+EP4
LS=~LS1+LS2+LS3+LS4+LS5
#regression
CS=~LS
CS=~BT+BD+EMP+EP
'
fit.semmodel<-sem(model1,data=subsetn,estimator="MLR",mimic="Mplus")

summary

summary<-summary(fit.semmodel,fit.measures=T,standardized=T,rsq=T)
semPaths(fit.semmodel, whatLabels = "est", style = "lisrel", intercepts = FALSE)

#library(seminr)
#measurement model
#mm<-constructs(composite("BD",multi_items("BT",1:7)),composite("BD",multi_items("BD",1:4)),composite("CS",multi_items("CS",1:3)))
#sm<-relationships(paths(from = c("BT","BD"),to=c("CS")))
#estimate<-estimate_pls(data=sem,measurement_model = mm,inner_weights=path_weighting,structural_model = sm,missing = mean_replacement,missing_value = "-99")
#library(restriktor)

# lavaan syntax
#model.lav <- "y1 ~ 1 + a*x1 + b*x2 + c*x3"
#fit.lav <- sem(model.lav, data = PoliticalDemocracy)

# restriktor syntax
#fit.restr <- goric(fit.lav, hypotheses = list(h1 = 'a > b > c'), comparison = #"complement")
#fit.restr
#h1 <- 'a1 > a2 > a3; b1 > b2 > b3'

#model <- '
  #y1 ~ 1 + a1*x1 + b1*x2
  #y2 ~ 1 + a2*x1 + b2*x2
  #y3 ~ 1 + a3*x1 + b3*x2
#'
#iht(model = model, data = PoliticalDemocracy, constraints = h1,
    #R = 1000, double.bootstrap = "no", parallel = "snow", ncpus = 8)

#The advantage of the goric(a) is that you can directly evaluate your order-restricted hypothesis against its complement (i.e., not h1).

#fit.lav <- sem(model, data = PoliticalDemocracy)
#goric(fit.lav, hypotheses = list(h1 = h1), comparison = "complement")

#From the results you can conclude that hypothesis h1 is 'some value' more supported than its complement.
#See the Vignette in restriktor for "Guidelines interpretation GORIC(A) output" or feel free to contact me.