安裝Package {lavaan}

https://lavaan.ugent.be/tutorial/index.html

SEM和CFA

SEM和CFA都要看適配度指標fit index,包括:CFI、TLI、MSEA、SRMR,(HU & Bentler, 1998/1999),有提供cut off point,CFI、TLI:>0.95,後面很多人抓0.9;MSEA和SRMR抓<0.08。這些適配度指標在SEM裡面都要一起看,其中一個表現不好,模型就視為不成立。 CFA是SEM的一個特殊的例子。

CFA

knitr::include_graphics("cfa.png")

https://lavaan.ugent.be/tutorial/cfa.html 雙箭頭表示相關,方框X1.X2…是真實資料,圓形是跑出來的概念(潛在變項) visual =~ x1 + x2 + x3 (CFA的語法) visual潛在變項是X1.X2.X3具合起來的

CFA與EFA

若是自己做的問卷,並不會知道甚麼是適合的模型,可以先做EPA,在依照EFA結果,做CFA模型。若是前人已經開發的問卷,可以依照前人的EFA來建構CFA模。

CFA實作

#依然用老師的資料GSdata做例子
#讀檔案存成dta
dta<-read.csv("D://GSdata_20211113.csv", head=T, fileEncoding = "UTF-8-BOM")  
#看資料
summary(dta)
 Placeofliving        Age           Gender          Weight      
 Min.   :1.000   Min.   :17.0   Min.   :1.000   Min.   : 40.00  
 1st Qu.:1.000   1st Qu.:20.0   1st Qu.:1.000   1st Qu.: 52.00  
 Median :1.000   Median :21.0   Median :2.000   Median : 58.00  
 Mean   :1.241   Mean   :21.6   Mean   :1.612   Mean   : 61.74  
 3rd Qu.:1.000   3rd Qu.:23.0   3rd Qu.:2.000   3rd Qu.: 70.00  
 Max.   :3.000   Max.   :30.0   Max.   :2.000   Max.   :135.00  
 NA's   :105                                                    
     Height           BMI            Major           TFEQ1r     
 Min.   :145.0   Min.   :15.35   Min.   :1.000   Min.   :1.000  
 1st Qu.:159.0   1st Qu.:19.53   1st Qu.:1.000   1st Qu.:2.000  
 Median :165.0   Median :21.60   Median :2.000   Median :2.000  
 Mean   :165.5   Mean   :22.39   Mean   :1.738   Mean   :2.415  
 3rd Qu.:171.0   3rd Qu.:24.30   3rd Qu.:2.000   3rd Qu.:3.000  
 Max.   :185.0   Max.   :47.86   Max.   :2.000   Max.   :4.000  
                                                                
     TFEQ2r          TFEQ3r          TFEQ4r          TFEQ5r     
 Min.   :1.000   Min.   :1.000   Min.   :1.000   Min.   :1.000  
 1st Qu.:2.000   1st Qu.:2.000   1st Qu.:2.000   1st Qu.:2.000  
 Median :2.000   Median :2.000   Median :2.000   Median :2.000  
 Mean   :2.228   Mean   :2.372   Mean   :2.258   Mean   :2.378  
 3rd Qu.:3.000   3rd Qu.:3.000   3rd Qu.:3.000   3rd Qu.:3.000  
 Max.   :4.000   Max.   :4.000   Max.   :4.000   Max.   :4.000  
                                                                
     TFEQ6r          TFEQ7r          TFEQ8r          TFEQ9r     
 Min.   :1.000   Min.   :1.000   Min.   :1.000   Min.   :1.000  
 1st Qu.:2.000   1st Qu.:2.000   1st Qu.:1.000   1st Qu.:1.000  
 Median :2.000   Median :2.000   Median :2.000   Median :2.000  
 Mean   :2.215   Mean   :2.468   Mean   :2.089   Mean   :1.994  
 3rd Qu.:3.000   3rd Qu.:3.000   3rd Qu.:3.000   3rd Qu.:3.000  
 Max.   :4.000   Max.   :4.000   Max.   :4.000   Max.   :4.000  
                                                                
    TFEQ10r         TFEQ11r         TFEQ12r         TFEQ13r     
 Min.   :1.000   Min.   :1.000   Min.   :1.000   Min.   :1.000  
 1st Qu.:1.000   1st Qu.:2.000   1st Qu.:1.000   1st Qu.:1.000  
 Median :2.000   Median :2.000   Median :2.000   Median :2.000  
 Mean   :2.203   Mean   :2.274   Mean   :1.914   Mean   :2.031  
 3rd Qu.:3.000   3rd Qu.:3.000   3rd Qu.:2.000   3rd Qu.:2.000  
 Max.   :4.000   Max.   :4.000   Max.   :4.000   Max.   :4.000  
                                                                
     TFEQ14          TFEQ15          TFEQ16          TFEQ17     
 Min.   :1.000   Min.   :1.000   Min.   :1.000   Min.   :1.000  
 1st Qu.:2.000   1st Qu.:2.000   1st Qu.:2.000   1st Qu.:2.000  
 Median :2.000   Median :2.000   Median :3.000   Median :2.000  
 Mean   :2.258   Mean   :2.292   Mean   :2.637   Mean   :2.012  
 3rd Qu.:3.000   3rd Qu.:3.000   3rd Qu.:3.000   3rd Qu.:2.000  
 Max.   :4.000   Max.   :4.000   Max.   :4.000   Max.   :4.000  
                                                                
    TFEQ18c          IPAQ0           IPAQ1           IPAQ2         IPAQ3      
 Min.   :1.000   Min.   :1.000   Min.   :0.000   Min.   :  0   Min.   :0.000  
 1st Qu.:2.000   1st Qu.:2.000   1st Qu.:0.000   1st Qu.:  0   1st Qu.:0.000  
 Median :2.000   Median :3.000   Median :1.000   Median : 15   Median :2.000  
 Mean   :2.135   Mean   :2.409   Mean   :1.563   Mean   : 35   Mean   :1.991  
 3rd Qu.:3.000   3rd Qu.:3.000   3rd Qu.:2.000   3rd Qu.: 60   3rd Qu.:3.000  
 Max.   :4.000   Max.   :3.000   Max.   :7.000   Max.   :300   Max.   :7.000  
                                                                              
     IPAQ4            IPAQ5           IPAQ6             IPAQ7       
 Min.   :  0.00   Min.   :0.000   Min.   :   0.00   Min.   :  0.00  
 1st Qu.:  0.00   1st Qu.:4.000   1st Qu.:  20.00   1st Qu.:  6.00  
 Median : 24.00   Median :6.000   Median :  30.00   Median :  8.00  
 Mean   : 34.78   Mean   :5.348   Mean   :  61.74   Mean   : 19.85  
 3rd Qu.: 50.00   3rd Qu.:7.000   3rd Qu.:  60.00   3rd Qu.: 12.00  
 Max.   :300.00   Max.   :7.000   Max.   :2046.00   Max.   :360.00  
                                                                    
     IPAQ7c        IPAQtotalMET   IPAQexerciselevel   Attitude1a   
 Min.   : 0.000   Min.   :    0   Min.   :1.000     Min.   :2.000  
 1st Qu.: 5.000   1st Qu.:  560   1st Qu.:1.000     1st Qu.:4.000  
 Median : 8.000   Median : 1386   Median :2.000     Median :5.000  
 Mean   : 8.138   Mean   : 2008   Mean   :2.022     Mean   :5.117  
 3rd Qu.:10.000   3rd Qu.: 2613   3rd Qu.:3.000     3rd Qu.:6.000  
 Max.   :24.000   Max.   :17598   Max.   :3.000     Max.   :7.000  
                                                                   
   Attitude1b      Attitude1c    Attitude1d      Attitude1e      Attitude1f   
 Min.   :3.000   Min.   :1.0   Min.   :3.000   Min.   :2.000   Min.   :1.000  
 1st Qu.:6.000   1st Qu.:6.0   1st Qu.:5.000   1st Qu.:6.000   1st Qu.:4.000  
 Median :7.000   Median :7.0   Median :6.000   Median :7.000   Median :5.000  
 Mean   :6.354   Mean   :6.4   Mean   :6.083   Mean   :6.298   Mean   :4.818  
 3rd Qu.:7.000   3rd Qu.:7.0   3rd Qu.:7.000   3rd Qu.:7.000   3rd Qu.:6.000  
 Max.   :7.000   Max.   :7.0   Max.   :7.000   Max.   :7.000   Max.   :7.000  
                                                                              
   Attitude1g      Attitude1h      Attitude2a      Attitude2b   
 Min.   :1.000   Min.   :3.000   Min.   :2.000   Min.   :3.000  
 1st Qu.:4.000   1st Qu.:6.000   1st Qu.:5.000   1st Qu.:6.000  
 Median :5.000   Median :7.000   Median :6.000   Median :7.000  
 Mean   :4.935   Mean   :6.274   Mean   :5.471   Mean   :6.289  
 3rd Qu.:6.000   3rd Qu.:7.000   3rd Qu.:7.000   3rd Qu.:7.000  
 Max.   :7.000   Max.   :7.000   Max.   :7.000   Max.   :7.000  
                                                                
   Attitude2c      Attitude2d     Attitude2e      Attitude2f      Attitude2g   
 Min.   :3.000   Min.   :3.00   Min.   :4.000   Min.   :1.000   Min.   :1.000  
 1st Qu.:6.000   1st Qu.:5.00   1st Qu.:6.000   1st Qu.:4.000   1st Qu.:5.000  
 Median :7.000   Median :6.00   Median :7.000   Median :5.000   Median :6.000  
 Mean   :6.363   Mean   :6.12   Mean   :6.292   Mean   :5.298   Mean   :5.557  
 3rd Qu.:7.000   3rd Qu.:7.00   3rd Qu.:7.000   3rd Qu.:7.000   3rd Qu.:7.000  
 Max.   :7.000   Max.   :7.00   Max.   :7.000   Max.   :7.000   Max.   :7.000  
                                                                               
   Attitude2h    Subjectivenorm1 Subjectivenorm2 Subjectivenorm3
 Min.   :3.000   Min.   :1.000   Min.   :1.000   Min.   :1.000  
 1st Qu.:6.000   1st Qu.:3.000   1st Qu.:4.000   1st Qu.:2.000  
 Median :7.000   Median :5.000   Median :5.000   Median :4.000  
 Mean   :6.302   Mean   :4.477   Mean   :4.603   Mean   :3.751  
 3rd Qu.:7.000   3rd Qu.:6.000   3rd Qu.:6.000   3rd Qu.:5.000  
 Max.   :7.000   Max.   :7.000   Max.   :7.000   Max.   :7.000  
                                                                
 Subjectivenorm4 Subjectivenorm5 Subjectivenorm6      PBC1      
 Min.   :1.000   Min.   :1.0     Min.   :1.000   Min.   :1.000  
 1st Qu.:2.000   1st Qu.:2.0     1st Qu.:3.000   1st Qu.:4.000  
 Median :3.000   Median :4.0     Median :4.000   Median :5.000  
 Mean   :3.477   Mean   :3.8     Mean   :4.234   Mean   :4.868  
 3rd Qu.:5.000   3rd Qu.:5.0     3rd Qu.:6.000   3rd Qu.:6.000  
 Max.   :7.000   Max.   :7.0     Max.   :7.000   Max.   :7.000  
                                                                
      PBC2            PBC3            PBC4            PBC5      
 Min.   :1.000   Min.   :1.000   Min.   :1.000   Min.   :1.000  
 1st Qu.:5.000   1st Qu.:3.000   1st Qu.:4.000   1st Qu.:4.000  
 Median :6.000   Median :4.000   Median :5.000   Median :5.000  
 Mean   :5.825   Mean   :3.945   Mean   :4.686   Mean   :4.935  
 3rd Qu.:7.000   3rd Qu.:5.000   3rd Qu.:6.000   3rd Qu.:6.000  
 Max.   :7.000   Max.   :7.000   Max.   :7.000   Max.   :7.000  
                                                                
      PBC6            PBC7            PBC8            PBC9      
 Min.   :1.000   Min.   :1.000   Min.   :1.000   Min.   :1.000  
 1st Qu.:3.000   1st Qu.:3.000   1st Qu.:3.000   1st Qu.:3.000  
 Median :5.000   Median :5.000   Median :4.000   Median :4.000  
 Mean   :4.582   Mean   :4.655   Mean   :4.188   Mean   :4.385  
 3rd Qu.:6.000   3rd Qu.:6.000   3rd Qu.:5.000   3rd Qu.:6.000  
 Max.   :7.000   Max.   :7.000   Max.   :7.000   Max.   :7.000  
                                                                
     PBC10       Behavioralintention1 Behavioralintention2 Behavioralintention3
 Min.   :1.000   Min.   :1.000        Min.   :1.000        Min.   :1.000       
 1st Qu.:3.000   1st Qu.:4.000        1st Qu.:4.000        1st Qu.:4.000       
 Median :5.000   Median :5.000        Median :5.000        Median :5.000       
 Mean   :4.606   Mean   :4.495        Mean   :4.714        Mean   :4.726       
 3rd Qu.:6.000   3rd Qu.:5.000        3rd Qu.:6.000        3rd Qu.:6.000       
 Max.   :7.000   Max.   :7.000        Max.   :7.000        Max.   :7.000       
                                                                               
 Behavioralintention4 Behavioralintention5 Behavioralintention6     WBIS1      
 Min.   :1.000        Min.   :1.000        Min.   :1.000        Min.   :1.000  
 1st Qu.:3.000        1st Qu.:4.000        1st Qu.:4.000        1st Qu.:3.000  
 Median :5.000        Median :5.000        Median :5.000        Median :4.000  
 Mean   :4.631        Mean   :4.757        Mean   :4.809        Mean   :3.443  
 3rd Qu.:6.000        3rd Qu.:6.000        3rd Qu.:6.000        3rd Qu.:4.000  
 Max.   :7.000        Max.   :7.000        Max.   :7.000        Max.   :5.000  
                                                                               
     WBIS2           WBIS3           WBIS4           WBIS5      
 Min.   :1.000   Min.   :1.000   Min.   :1.000   Min.   :1.000  
 1st Qu.:2.000   1st Qu.:2.000   1st Qu.:2.000   1st Qu.:2.000  
 Median :3.000   Median :3.000   Median :4.000   Median :3.000  
 Mean   :3.009   Mean   :3.163   Mean   :3.372   Mean   :2.858  
 3rd Qu.:4.000   3rd Qu.:4.000   3rd Qu.:4.000   3rd Qu.:4.000  
 Max.   :5.000   Max.   :5.000   Max.   :5.000   Max.   :5.000  
                                                                
     WBIS6           WBIS7           WBIS8           WBIS9      
 Min.   :1.000   Min.   :1.000   Min.   :1.000   Min.   :1.000  
 1st Qu.:2.000   1st Qu.:1.000   1st Qu.:1.000   1st Qu.:2.000  
 Median :3.000   Median :2.000   Median :2.000   Median :3.000  
 Mean   :2.982   Mean   :1.895   Mean   :1.997   Mean   :3.262  
 3rd Qu.:4.000   3rd Qu.:3.000   3rd Qu.:3.000   3rd Qu.:4.000  
 Max.   :5.000   Max.   :5.000   Max.   :5.000   Max.   :5.000  
                                                                
     WBIS10          WBIS11          WSSQ1           WSSQ2      
 Min.   :1.000   Min.   :1.000   Min.   :0.000   Min.   :0.000  
 1st Qu.:1.000   1st Qu.:1.000   1st Qu.:0.000   1st Qu.:1.000  
 Median :2.000   Median :2.000   Median :2.000   Median :3.000  
 Mean   :2.182   Mean   :2.169   Mean   :1.803   Mean   :2.557  
 3rd Qu.:3.000   3rd Qu.:3.000   3rd Qu.:3.000   3rd Qu.:4.000  
 Max.   :5.000   Max.   :5.000   Max.   :5.000   Max.   :5.000  
                                                                
     WSSQ3           WSSQ4           WSSQ5           WSSQ6      
 Min.   :0.000   Min.   :0.000   Min.   :0.000   Min.   :0.000  
 1st Qu.:1.000   1st Qu.:0.000   1st Qu.:1.000   1st Qu.:1.000  
 Median :2.000   Median :1.000   Median :2.000   Median :3.000  
 Mean   :2.212   Mean   :1.498   Mean   :2.068   Mean   :2.437  
 3rd Qu.:4.000   3rd Qu.:2.000   3rd Qu.:3.000   3rd Qu.:4.000  
 Max.   :5.000   Max.   :5.000   Max.   :5.000   Max.   :5.000  
                                                                
     WSSQ7           WSSQ8           WSSQ9           WSSQ10     
 Min.   :0.000   Min.   :0.000   Min.   :0.000   Min.   :0.000  
 1st Qu.:2.000   1st Qu.:1.000   1st Qu.:1.000   1st Qu.:0.000  
 Median :3.000   Median :1.000   Median :1.000   Median :2.000  
 Mean   :2.628   Mean   :1.658   Mean   :1.542   Mean   :1.914  
 3rd Qu.:4.000   3rd Qu.:2.000   3rd Qu.:2.000   3rd Qu.:3.000  
 Max.   :5.000   Max.   :5.000   Max.   :5.000   Max.   :5.000  
                                                                
     WSSQ11          WSSQ12       Weight_group     WBIS1_r         WBIS9_r     
 Min.   :0.000   Min.   :0.000   Min.   :1.00   Min.   :1.000   Min.   :1.000  
 1st Qu.:0.000   1st Qu.:1.000   1st Qu.:1.00   1st Qu.:2.000   1st Qu.:2.000  
 Median :1.000   Median :1.000   Median :1.00   Median :2.000   Median :3.000  
 Mean   :1.529   Mean   :1.535   Mean   :1.32   Mean   :2.557   Mean   :2.738  
 3rd Qu.:2.000   3rd Qu.:3.000   3rd Qu.:2.00   3rd Qu.:3.000   3rd Qu.:4.000  
 Max.   :5.000   Max.   :5.000   Max.   :2.00   Max.   :5.000   Max.   :5.000  
                                                                               
 WBIS_Total_Score WSSQ_Q1to6_Total WSSQ_Q7to12_Total WSSQ_Total_Score
 Min.   :11.00    Min.   : 0.00    Min.   : 0.00     Min.   : 0.00   
 1st Qu.:22.00    1st Qu.: 7.00    1st Qu.: 6.00     1st Qu.:12.00   
 Median :30.00    Median :14.00    Median :12.00     Median :25.00   
 Mean   :28.92    Mean   :12.58    Mean   :10.81     Mean   :23.38   
 3rd Qu.:36.00    3rd Qu.:18.00    3rd Qu.:16.00     3rd Qu.:33.00   
 Max.   :55.00    Max.   :28.00    Max.   :28.00     Max.   :53.00   
                                                                     
   TFEQ_Total    Attitude_Eat     Attitude_PA      SubNorm_Eat    
 Min.   :12.0   Min.   : 47.92   Min.   : 41.67   Min.   :  0.00  
 1st Qu.:22.0   1st Qu.: 70.83   1st Qu.: 72.92   1st Qu.: 38.89  
 Median :26.0   Median : 81.25   Median : 83.33   Median : 55.56  
 Mean   :26.7   Mean   : 79.75   Mean   : 82.69   Mean   : 54.62  
 3rd Qu.:31.0   3rd Qu.: 89.58   3rd Qu.: 95.83   3rd Qu.: 72.22  
 Max.   :45.0   Max.   :100.00   Max.   :100.00   Max.   :100.00  
                                                                  
   SubNorm_PA        PBC_Eat           PBC_PA          Int_Eat      
 Min.   :  0.00   Min.   :  0.00   Min.   :  0.00   Min.   :  0.00  
 1st Qu.: 27.78   1st Qu.: 58.33   1st Qu.: 37.50   1st Qu.: 50.00  
 Median : 50.00   Median : 66.67   Median : 58.33   Median : 66.67  
 Mean   : 47.28   Mean   : 67.97   Mean   : 59.28   Mean   : 60.75  
 3rd Qu.: 66.67   3rd Qu.: 79.17   3rd Qu.: 83.33   3rd Qu.: 77.78  
 Max.   :100.00   Max.   :100.00   Max.   :100.00   Max.   :100.00  
                                                                    
     Int_PA       IPAQtotalMET2   
 Min.   :  0.00   Min.   :  0.00  
 1st Qu.: 50.00   1st Qu.:  5.60  
 Median : 66.67   Median : 13.86  
 Mean   : 62.21   Mean   : 20.08  
 3rd Qu.: 83.33   3rd Qu.: 26.13  
 Max.   :100.00   Max.   :175.98  
                                  
#運用package lavaan
library(lavaan)
#CFA語法
#先依照變項建構因子,真實資料可能會先做EFA,決定變項屬於哪個因子
#這邊假設TFEQ1~TFEQ6屬於Factor1、TFEQ7~TFEQ12屬於Factor2、TFEQ13~TFEQ18屬於Factor3
#factor1=~(來自於)變項1+變項2+...
#存成TFEQ.model
TFEQ.model <-
' 
  factor1 =~ TFEQ1r+TFEQ2r+TFEQ3r+TFEQ4r+TFEQ5r+TFEQ6r   
  factor2 =~ TFEQ7r+TFEQ8r+TFEQ9r+TFEQ10r+TFEQ11r+TFEQ12r  
  factor3 =~ TFEQ13r+TFEQ14+TFEQ15+TFEQ16+TFEQ17+TFEQ18c
'  
#用cfa做TFEQ.model的適配度檢定,data來自於dta
fit<-cfa(TFEQ.model, data=dta)
#fit.measures=T,常見的適配度資料
#standardized=T,係數標準化。
#經標準化後,factor loading:0-1,兩個變項的相關性是標準化係數
summary(fit,fit.measures=T, standardized=T)
lavaan 0.6-9 ended normally after 41 iterations

  Estimator                                         ML
  Optimization method                           NLMINB
  Number of model parameters                        39
                                                      
  Number of observations                           325
                                                      
Model Test User Model:
                                                      
  Test statistic                               916.449
  Degrees of freedom                               132
  P-value (Chi-square)                           0.000

Model Test Baseline Model:

  Test statistic                              2161.280
  Degrees of freedom                               153
  P-value                                        0.000

User Model versus Baseline Model:

  Comparative Fit Index (CFI)                    0.609
  Tucker-Lewis Index (TLI)                       0.547

Loglikelihood and Information Criteria:

  Loglikelihood user model (H0)              -6559.276
  Loglikelihood unrestricted model (H1)      -6101.052
                                                      
  Akaike (AIC)                               13196.553
  Bayesian (BIC)                             13344.122
  Sample-size adjusted Bayesian (BIC)        13220.417

Root Mean Square Error of Approximation:

  RMSEA                                          0.135
  90 Percent confidence interval - lower         0.127
  90 Percent confidence interval - upper         0.144
  P-value RMSEA <= 0.05                          0.000

Standardized Root Mean Square Residual:

  SRMR                                           0.133

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
  factor1 =~                                                            
    TFEQ1r            1.000                               0.493    0.587
    TFEQ2r            0.131    0.105    1.242    0.214    0.064    0.076
    TFEQ3r            1.170    0.134    8.722    0.000    0.576    0.633
    TFEQ4r            1.294    0.135    9.551    0.000    0.637    0.729
    TFEQ5r            1.063    0.121    8.807    0.000    0.524    0.642
    TFEQ6r            1.142    0.132    8.678    0.000    0.563    0.628
  factor2 =~                                                            
    TFEQ7r            1.000                               0.486    0.627
    TFEQ8r            1.446    0.134   10.799    0.000    0.702    0.756
    TFEQ9r            1.472    0.131   11.271    0.000    0.715    0.809
    TFEQ10r           1.138    0.127    8.980    0.000    0.553    0.593
    TFEQ11r           0.048    0.103    0.463    0.643    0.023    0.028
    TFEQ12r           0.003    0.096    0.030    0.976    0.001    0.002
  factor3 =~                                                            
    TFEQ13r           1.000                               0.680    0.791
    TFEQ14            0.646    0.073    8.837    0.000    0.439    0.583
    TFEQ15           -0.287    0.071   -4.046    0.000   -0.195   -0.255
    TFEQ16           -0.307    0.077   -4.014    0.000   -0.209   -0.253
    TFEQ17            0.311    0.067    4.674    0.000    0.211    0.296
    TFEQ18c          -0.167    0.062   -2.681    0.007   -0.114   -0.168

Covariances:
                   Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
  factor1 ~~                                                            
    factor2           0.200    0.029    6.874    0.000    0.834    0.834
    factor3           0.224    0.034    6.649    0.000    0.670    0.670
  factor2 ~~                                                            
    factor3           0.263    0.035    7.603    0.000    0.798    0.798

Variances:
                   Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
   .TFEQ1r            0.462    0.040   11.414    0.000    0.462    0.656
   .TFEQ2r            0.719    0.056   12.733    0.000    0.719    0.994
   .TFEQ3r            0.498    0.045   11.048    0.000    0.498    0.600
   .TFEQ4r            0.358    0.036    9.825    0.000    0.358    0.468
   .TFEQ5r            0.392    0.036   10.963    0.000    0.392    0.588
   .TFEQ6r            0.486    0.044   11.090    0.000    0.486    0.606
   .TFEQ7r            0.364    0.032   11.436    0.000    0.364    0.606
   .TFEQ8r            0.369    0.037    9.987    0.000    0.369    0.428
   .TFEQ9r            0.270    0.031    8.794    0.000    0.270    0.346
   .TFEQ10r           0.564    0.048   11.656    0.000    0.564    0.648
   .TFEQ11r           0.709    0.056   12.746    0.000    0.709    0.999
   .TFEQ12r           0.614    0.048   12.748    0.000    0.614    1.000
   .TFEQ13r           0.276    0.044    6.222    0.000    0.276    0.374
   .TFEQ14            0.374    0.035   10.827    0.000    0.374    0.660
   .TFEQ15            0.544    0.044   12.502    0.000    0.544    0.935
   .TFEQ16            0.637    0.051   12.506    0.000    0.637    0.936
   .TFEQ17            0.466    0.038   12.409    0.000    0.466    0.913
   .TFEQ18c           0.443    0.035   12.645    0.000    0.443    0.972
    factor1           0.243    0.045    5.338    0.000    1.000    1.000
    factor2           0.236    0.040    5.907    0.000    1.000    1.000
    factor3           0.462    0.066    6.982    0.000    1.000    1.000

CFA結果判讀

Step1:先看卡方值和P值 Test statistic:916.449(卡方值),Degrees of freedom:132,P-value (Chi-square):0.000(顯著)

實際上希望CFA卡方值不顯著,但因為大樣本通常都容易顯著,所以也沒關係:D

Step2:看適配度,cfa default為最大概似法(ML)

Comparative Fit Index (CFI):0.609,並沒有>0.9→模型不好

Tucker-Lewis Index (TLI): 0.547,並沒有>0.9→模型不好

RMSEA:0.135,並沒有<0.08→模型不好

SRMR:0.133,並沒有<0.08→模型不好

Step3:看factor相關

knitr::include_graphics("cfa factor loading.png")

factor1和factor2、factor3有相關

factor2和factor3有相關

若模型成立,factor1、factor2、factor3之間會有雙向箭頭

Step4:思考模型為什麼不好

看factor中,各變項的factor loading,Std.all要>0.5

knitr::include_graphics("cfa factor loading.png")

factor1:TFEQ2r factor loading=0.076 (沒有>0.5,建議刪除此項)

factor2:TFEQ11r:0.028和TFEQ12r:0.002建議刪除

factor3:TFEQ15、TFEQ16、TFEQ18c,都是負值,檢查是否為反向題資料要倒轉,否則刪除。TFEQ17:0.296建議刪除

CFA實作

強迫factor間不相關

library(lavaan)
TFEQ.model <-
' 
  factor1 =~ TFEQ1r+TFEQ2r+TFEQ3r+ TFEQ4r+ TFEQ5r+TFEQ6r   
  factor2 =~ TFEQ7r+TFEQ8r+TFEQ9r+ TFEQ10r+ TFEQ11r+TFEQ12r  
  factor3 =~ TFEQ13r+TFEQ14+TFEQ15+ TFEQ16+ TFEQ17+TFEQ18c
#告訴lavaan,factor1, factor2相關性=0(強迫設為不相關的意思)
  factor1~~0*factor2  
#告訴lavaan,factor1, factor3相關性=0(強迫設為不相關的意思)
  factor1~~0*factor3
#告訴lavaan,factor2, factor3相關性=0(強迫設為不相關的意思)
  factor2~~0*factor3
'  
fit<-cfa(TFEQ.model, data=dta)
summary(fit,fit.measures=T, standardized=T)
lavaan 0.6-9 ended normally after 37 iterations

  Estimator                                         ML
  Optimization method                           NLMINB
  Number of model parameters                        36
                                                      
  Number of observations                           325
                                                      
Model Test User Model:
                                                      
  Test statistic                              1247.197
  Degrees of freedom                               135
  P-value (Chi-square)                           0.000

Model Test Baseline Model:

  Test statistic                              2161.280
  Degrees of freedom                               153
  P-value                                        0.000

User Model versus Baseline Model:

  Comparative Fit Index (CFI)                    0.446
  Tucker-Lewis Index (TLI)                       0.372

Loglikelihood and Information Criteria:

  Loglikelihood user model (H0)              -6724.650
  Loglikelihood unrestricted model (H1)      -6101.052
                                                      
  Akaike (AIC)                               13521.300
  Bayesian (BIC)                             13657.518
  Sample-size adjusted Bayesian (BIC)        13543.329

Root Mean Square Error of Approximation:

  RMSEA                                          0.159
  90 Percent confidence interval - lower         0.151
  90 Percent confidence interval - upper         0.167
  P-value RMSEA <= 0.05                          0.000

Standardized Root Mean Square Residual:

  SRMR                                           0.227

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
  factor1 =~                                                            
    TFEQ1r            1.000                               0.447    0.532
    TFEQ2r            0.227    0.120    1.881    0.060    0.101    0.119
    TFEQ3r            1.373    0.173    7.922    0.000    0.613    0.673
    TFEQ4r            1.411    0.173    8.164    0.000    0.630    0.721
    TFEQ5r            1.136    0.149    7.606    0.000    0.508    0.622
    TFEQ6r            1.325    0.169    7.853    0.000    0.592    0.661
  factor2 =~                                                            
    TFEQ7r            1.000                               0.431    0.556
    TFEQ8r            1.677    0.175    9.566    0.000    0.722    0.778
    TFEQ9r            1.823    0.191    9.549    0.000    0.785    0.888
    TFEQ10r           1.096    0.150    7.298    0.000    0.472    0.506
    TFEQ11r           0.062    0.117    0.527    0.598    0.027    0.032
    TFEQ12r           0.049    0.109    0.450    0.652    0.021    0.027
  factor3 =~                                                            
    TFEQ13r           1.000                               0.660    0.769
    TFEQ14            0.672    0.123    5.476    0.000    0.444    0.589
    TFEQ15           -0.324    0.085   -3.794    0.000   -0.214   -0.281
    TFEQ16           -0.351    0.092   -3.797    0.000   -0.232   -0.281
    TFEQ17            0.260    0.078    3.340    0.001    0.172    0.240
    TFEQ18c          -0.251    0.074   -3.404    0.001   -0.166   -0.246

Covariances:
                   Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
  factor1 ~~                                                            
    factor2           0.000                               0.000    0.000
    factor3           0.000                               0.000    0.000
  factor2 ~~                                                            
    factor3           0.000                               0.000    0.000

Variances:
                   Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
   .TFEQ1r            0.505    0.044   11.372    0.000    0.505    0.717
   .TFEQ2r            0.713    0.056   12.698    0.000    0.713    0.986
   .TFEQ3r            0.455    0.046    9.817    0.000    0.455    0.547
   .TFEQ4r            0.367    0.041    8.905    0.000    0.367    0.480
   .TFEQ5r            0.408    0.039   10.527    0.000    0.408    0.613
   .TFEQ6r            0.452    0.045   10.005    0.000    0.452    0.563
   .TFEQ7r            0.414    0.035   11.693    0.000    0.414    0.690
   .TFEQ8r            0.341    0.043    7.989    0.000    0.341    0.395
   .TFEQ9r            0.165    0.041    4.040    0.000    0.165    0.211
   .TFEQ10r           0.647    0.054   11.958    0.000    0.647    0.744
   .TFEQ11r           0.709    0.056   12.745    0.000    0.709    0.999
   .TFEQ12r           0.614    0.048   12.746    0.000    0.614    0.999
   .TFEQ13r           0.302    0.077    3.901    0.000    0.302    0.409
   .TFEQ14            0.370    0.045    8.257    0.000    0.370    0.653
   .TFEQ15            0.536    0.044   12.234    0.000    0.536    0.921
   .TFEQ16            0.627    0.051   12.233    0.000    0.627    0.921
   .TFEQ17            0.481    0.039   12.386    0.000    0.481    0.942
   .TFEQ18c           0.428    0.035   12.368    0.000    0.428    0.940
    factor1           0.200    0.043    4.593    0.000    1.000    1.000
    factor2           0.186    0.037    5.039    0.000    1.000    1.000
    factor3           0.436    0.091    4.812    0.000    1.000    1.000

結果判讀

強迫factor間設為不相關模型應該會更糟,因為破壞了原來的結構

knitr::include_graphics("0_covariance.png")

果不其然CFA:0.446、TLI:0.372,比前面的模型更糟糕

CFA再試一次

這次選WSSQ,WSSQ1WSSQ6設為factor1、WSSQ7WSSQ12設為factor2

WSSQ.model <-
' 
  factor1 =~ WSSQ1+WSSQ2+WSSQ3+ WSSQ4+ WSSQ5+WSSQ6   
  factor2 =~ WSSQ7+WSSQ8+WSSQ9+ WSSQ10+ WSSQ11+WSSQ12  
'
fit<-cfa(WSSQ.model, data=dta)
summary(fit,fit.measures=T, standardized=T)
lavaan 0.6-9 ended normally after 36 iterations

  Estimator                                         ML
  Optimization method                           NLMINB
  Number of model parameters                        25
                                                      
  Number of observations                           325
                                                      
Model Test User Model:
                                                      
  Test statistic                               273.552
  Degrees of freedom                                53
  P-value (Chi-square)                           0.000

Model Test Baseline Model:

  Test statistic                              2668.151
  Degrees of freedom                                66
  P-value                                        0.000

User Model versus Baseline Model:

  Comparative Fit Index (CFI)                    0.915
  Tucker-Lewis Index (TLI)                       0.894

Loglikelihood and Information Criteria:

  Loglikelihood user model (H0)              -5683.696
  Loglikelihood unrestricted model (H1)      -5546.920
                                                      
  Akaike (AIC)                               11417.391
  Bayesian (BIC)                             11511.987
  Sample-size adjusted Bayesian (BIC)        11432.689

Root Mean Square Error of Approximation:

  RMSEA                                          0.113
  90 Percent confidence interval - lower         0.100
  90 Percent confidence interval - upper         0.127
  P-value RMSEA <= 0.05                          0.000

Standardized Root Mean Square Residual:

  SRMR                                           0.056

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
  factor1 =~                                                            
    WSSQ1             1.000                               0.992    0.664
    WSSQ2             1.336    0.102   13.035    0.000    1.326    0.828
    WSSQ3             1.281    0.095   13.467    0.000    1.271    0.863
    WSSQ4             1.085    0.089   12.225    0.000    1.077    0.767
    WSSQ5             0.942    0.090   10.427    0.000    0.935    0.638
    WSSQ6             1.132    0.094   12.093    0.000    1.123    0.757
  factor2 =~                                                            
    WSSQ7             1.000                               0.853    0.587
    WSSQ8             1.212    0.109   11.112    0.000    1.034    0.816
    WSSQ9             1.131    0.104   10.872    0.000    0.964    0.788
    WSSQ10            1.444    0.134   10.810    0.000    1.231    0.781
    WSSQ11            1.281    0.114   11.196    0.000    1.092    0.827
    WSSQ12            1.224    0.109   11.245    0.000    1.044    0.833

Covariances:
                   Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
  factor1 ~~                                                            
    factor2           0.738    0.099    7.459    0.000    0.873    0.873

Variances:
                   Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
   .WSSQ1             1.247    0.105   11.875    0.000    1.247    0.559
   .WSSQ2             0.803    0.078   10.294    0.000    0.803    0.314
   .WSSQ3             0.552    0.058    9.460    0.000    0.552    0.255
   .WSSQ4             0.814    0.073   11.161    0.000    0.814    0.412
   .WSSQ5             1.270    0.106   11.988    0.000    1.270    0.593
   .WSSQ6             0.941    0.084   11.256    0.000    0.941    0.427
   .WSSQ7             1.384    0.113   12.203    0.000    1.384    0.656
   .WSSQ8             0.535    0.050   10.654    0.000    0.535    0.334
   .WSSQ9             0.568    0.051   11.034    0.000    0.568    0.379
   .WSSQ10            0.970    0.087   11.114    0.000    0.970    0.390
   .WSSQ11            0.552    0.053   10.483    0.000    0.552    0.317
   .WSSQ12            0.482    0.046   10.373    0.000    0.482    0.307
    factor1           0.985    0.150    6.558    0.000    1.000    1.000
    factor2           0.727    0.129    5.624    0.000    1.000    1.000

結果判讀

Comparative Fit Index (CFI) 0.915(>0.9,好!)

Tucker-Lewis Index (TLI) 0.894(快要>0.9,有機會調整)

RMSEA 0.113(快要<0.08,有機會調整)

SRMR 0.056(<0.08,好!)

調整模型

運用指令modindices,表示: Modification Indices for Models

modindices(fit)  #請幫我檢查如何幫我把fit適配度變好
        lhs op    rhs     mi    epc sepc.lv sepc.all sepc.nox
28  factor1 =~  WSSQ7 60.931  1.452   1.441    0.992    0.992
29  factor1 =~  WSSQ8  0.423  0.085   0.085    0.067    0.067
30  factor1 =~  WSSQ9  0.753 -0.113  -0.113   -0.092   -0.092
31  factor1 =~ WSSQ10  1.358  0.198   0.196    0.124    0.124
32  factor1 =~ WSSQ11  8.368 -0.391  -0.388   -0.294   -0.294
33  factor1 =~ WSSQ12  5.734 -0.305  -0.303   -0.242   -0.242
34  factor2 =~  WSSQ1  0.087  0.062   0.053    0.035    0.035
35  factor2 =~  WSSQ2 14.230 -0.737  -0.629   -0.393   -0.393
36  factor2 =~  WSSQ3  0.295  0.096   0.081    0.055    0.055
37  factor2 =~  WSSQ4  2.819  0.304   0.260    0.185    0.185
38  factor2 =~  WSSQ5  2.598  0.340   0.290    0.198    0.198
39  factor2 =~  WSSQ6  0.297  0.105   0.090    0.061    0.061
40    WSSQ1 ~~  WSSQ2  7.669  0.182   0.182    0.182    0.182
41    WSSQ1 ~~  WSSQ3  3.472 -0.107  -0.107   -0.129   -0.129
42    WSSQ1 ~~  WSSQ4  4.622  0.135   0.135    0.134    0.134
43    WSSQ1 ~~  WSSQ5  9.820 -0.236  -0.236   -0.187   -0.187
44    WSSQ1 ~~  WSSQ6  1.223 -0.074  -0.074   -0.069   -0.069
45    WSSQ1 ~~  WSSQ7  2.957 -0.132  -0.132   -0.101   -0.101
46    WSSQ1 ~~  WSSQ8  0.919 -0.049  -0.049   -0.060   -0.060
47    WSSQ1 ~~  WSSQ9  3.068  0.090   0.090    0.107    0.107
48    WSSQ1 ~~ WSSQ10  0.710 -0.057  -0.057   -0.052   -0.052
49    WSSQ1 ~~ WSSQ11  0.056  0.012   0.012    0.015    0.015
50    WSSQ1 ~~ WSSQ12  1.177  0.053   0.053    0.068    0.068
51    WSSQ2 ~~  WSSQ3 28.094  0.290   0.290    0.435    0.435
52    WSSQ2 ~~  WSSQ4  6.344 -0.142  -0.142   -0.176   -0.176
53    WSSQ2 ~~  WSSQ5 12.556 -0.233  -0.233   -0.231   -0.231
54    WSSQ2 ~~  WSSQ6  0.762  0.053   0.053    0.060    0.060
55    WSSQ2 ~~  WSSQ7  6.696  0.170   0.170    0.162    0.162
56    WSSQ2 ~~  WSSQ8  2.227 -0.065  -0.065   -0.100   -0.100
57    WSSQ2 ~~  WSSQ9 10.368 -0.143  -0.143   -0.212   -0.212
58    WSSQ2 ~~ WSSQ10  6.422  0.146   0.146    0.166    0.166
59    WSSQ2 ~~ WSSQ11  0.338 -0.026  -0.026   -0.039   -0.039
60    WSSQ2 ~~ WSSQ12  6.512 -0.108  -0.108   -0.173   -0.173
61    WSSQ3 ~~  WSSQ4  4.089 -0.101  -0.101   -0.151   -0.151
62    WSSQ3 ~~  WSSQ5  0.217 -0.027  -0.027   -0.032   -0.032
63    WSSQ3 ~~  WSSQ6  7.732 -0.148  -0.148   -0.205   -0.205
64    WSSQ3 ~~  WSSQ7 18.031  0.241   0.241    0.275    0.275
65    WSSQ3 ~~  WSSQ8  0.913  0.036   0.036    0.066    0.066
66    WSSQ3 ~~  WSSQ9  0.923  0.037   0.037    0.066    0.066
67    WSSQ3 ~~ WSSQ10  1.656 -0.064  -0.064   -0.088   -0.088
68    WSSQ3 ~~ WSSQ11  1.680 -0.050  -0.050   -0.091   -0.091
69    WSSQ3 ~~ WSSQ12  1.146 -0.039  -0.039   -0.076   -0.076
70    WSSQ4 ~~  WSSQ5  4.307  0.131   0.131    0.129    0.129
71    WSSQ4 ~~  WSSQ6  0.094  0.017   0.017    0.020    0.020
72    WSSQ4 ~~  WSSQ7  4.562 -0.136  -0.136   -0.129   -0.129
73    WSSQ4 ~~  WSSQ8  0.548  0.031   0.031    0.048    0.048
74    WSSQ4 ~~  WSSQ9  1.527  0.053   0.053    0.078    0.078
75    WSSQ4 ~~ WSSQ10  0.623 -0.044  -0.044   -0.050   -0.050
76    WSSQ4 ~~ WSSQ11  3.712  0.084   0.084    0.125    0.125
77    WSSQ4 ~~ WSSQ12  0.011 -0.004  -0.004   -0.007   -0.007
78    WSSQ5 ~~  WSSQ6 10.805  0.222   0.222    0.203    0.203
79    WSSQ5 ~~  WSSQ7  6.452  0.196   0.196    0.148    0.148
80    WSSQ5 ~~  WSSQ8  5.538  0.120   0.120    0.146    0.146
81    WSSQ5 ~~  WSSQ9  0.005 -0.004  -0.004   -0.004   -0.004
82    WSSQ5 ~~ WSSQ10  3.214 -0.121  -0.121   -0.109   -0.109
83    WSSQ5 ~~ WSSQ11  0.599 -0.041  -0.041   -0.048   -0.048
84    WSSQ5 ~~ WSSQ12  0.326  0.028   0.028    0.036    0.036
85    WSSQ6 ~~  WSSQ7 12.328  0.240   0.240    0.211    0.211
86    WSSQ6 ~~  WSSQ8  0.135 -0.017  -0.017   -0.024   -0.024
87    WSSQ6 ~~  WSSQ9  1.237 -0.051  -0.051   -0.070   -0.070
88    WSSQ6 ~~ WSSQ10  8.982  0.180   0.180    0.188    0.188
89    WSSQ6 ~~ WSSQ11  8.235 -0.133  -0.133   -0.185   -0.185
90    WSSQ6 ~~ WSSQ12  0.101  0.014   0.014    0.021    0.021
91    WSSQ7 ~~  WSSQ8  1.413  0.064   0.064    0.075    0.075
92    WSSQ7 ~~  WSSQ9  0.002 -0.003  -0.003   -0.003   -0.003
93    WSSQ7 ~~ WSSQ10  0.438 -0.047  -0.047   -0.041   -0.041
94    WSSQ7 ~~ WSSQ11 27.676 -0.292  -0.292   -0.334   -0.334
95    WSSQ7 ~~ WSSQ12  9.531 -0.161  -0.161   -0.197   -0.197
96    WSSQ8 ~~  WSSQ9  6.309  0.095   0.095    0.172    0.172
97    WSSQ8 ~~ WSSQ10 23.333 -0.237  -0.237   -0.329   -0.329
98    WSSQ8 ~~ WSSQ11  1.406  0.046   0.046    0.085    0.085
99    WSSQ8 ~~ WSSQ12  0.217 -0.017  -0.017   -0.034   -0.034
100   WSSQ9 ~~ WSSQ10  4.453 -0.104  -0.104   -0.140   -0.140
101   WSSQ9 ~~ WSSQ11  0.083 -0.011  -0.011   -0.020   -0.020
102   WSSQ9 ~~ WSSQ12  0.378  0.023   0.023    0.043    0.043
103  WSSQ10 ~~ WSSQ11 11.556  0.172   0.172    0.235    0.235
104  WSSQ10 ~~ WSSQ12  5.655  0.113   0.113    0.166    0.166
105  WSSQ11 ~~ WSSQ12  3.688  0.073   0.073    0.141    0.141
knitr::include_graphics("mi1.png")

mi越大多做這件事,就會進步越多(mi做了卡方值下降多少),通常mi值>3.84,就會降卡方值(因為卡方值>3.84就會顯著)

WSSQ7訂在factor1,卡方會下降60.931

WSSQ2~~WSSQ3做一個相關,卡方值會再下降28.094

優先處理大的→60.931

mi一次處理一條,然後再看一次modindices(fit),一旦動了一個部分,其他數值都會變,modindices應該重做

WSSQ.model <-
' factor1 =~ WSSQ1+WSSQ2+WSSQ3+ WSSQ4+ WSSQ5+WSSQ6+WSSQ7  
factor2 =~ WSSQ8+WSSQ9+ WSSQ10+ WSSQ11+WSSQ12  
'
fit<-cfa(WSSQ.model, data=dta)
summary(fit,fit.measures=T, standardized=T)
lavaan 0.6-9 ended normally after 32 iterations

  Estimator                                         ML
  Optimization method                           NLMINB
  Number of model parameters                        25
                                                      
  Number of observations                           325
                                                      
Model Test User Model:
                                                      
  Test statistic                               214.051
  Degrees of freedom                                53
  P-value (Chi-square)                           0.000

Model Test Baseline Model:

  Test statistic                              2668.151
  Degrees of freedom                                66
  P-value                                        0.000

User Model versus Baseline Model:

  Comparative Fit Index (CFI)                    0.938
  Tucker-Lewis Index (TLI)                       0.923

Loglikelihood and Information Criteria:

  Loglikelihood user model (H0)              -5653.946
  Loglikelihood unrestricted model (H1)      -5546.920
                                                      
  Akaike (AIC)                               11357.891
  Bayesian (BIC)                             11452.487
  Sample-size adjusted Bayesian (BIC)        11373.189

Root Mean Square Error of Approximation:

  RMSEA                                          0.097
  90 Percent confidence interval - lower         0.083
  90 Percent confidence interval - upper         0.110
  P-value RMSEA <= 0.05                          0.000

Standardized Root Mean Square Residual:

  SRMR                                           0.043

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
  factor1 =~                                                            
    WSSQ1             1.000                               0.977    0.654
    WSSQ2             1.362    0.106   12.869    0.000    1.331    0.832
    WSSQ3             1.312    0.098   13.331    0.000    1.283    0.871
    WSSQ4             1.085    0.091   11.908    0.000    1.061    0.755
    WSSQ5             0.964    0.093   10.398    0.000    0.942    0.643
    WSSQ6             1.158    0.096   12.006    0.000    1.132    0.763
    WSSQ7             1.016    0.093   10.951    0.000    0.993    0.683
  factor2 =~                                                            
    WSSQ8             1.000                               1.030    0.813
    WSSQ9             0.937    0.058   16.085    0.000    0.965    0.788
    WSSQ10            1.199    0.075   15.943    0.000    1.235    0.783
    WSSQ11            1.078    0.061   17.578    0.000    1.110    0.840
    WSSQ12            1.025    0.058   17.627    0.000    1.055    0.842

Covariances:
                   Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
  factor1 ~~                                                            
    factor2           0.847    0.100    8.475    0.000    0.841    0.841

Variances:
                   Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
   .WSSQ1             1.277    0.107   11.964    0.000    1.277    0.572
   .WSSQ2             0.789    0.076   10.365    0.000    0.789    0.308
   .WSSQ3             0.522    0.056    9.405    0.000    0.522    0.241
   .WSSQ4             0.848    0.075   11.350    0.000    0.848    0.430
   .WSSQ5             1.256    0.105   12.008    0.000    1.256    0.586
   .WSSQ6             0.921    0.082   11.282    0.000    0.921    0.418
   .WSSQ7             1.125    0.095   11.829    0.000    1.125    0.533
   .WSSQ8             0.543    0.051   10.606    0.000    0.543    0.338
   .WSSQ9             0.567    0.052   10.953    0.000    0.567    0.378
   .WSSQ10            0.960    0.087   11.013    0.000    0.960    0.386
   .WSSQ11            0.513    0.051   10.110    0.000    0.513    0.294
   .WSSQ12            0.458    0.045   10.074    0.000    0.458    0.291
    factor1           0.955    0.148    6.444    0.000    1.000    1.000
    factor2           1.061    0.122    8.715    0.000    1.000    1.000
modindices(fit)  #請幫我檢查如何幫我把fit適配度變好
        lhs op    rhs     mi    epc sepc.lv sepc.all sepc.nox
28  factor1 =~  WSSQ8  5.611  0.269   0.263    0.207    0.207
29  factor1 =~  WSSQ9  0.249  0.056   0.055    0.045    0.045
30  factor1 =~ WSSQ10  4.099  0.296   0.289    0.183    0.183
31  factor1 =~ WSSQ11  8.038 -0.326  -0.319   -0.241   -0.241
32  factor1 =~ WSSQ12  2.577 -0.175  -0.171   -0.136   -0.136
33  factor2 =~  WSSQ1  1.563  0.186   0.192    0.128    0.128
34  factor2 =~  WSSQ2  9.742 -0.412  -0.425   -0.265   -0.265
35  factor2 =~  WSSQ3  0.059  0.028   0.029    0.020    0.020
36  factor2 =~  WSSQ4  7.751  0.353   0.363    0.259    0.259
37  factor2 =~  WSSQ5  1.667  0.190   0.196    0.134    0.134
38  factor2 =~  WSSQ6  0.070  0.035   0.036    0.024    0.024
39  factor2 =~  WSSQ7  3.548 -0.266  -0.274   -0.188   -0.188
40    WSSQ1 ~~  WSSQ2  9.194  0.198   0.198    0.197    0.197
41    WSSQ1 ~~  WSSQ3  2.825 -0.095  -0.095   -0.116   -0.116
42    WSSQ1 ~~  WSSQ4  7.042  0.170   0.170    0.163    0.163
43    WSSQ1 ~~  WSSQ5  8.994 -0.225  -0.225   -0.178   -0.178
44    WSSQ1 ~~  WSSQ6  0.902 -0.064  -0.064   -0.059   -0.059
45    WSSQ1 ~~  WSSQ7  7.362 -0.195  -0.195   -0.163   -0.163
46    WSSQ1 ~~  WSSQ8  1.130 -0.055  -0.055   -0.066   -0.066
47    WSSQ1 ~~  WSSQ9  2.793  0.087   0.087    0.102    0.102
48    WSSQ1 ~~ WSSQ10  0.757 -0.059  -0.059   -0.053   -0.053
49    WSSQ1 ~~ WSSQ11  0.173  0.021   0.021    0.026    0.026
50    WSSQ1 ~~ WSSQ12  1.333  0.056   0.056    0.073    0.073
51    WSSQ2 ~~  WSSQ3 20.594  0.237   0.237    0.370    0.370
52    WSSQ2 ~~  WSSQ4  4.063 -0.113  -0.113   -0.138   -0.138
53    WSSQ2 ~~  WSSQ5 15.149 -0.251  -0.251   -0.252   -0.252
54    WSSQ2 ~~  WSSQ6  0.174  0.024   0.024    0.029    0.029
55    WSSQ2 ~~  WSSQ7  0.047 -0.013  -0.013   -0.014   -0.014
56    WSSQ2 ~~  WSSQ8  1.715 -0.057  -0.057   -0.087   -0.087
57    WSSQ2 ~~  WSSQ9  8.741 -0.130  -0.130   -0.194   -0.194
58    WSSQ2 ~~ WSSQ10  8.291  0.164   0.164    0.188    0.188
59    WSSQ2 ~~ WSSQ11  0.075  0.012   0.012    0.019    0.019
60    WSSQ2 ~~ WSSQ12  4.086 -0.083  -0.083   -0.138   -0.138
61    WSSQ3 ~~  WSSQ4  2.953 -0.084  -0.084   -0.126   -0.126
62    WSSQ3 ~~  WSSQ5  1.099 -0.058  -0.058   -0.072   -0.072
63    WSSQ3 ~~  WSSQ6 13.942 -0.191  -0.191   -0.276   -0.276
64    WSSQ3 ~~  WSSQ7  6.001  0.131   0.131    0.171    0.171
65    WSSQ3 ~~  WSSQ8  1.198  0.041   0.041    0.076    0.076
66    WSSQ3 ~~  WSSQ9  1.566  0.047   0.047    0.086    0.086
67    WSSQ3 ~~ WSSQ10  1.115 -0.051  -0.051   -0.072   -0.072
68    WSSQ3 ~~ WSSQ11  0.212 -0.017  -0.017   -0.033   -0.033
69    WSSQ3 ~~ WSSQ12  0.249 -0.017  -0.017   -0.036   -0.036
70    WSSQ4 ~~  WSSQ5  4.644  0.136   0.136    0.132    0.132
71    WSSQ4 ~~  WSSQ6  0.252  0.028   0.028    0.032    0.032
72    WSSQ4 ~~  WSSQ7  9.672 -0.188  -0.188   -0.193   -0.193
73    WSSQ4 ~~  WSSQ8  0.279  0.023   0.023    0.034    0.034
74    WSSQ4 ~~  WSSQ9  1.226  0.048   0.048    0.070    0.070
75    WSSQ4 ~~ WSSQ10  0.699 -0.047  -0.047   -0.052   -0.052
76    WSSQ4 ~~ WSSQ11  4.717  0.093   0.093    0.142    0.142
77    WSSQ4 ~~ WSSQ12  0.005 -0.003  -0.003   -0.005   -0.005
78    WSSQ5 ~~  WSSQ6  9.125  0.200   0.200    0.186    0.186
79    WSSQ5 ~~  WSSQ7  4.951  0.158   0.158    0.133    0.133
80    WSSQ5 ~~  WSSQ8  5.876  0.124   0.124    0.150    0.150
81    WSSQ5 ~~  WSSQ9  0.003  0.003   0.003    0.004    0.004
82    WSSQ5 ~~ WSSQ10  2.823 -0.113  -0.113   -0.103   -0.103
83    WSSQ5 ~~ WSSQ11  0.170 -0.021  -0.021   -0.026   -0.026
84    WSSQ5 ~~ WSSQ12  0.777  0.042   0.042    0.056    0.056
85    WSSQ6 ~~  WSSQ7  6.458  0.161   0.161    0.158    0.158
86    WSSQ6 ~~  WSSQ8  0.044 -0.010  -0.010   -0.013   -0.013
87    WSSQ6 ~~  WSSQ9  0.794 -0.041  -0.041   -0.056   -0.056
88    WSSQ6 ~~ WSSQ10 10.855  0.195   0.195    0.207    0.207
89    WSSQ6 ~~ WSSQ11  5.676 -0.107  -0.107   -0.156   -0.156
90    WSSQ6 ~~ WSSQ12  0.672  0.035   0.035    0.054    0.054
91    WSSQ7 ~~  WSSQ8  4.509  0.104   0.104    0.133    0.133
92    WSSQ7 ~~  WSSQ9  1.542  0.061   0.061    0.076    0.076
93    WSSQ7 ~~ WSSQ10  0.017 -0.008  -0.008   -0.008   -0.008
94    WSSQ7 ~~ WSSQ11 12.614 -0.172  -0.172   -0.227   -0.227
95    WSSQ7 ~~ WSSQ12  1.682 -0.060  -0.060   -0.083   -0.083
96    WSSQ8 ~~  WSSQ9  7.031  0.102   0.102    0.184    0.184
97    WSSQ8 ~~ WSSQ10 23.634 -0.242  -0.242   -0.336   -0.336
98    WSSQ8 ~~ WSSQ11  0.371  0.024   0.024    0.045    0.045
99    WSSQ8 ~~ WSSQ12  0.768 -0.033  -0.033   -0.066   -0.066
100   WSSQ9 ~~ WSSQ10  5.182 -0.113  -0.113   -0.153   -0.153
101   WSSQ9 ~~ WSSQ11  1.171 -0.042  -0.042   -0.078   -0.078
102   WSSQ9 ~~ WSSQ12  0.015  0.004   0.004    0.009    0.009
103  WSSQ10 ~~ WSSQ11  7.908  0.142   0.142    0.202    0.202
104  WSSQ10 ~~ WSSQ12  3.592  0.090   0.090    0.136    0.136
105  WSSQ11 ~~ WSSQ12  0.280  0.020   0.020    0.042    0.042
WSSQ.model <-
' factor1 =~ WSSQ1+WSSQ2+WSSQ3+ WSSQ4+ WSSQ5+WSSQ6+WSSQ7  
factor2 =~ WSSQ8+WSSQ9+ WSSQ10+ WSSQ11+WSSQ12  
WSSQ8 ~~ WSSQ10
'
fit<-cfa(WSSQ.model, data=dta)
summary(fit,fit.measures=T, standardized=T)
lavaan 0.6-9 ended normally after 31 iterations

  Estimator                                         ML
  Optimization method                           NLMINB
  Number of model parameters                        26
                                                      
  Number of observations                           325
                                                      
Model Test User Model:
                                                      
  Test statistic                               186.881
  Degrees of freedom                                52
  P-value (Chi-square)                           0.000

Model Test Baseline Model:

  Test statistic                              2668.151
  Degrees of freedom                                66
  P-value                                        0.000

User Model versus Baseline Model:

  Comparative Fit Index (CFI)                    0.948
  Tucker-Lewis Index (TLI)                       0.934

Loglikelihood and Information Criteria:

  Loglikelihood user model (H0)              -5640.360
  Loglikelihood unrestricted model (H1)      -5546.920
                                                      
  Akaike (AIC)                               11332.721
  Bayesian (BIC)                             11431.100
  Sample-size adjusted Bayesian (BIC)        11348.630

Root Mean Square Error of Approximation:

  RMSEA                                          0.089
  90 Percent confidence interval - lower         0.076
  90 Percent confidence interval - upper         0.103
  P-value RMSEA <= 0.05                          0.000

Standardized Root Mean Square Residual:

  SRMR                                           0.041

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
  factor1 =~                                                            
    WSSQ1             1.000                               0.974    0.652
    WSSQ2             1.367    0.107   12.832    0.000    1.332    0.832
    WSSQ3             1.315    0.099   13.272    0.000    1.281    0.870
    WSSQ4             1.087    0.092   11.860    0.000    1.059    0.754
    WSSQ5             0.967    0.093   10.379    0.000    0.942    0.644
    WSSQ6             1.165    0.097   11.995    0.000    1.135    0.765
    WSSQ7             1.021    0.093   10.942    0.000    0.995    0.685
  factor2 =~                                                            
    WSSQ8             1.000                               1.063    0.839
    WSSQ9             0.895    0.055   16.386    0.000    0.952    0.778
    WSSQ10            1.205    0.081   14.926    0.000    1.281    0.813
    WSSQ11            1.038    0.057   18.221    0.000    1.103    0.835
    WSSQ12            0.980    0.054   18.061    0.000    1.041    0.831

Covariances:
                   Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
 .WSSQ8 ~~                                                              
   .WSSQ10           -0.247    0.046   -5.419    0.000   -0.247   -0.391
  factor1 ~~                                                            
    factor2           0.872    0.102    8.569    0.000    0.842    0.842

Variances:
                   Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
   .WSSQ1             1.283    0.107   11.980    0.000    1.283    0.575
   .WSSQ2             0.786    0.076   10.378    0.000    0.786    0.307
   .WSSQ3             0.526    0.056    9.466    0.000    0.526    0.243
   .WSSQ4             0.851    0.075   11.372    0.000    0.851    0.431
   .WSSQ5             1.255    0.104   12.014    0.000    1.255    0.586
   .WSSQ6             0.915    0.081   11.278    0.000    0.915    0.415
   .WSSQ7             1.121    0.095   11.831    0.000    1.121    0.531
   .WSSQ8             0.473    0.049    9.700    0.000    0.473    0.295
   .WSSQ9             0.592    0.052   11.388    0.000    0.592    0.395
   .WSSQ10            0.843    0.083   10.159    0.000    0.843    0.339
   .WSSQ11            0.527    0.050   10.638    0.000    0.527    0.302
   .WSSQ12            0.487    0.045   10.723    0.000    0.487    0.310
    factor1           0.949    0.148    6.420    0.000    1.000    1.000
    factor2           1.130    0.124    9.093    0.000    1.000    1.000
modindices(fit)    
        lhs op    rhs     mi    epc sepc.lv sepc.all sepc.nox
29  factor1 =~  WSSQ8  2.694  0.197   0.192    0.151    0.151
30  factor1 =~  WSSQ9  0.830  0.101   0.098    0.080    0.080
31  factor1 =~ WSSQ10  1.696  0.201   0.196    0.124    0.124
32  factor1 =~ WSSQ11  6.028 -0.273  -0.266   -0.201   -0.201
33  factor1 =~ WSSQ12  0.810 -0.095  -0.093   -0.074   -0.074
34  factor2 =~  WSSQ1  0.726  0.120   0.128    0.086    0.086
35  factor2 =~  WSSQ2  8.388 -0.363  -0.386   -0.241   -0.241
36  factor2 =~  WSSQ3  0.007  0.009   0.010    0.007    0.007
37  factor2 =~  WSSQ4  6.432  0.305   0.324    0.231    0.231
38  factor2 =~  WSSQ5  1.582  0.175   0.186    0.127    0.127
39  factor2 =~  WSSQ6  0.331  0.072   0.077    0.052    0.052
40  factor2 =~  WSSQ7  2.636 -0.217  -0.230   -0.159   -0.159
41    WSSQ1 ~~  WSSQ2  9.550  0.201   0.201    0.201    0.201
42    WSSQ1 ~~  WSSQ3  2.309 -0.086  -0.086   -0.104   -0.104
43    WSSQ1 ~~  WSSQ4  7.426  0.175   0.175    0.167    0.167
44    WSSQ1 ~~  WSSQ5  8.700 -0.222  -0.222   -0.175   -0.175
45    WSSQ1 ~~  WSSQ6  0.880 -0.063  -0.063   -0.058   -0.058
46    WSSQ1 ~~  WSSQ7  7.236 -0.193  -0.193   -0.161   -0.161
47    WSSQ1 ~~  WSSQ8  2.646 -0.081  -0.081   -0.104   -0.104
48    WSSQ1 ~~  WSSQ9  3.734  0.101   0.101    0.116    0.116
49    WSSQ1 ~~ WSSQ10  2.218 -0.097  -0.097   -0.094   -0.094
50    WSSQ1 ~~ WSSQ11  0.579  0.039   0.039    0.047    0.047
51    WSSQ1 ~~ WSSQ12  2.203  0.072   0.072    0.091    0.091
52    WSSQ2 ~~  WSSQ3 20.422  0.235   0.235    0.366    0.366
53    WSSQ2 ~~  WSSQ4  3.952 -0.111  -0.111   -0.135   -0.135
54    WSSQ2 ~~  WSSQ5 15.385 -0.252  -0.252   -0.254   -0.254
55    WSSQ2 ~~  WSSQ6  0.083  0.017   0.017    0.020    0.020
56    WSSQ2 ~~  WSSQ7  0.089 -0.018  -0.018   -0.020   -0.020
57    WSSQ2 ~~  WSSQ8  0.859 -0.039  -0.039   -0.064   -0.064
58    WSSQ2 ~~  WSSQ9  8.198 -0.125  -0.125   -0.184   -0.184
59    WSSQ2 ~~ WSSQ10  5.757  0.132   0.132    0.162    0.162
60    WSSQ2 ~~ WSSQ11  0.027  0.007   0.007    0.011    0.011
61    WSSQ2 ~~ WSSQ12  3.754 -0.079  -0.079   -0.128   -0.128
62    WSSQ3 ~~  WSSQ4  2.516 -0.077  -0.077   -0.116   -0.116
63    WSSQ3 ~~  WSSQ5  1.035 -0.057  -0.057   -0.070   -0.070
64    WSSQ3 ~~  WSSQ6 14.412 -0.194  -0.194   -0.279   -0.279
65    WSSQ3 ~~  WSSQ7  5.761  0.128   0.128    0.167    0.167
66    WSSQ3 ~~  WSSQ8  0.179  0.015   0.015    0.031    0.031
67    WSSQ3 ~~  WSSQ9  2.113  0.054   0.054    0.097    0.097
68    WSSQ3 ~~ WSSQ10  1.717 -0.062  -0.062   -0.093   -0.093
69    WSSQ3 ~~ WSSQ11  0.049 -0.008  -0.008   -0.015   -0.015
70    WSSQ3 ~~ WSSQ12  0.024 -0.005  -0.005   -0.011   -0.011
71    WSSQ4 ~~  WSSQ5  4.695  0.137   0.137    0.133    0.133
72    WSSQ4 ~~  WSSQ6  0.217  0.026   0.026    0.030    0.030
73    WSSQ4 ~~  WSSQ7  9.736 -0.189  -0.189   -0.193   -0.193
74    WSSQ4 ~~  WSSQ8  0.000  0.001   0.001    0.001    0.001
75    WSSQ4 ~~  WSSQ9  1.678  0.057   0.057    0.080    0.080
76    WSSQ4 ~~ WSSQ10  1.179 -0.059  -0.059   -0.070   -0.070
77    WSSQ4 ~~ WSSQ11  5.276  0.097   0.097    0.146    0.146
78    WSSQ4 ~~ WSSQ12  0.045  0.009   0.009    0.013    0.013
79    WSSQ5 ~~  WSSQ6  8.842  0.196   0.196    0.183    0.183
80    WSSQ5 ~~  WSSQ7  4.810  0.155   0.155    0.131    0.131
81    WSSQ5 ~~  WSSQ8  3.760  0.096   0.096    0.124    0.124
82    WSSQ5 ~~  WSSQ9  0.015  0.006   0.006    0.007    0.007
83    WSSQ5 ~~ WSSQ10  1.755 -0.085  -0.085   -0.083   -0.083
84    WSSQ5 ~~ WSSQ11  0.134 -0.018  -0.018   -0.023   -0.023
85    WSSQ5 ~~ WSSQ12  0.817  0.044   0.044    0.056    0.056
86    WSSQ6 ~~  WSSQ7  6.015  0.155   0.155    0.153    0.153
87    WSSQ6 ~~  WSSQ8  0.236  0.021   0.021    0.032    0.032
88    WSSQ6 ~~  WSSQ9  1.017 -0.046  -0.046   -0.062   -0.062
89    WSSQ6 ~~ WSSQ10 10.654  0.186   0.186    0.211    0.211
90    WSSQ6 ~~ WSSQ11  6.510 -0.113  -0.113   -0.162   -0.162
91    WSSQ6 ~~ WSSQ12  0.338  0.025   0.025    0.037    0.037
92    WSSQ7 ~~  WSSQ8  4.396  0.099   0.099    0.135    0.135
93    WSSQ7 ~~  WSSQ9  1.175  0.053   0.053    0.066    0.066
94    WSSQ7 ~~ WSSQ10  0.090  0.018   0.018    0.019    0.019
95    WSSQ7 ~~ WSSQ11 12.947 -0.172  -0.172   -0.224   -0.224
96    WSSQ7 ~~ WSSQ12  1.854 -0.062  -0.062   -0.084   -0.084
97    WSSQ8 ~~  WSSQ9  0.840  0.037   0.037    0.070    0.070
98    WSSQ8 ~~ WSSQ11  0.101 -0.013  -0.013   -0.027   -0.027
99    WSSQ8 ~~ WSSQ12  4.370 -0.084  -0.084   -0.175   -0.175
100   WSSQ9 ~~ WSSQ10 10.260 -0.167  -0.167   -0.236   -0.236
101   WSSQ9 ~~ WSSQ11  0.029 -0.006  -0.006   -0.012   -0.012
102   WSSQ9 ~~ WSSQ12  1.488  0.044   0.044    0.082    0.082
103  WSSQ10 ~~ WSSQ11  2.277  0.082   0.082    0.123    0.123
104  WSSQ10 ~~ WSSQ12  0.020  0.007   0.007    0.011    0.011
105  WSSQ11 ~~ WSSQ12  2.241  0.055   0.055    0.109    0.109
WSSQ.model <-
' factor1 =~ WSSQ1+WSSQ2+WSSQ3+ WSSQ4+ WSSQ5+WSSQ6+WSSQ7  
factor2 =~ WSSQ8+WSSQ9+ WSSQ10+ WSSQ11+WSSQ12  
WSSQ8 ~~ WSSQ10
WSSQ2~~WSSQ3
'   
#每做一次mi(modification index,自由度就會-1
#mi值>3.84,通常會降卡方值
fit<-cfa(WSSQ.model, data=dta)
summary(fit,fit.measures=T, standardized=T)
lavaan 0.6-9 ended normally after 32 iterations

  Estimator                                         ML
  Optimization method                           NLMINB
  Number of model parameters                        27
                                                      
  Number of observations                           325
                                                      
Model Test User Model:
                                                      
  Test statistic                               167.785
  Degrees of freedom                                51
  P-value (Chi-square)                           0.000

Model Test Baseline Model:

  Test statistic                              2668.151
  Degrees of freedom                                66
  P-value                                        0.000

User Model versus Baseline Model:

  Comparative Fit Index (CFI)                    0.955
  Tucker-Lewis Index (TLI)                       0.942

Loglikelihood and Information Criteria:

  Loglikelihood user model (H0)              -5630.813
  Loglikelihood unrestricted model (H1)      -5546.920
                                                      
  Akaike (AIC)                               11315.625
  Bayesian (BIC)                             11417.788
  Sample-size adjusted Bayesian (BIC)        11332.147

Root Mean Square Error of Approximation:

  RMSEA                                          0.084
  90 Percent confidence interval - lower         0.070
  90 Percent confidence interval - upper         0.098
  P-value RMSEA <= 0.05                          0.000

Standardized Root Mean Square Residual:

  SRMR                                           0.038

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
  factor1 =~                                                            
    WSSQ1             1.000                               0.972    0.650
    WSSQ2             1.313    0.108   12.182    0.000    1.276    0.797
    WSSQ3             1.275    0.100   12.723    0.000    1.238    0.841
    WSSQ4             1.109    0.093   11.884    0.000    1.078    0.767
    WSSQ5             0.995    0.095   10.501    0.000    0.967    0.661
    WSSQ6             1.186    0.099   11.993    0.000    1.152    0.776
    WSSQ7             1.020    0.095   10.790    0.000    0.991    0.682
  factor2 =~                                                            
    WSSQ8             1.000                               1.064    0.840
    WSSQ9             0.896    0.054   16.434    0.000    0.953    0.779
    WSSQ10            1.203    0.081   14.925    0.000    1.280    0.812
    WSSQ11            1.036    0.057   18.223    0.000    1.102    0.835
    WSSQ12            0.980    0.054   18.106    0.000    1.042    0.831

Covariances:
                   Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
 .WSSQ8 ~~                                                              
   .WSSQ10           -0.246    0.045   -5.402    0.000   -0.246   -0.389
 .WSSQ2 ~~                                                              
   .WSSQ3             0.238    0.061    3.922    0.000    0.238    0.309
  factor1 ~~                                                            
    factor2           0.884    0.103    8.573    0.000    0.855    0.855

Variances:
                   Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
   .WSSQ1             1.288    0.109   11.861    0.000    1.288    0.577
   .WSSQ2             0.934    0.091   10.283    0.000    0.934    0.365
   .WSSQ3             0.634    0.066    9.548    0.000    0.634    0.292
   .WSSQ4             0.811    0.074   10.999    0.000    0.811    0.411
   .WSSQ5             1.208    0.102   11.811    0.000    1.208    0.564
   .WSSQ6             0.876    0.080   10.894    0.000    0.876    0.398
   .WSSQ7             1.128    0.097   11.693    0.000    1.128    0.535
   .WSSQ8             0.472    0.049    9.709    0.000    0.472    0.294
   .WSSQ9             0.590    0.052   11.384    0.000    0.590    0.394
   .WSSQ10            0.848    0.083   10.192    0.000    0.848    0.341
   .WSSQ11            0.529    0.050   10.660    0.000    0.529    0.303
   .WSSQ12            0.486    0.045   10.722    0.000    0.486    0.309
    factor1           0.944    0.148    6.360    0.000    1.000    1.000
    factor2           1.131    0.124    9.104    0.000    1.000    1.000
modindices(fit)   
        lhs op    rhs     mi    epc sepc.lv sepc.all sepc.nox
30  factor1 =~  WSSQ8  2.881  0.221   0.215    0.170    0.170
31  factor1 =~  WSSQ9  1.133  0.128   0.124    0.101    0.101
32  factor1 =~ WSSQ10  1.322  0.194   0.188    0.119    0.119
33  factor1 =~ WSSQ11  6.954 -0.319  -0.310   -0.235   -0.235
34  factor1 =~ WSSQ12  0.603 -0.090  -0.087   -0.069   -0.069
35  factor2 =~  WSSQ1  0.358  0.093   0.099    0.066    0.066
36  factor2 =~  WSSQ2  3.331 -0.240  -0.255   -0.160   -0.160
37  factor2 =~  WSSQ3  2.789  0.192   0.204    0.139    0.139
38  factor2 =~  WSSQ4  2.588  0.214   0.228    0.162    0.162
39  factor2 =~  WSSQ5  0.082  0.043   0.046    0.031    0.031
40  factor2 =~  WSSQ6  0.354 -0.083  -0.088   -0.060   -0.060
41  factor2 =~  WSSQ7  4.325 -0.307  -0.326   -0.224   -0.224
42    WSSQ1 ~~  WSSQ2 15.961  0.255   0.255    0.232    0.232
43    WSSQ1 ~~  WSSQ3  2.306 -0.083  -0.083   -0.092   -0.092
44    WSSQ1 ~~  WSSQ4  6.596  0.166   0.166    0.162    0.162
45    WSSQ1 ~~  WSSQ5 11.465 -0.255  -0.255   -0.204   -0.204
46    WSSQ1 ~~  WSSQ6  1.551 -0.084  -0.084   -0.079   -0.079
47    WSSQ1 ~~  WSSQ7  6.796 -0.191  -0.191   -0.158   -0.158
48    WSSQ1 ~~  WSSQ8  2.887 -0.085  -0.085   -0.110   -0.110
49    WSSQ1 ~~  WSSQ9  3.432  0.098   0.098    0.112    0.112
50    WSSQ1 ~~ WSSQ10  2.151 -0.097  -0.097   -0.093   -0.093
51    WSSQ1 ~~ WSSQ11  0.519  0.037   0.037    0.045    0.045
52    WSSQ1 ~~ WSSQ12  1.840  0.067   0.067    0.084    0.084
53    WSSQ2 ~~  WSSQ4  0.539 -0.040  -0.040   -0.045   -0.045
54    WSSQ2 ~~  WSSQ5  9.147 -0.187  -0.187   -0.176   -0.176
55    WSSQ2 ~~  WSSQ6  4.362  0.118   0.118    0.130    0.130
56    WSSQ2 ~~  WSSQ7  0.000  0.000   0.000    0.000    0.000
57    WSSQ2 ~~  WSSQ8  0.439 -0.027  -0.027   -0.041   -0.041
58    WSSQ2 ~~  WSSQ9  8.465 -0.124  -0.124   -0.168   -0.168
59    WSSQ2 ~~ WSSQ10  8.291  0.155   0.155    0.174    0.174
60    WSSQ2 ~~ WSSQ11  0.108  0.014   0.014    0.019    0.019
61    WSSQ2 ~~ WSSQ12  2.801 -0.067  -0.067   -0.099   -0.099
62    WSSQ3 ~~  WSSQ4  0.170 -0.019  -0.019   -0.027   -0.027
63    WSSQ3 ~~  WSSQ5  0.130  0.019   0.019    0.022    0.022
64    WSSQ3 ~~  WSSQ6  9.271 -0.149  -0.149   -0.200   -0.200
65    WSSQ3 ~~  WSSQ7  9.280  0.158   0.158    0.187    0.187
66    WSSQ3 ~~  WSSQ8  0.828  0.032   0.032    0.058    0.058
67    WSSQ3 ~~  WSSQ9  4.740  0.079   0.079    0.130    0.130
68    WSSQ3 ~~ WSSQ10  2.245 -0.069  -0.069   -0.094   -0.094
69    WSSQ3 ~~ WSSQ11  0.020 -0.005  -0.005   -0.009   -0.009
70    WSSQ3 ~~ WSSQ12  0.165  0.014   0.014    0.025    0.025
71    WSSQ4 ~~  WSSQ5  2.041  0.090   0.090    0.091    0.091
72    WSSQ4 ~~  WSSQ6  0.258 -0.029  -0.029   -0.034   -0.034
73    WSSQ4 ~~  WSSQ7 12.913 -0.220  -0.220   -0.230   -0.230
74    WSSQ4 ~~  WSSQ8  0.092 -0.013  -0.013   -0.020   -0.020
75    WSSQ4 ~~  WSSQ9  1.241  0.048   0.048    0.070    0.070
76    WSSQ4 ~~ WSSQ10  1.694 -0.071  -0.071   -0.086   -0.086
77    WSSQ4 ~~ WSSQ11  4.968  0.094   0.094    0.144    0.144
78    WSSQ4 ~~ WSSQ12  0.007 -0.003  -0.003   -0.005   -0.005
79    WSSQ5 ~~  WSSQ6  5.358  0.152   0.152    0.148    0.148
80    WSSQ5 ~~  WSSQ7  3.674  0.136   0.136    0.117    0.117
81    WSSQ5 ~~  WSSQ8  2.839  0.082   0.082    0.109    0.109
82    WSSQ5 ~~  WSSQ9  0.007 -0.004  -0.004   -0.005   -0.005
83    WSSQ5 ~~ WSSQ10  2.456 -0.100  -0.100   -0.099   -0.099
84    WSSQ5 ~~ WSSQ11  0.281 -0.026  -0.026   -0.033   -0.033
85    WSSQ5 ~~ WSSQ12  0.443  0.032   0.032    0.041    0.041
86    WSSQ6 ~~  WSSQ7  5.366  0.148   0.148    0.149    0.149
87    WSSQ6 ~~  WSSQ8  0.024  0.007   0.007    0.010    0.010
88    WSSQ6 ~~  WSSQ9  1.672 -0.058  -0.058   -0.081   -0.081
89    WSSQ6 ~~ WSSQ10 10.223  0.182   0.182    0.211    0.211
90    WSSQ6 ~~ WSSQ11  7.912 -0.124  -0.124   -0.182   -0.182
91    WSSQ6 ~~ WSSQ12  0.082  0.012   0.012    0.018    0.018
92    WSSQ7 ~~  WSSQ8  3.959  0.094   0.094    0.129    0.129
93    WSSQ7 ~~  WSSQ9  0.947  0.048   0.048    0.059    0.059
94    WSSQ7 ~~ WSSQ10  0.078  0.017   0.017    0.018    0.018
95    WSSQ7 ~~ WSSQ11 13.465 -0.177  -0.177   -0.230   -0.230
96    WSSQ7 ~~ WSSQ12  2.369 -0.071  -0.071   -0.096   -0.096
97    WSSQ8 ~~  WSSQ9  0.699  0.034   0.034    0.064    0.064
98    WSSQ8 ~~ WSSQ11  0.055 -0.010  -0.010   -0.020   -0.020
99    WSSQ8 ~~ WSSQ12  4.686 -0.087  -0.087   -0.181   -0.181
100   WSSQ9 ~~ WSSQ10 10.349 -0.167  -0.167   -0.236   -0.236
101   WSSQ9 ~~ WSSQ11  0.032 -0.007  -0.007   -0.012   -0.012
102   WSSQ9 ~~ WSSQ12  1.325  0.042   0.042    0.078    0.078
103  WSSQ10 ~~ WSSQ11  2.720  0.089   0.089    0.133    0.133
104  WSSQ10 ~~ WSSQ12  0.023  0.008   0.008    0.012    0.012
105  WSSQ11 ~~ WSSQ12  2.279  0.055   0.055    0.109    0.109
WSSQ.model <-
' factor1 =~ WSSQ1+WSSQ2+WSSQ3+ WSSQ4+ WSSQ5+WSSQ6+WSSQ7  
factor2 =~ WSSQ8+WSSQ9+ WSSQ10+ WSSQ11+WSSQ12  
WSSQ8 ~~ WSSQ10
WSSQ2~~WSSQ3+WSSQ1
'
fit<-cfa(WSSQ.model, data=dta)
summary(fit,fit.measures=T, standardized=T)
lavaan 0.6-9 ended normally after 34 iterations

  Estimator                                         ML
  Optimization method                           NLMINB
  Number of model parameters                        28
                                                      
  Number of observations                           325
                                                      
Model Test User Model:
                                                      
  Test statistic                               152.028
  Degrees of freedom                                50
  P-value (Chi-square)                           0.000

Model Test Baseline Model:

  Test statistic                              2668.151
  Degrees of freedom                                66
  P-value                                        0.000

User Model versus Baseline Model:

  Comparative Fit Index (CFI)                    0.961
  Tucker-Lewis Index (TLI)                       0.948

Loglikelihood and Information Criteria:

  Loglikelihood user model (H0)              -5622.934
  Loglikelihood unrestricted model (H1)      -5546.920
                                                      
  Akaike (AIC)                               11301.868
  Bayesian (BIC)                             11407.815
  Sample-size adjusted Bayesian (BIC)        11319.001

Root Mean Square Error of Approximation:

  RMSEA                                          0.079
  90 Percent confidence interval - lower         0.065
  90 Percent confidence interval - upper         0.094
  P-value RMSEA <= 0.05                          0.001

Standardized Root Mean Square Residual:

  SRMR                                           0.037

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
  factor1 =~                                                            
    WSSQ1             1.000                               0.947    0.634
    WSSQ2             1.320    0.101   13.009    0.000    1.250    0.782
    WSSQ3             1.307    0.106   12.276    0.000    1.238    0.841
    WSSQ4             1.138    0.099   11.502    0.000    1.078    0.767
    WSSQ5             1.033    0.100   10.326    0.000    0.978    0.668
    WSSQ6             1.217    0.105   11.604    0.000    1.153    0.777
    WSSQ7             1.051    0.100   10.534    0.000    0.995    0.685
  factor2 =~                                                            
    WSSQ8             1.000                               1.065    0.841
    WSSQ9             0.895    0.054   16.468    0.000    0.953    0.779
    WSSQ10            1.201    0.080   14.925    0.000    1.278    0.811
    WSSQ11            1.035    0.057   18.237    0.000    1.102    0.834
    WSSQ12            0.979    0.054   18.133    0.000    1.042    0.831

Covariances:
                   Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
 .WSSQ8 ~~                                                              
   .WSSQ10           -0.246    0.045   -5.404    0.000   -0.246   -0.389
 .WSSQ2 ~~                                                              
   .WSSQ3             0.266    0.060    4.460    0.000    0.266    0.335
 .WSSQ1 ~~                                                              
   .WSSQ2             0.253    0.068    3.736    0.000    0.253    0.219
  factor1 ~~                                                            
    factor2           0.865    0.102    8.446    0.000    0.858    0.858

Variances:
                   Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
   .WSSQ1             1.335    0.112   11.876    0.000    1.335    0.598
   .WSSQ2             0.995    0.094   10.570    0.000    0.995    0.389
   .WSSQ3             0.635    0.066    9.563    0.000    0.635    0.293
   .WSSQ4             0.811    0.074   10.935    0.000    0.811    0.411
   .WSSQ5             1.187    0.101   11.736    0.000    1.187    0.554
   .WSSQ6             0.875    0.081   10.823    0.000    0.875    0.397
   .WSSQ7             1.121    0.096   11.637    0.000    1.121    0.531
   .WSSQ8             0.470    0.048    9.695    0.000    0.470    0.293
   .WSSQ9             0.589    0.052   11.381    0.000    0.589    0.393
   .WSSQ10            0.851    0.083   10.205    0.000    0.851    0.342
   .WSSQ11            0.531    0.050   10.670    0.000    0.531    0.304
   .WSSQ12            0.486    0.045   10.724    0.000    0.486    0.309
    factor1           0.897    0.146    6.136    0.000    1.000    1.000
    factor2           1.133    0.124    9.118    0.000    1.000    1.000

為什麼要加這些進去? 必須回答

SEM或CFA有很多估計法

沒有跟lavaan說,一定用最大概似估計法 可以改估計法Estimators DWLS:用在非continues的score上,表現會比較好(像)

WSSQ.model <-
' factor1 =~ WSSQ1+WSSQ2+WSSQ3+ WSSQ4+ WSSQ5+WSSQ6
factor2 =~ WSSQ7+WSSQ8+WSSQ9+ WSSQ10+ WSSQ11+WSSQ12  
'
#DWLS的缺點是,sample size小的時候不好用
#會幫忙把scale切成不同階段,需要更多的樣本數
fit<-cfa(WSSQ.model, data=dta, estimator="DWLS")
summary(fit,fit.measures=T, standardized=T)
lavaan 0.6-9 ended normally after 36 iterations

  Estimator                                       DWLS
  Optimization method                           NLMINB
  Number of model parameters                        25
                                                      
  Number of observations                           325
                                                      
Model Test User Model:
                                                      
  Test statistic                                65.750
  Degrees of freedom                                53
  P-value (Chi-square)                           0.112

Model Test Baseline Model:

  Test statistic                              6823.391
  Degrees of freedom                                66
  P-value                                        0.000

User Model versus Baseline Model:

  Comparative Fit Index (CFI)                    0.998
  Tucker-Lewis Index (TLI)                       0.998

Root Mean Square Error of Approximation:

  RMSEA                                          0.027
  90 Percent confidence interval - lower         0.000
  90 Percent confidence interval - upper         0.047
  P-value RMSEA <= 0.05                          0.975

Standardized Root Mean Square Residual:

  SRMR                                           0.051

Parameter Estimates:

  Standard errors                             Standard
  Information                                 Expected
  Information saturated (h1) model        Unstructured

Latent Variables:
                   Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
  factor1 =~                                                            
    WSSQ1             1.000                               0.985    0.658
    WSSQ2             1.302    0.060   21.662    0.000    1.283    0.801
    WSSQ3             1.291    0.058   22.166    0.000    1.272    0.863
    WSSQ4             1.110    0.052   21.219    0.000    1.094    0.777
    WSSQ5             0.973    0.050   19.520    0.000    0.958    0.654
    WSSQ6             1.155    0.055   21.111    0.000    1.138    0.766
  factor2 =~                                                            
    WSSQ7             1.000                               0.943    0.648
    WSSQ8             1.091    0.052   20.887    0.000    1.029    0.812
    WSSQ9             1.006    0.048   20.901    0.000    0.949    0.774
    WSSQ10            1.303    0.062   20.996    0.000    1.229    0.779
    WSSQ11            1.111    0.053   20.913    0.000    1.048    0.793
    WSSQ12            1.077    0.051   20.987    0.000    1.016    0.809

Covariances:
                   Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
  factor1 ~~                                                            
    factor2           0.836    0.043   19.529    0.000    0.900    0.900

Variances:
                   Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
   .WSSQ1             1.268    0.138    9.215    0.000    1.268    0.567
   .WSSQ2             0.923    0.162    5.693    0.000    0.923    0.359
   .WSSQ3             0.556    0.142    3.912    0.000    0.556    0.256
   .WSSQ4             0.783    0.151    5.197    0.000    0.783    0.396
   .WSSQ5             1.231    0.133    9.285    0.000    1.231    0.573
   .WSSQ6             0.915    0.142    6.434    0.000    0.915    0.414
   .WSSQ7             1.227    0.138    8.902    0.000    1.227    0.580
   .WSSQ8             0.549    0.123    4.464    0.000    0.549    0.341
   .WSSQ9             0.602    0.115    5.254    0.000    0.602    0.401
   .WSSQ10            0.982    0.152    6.458    0.000    0.982    0.394
   .WSSQ11            0.651    0.135    4.837    0.000    0.651    0.372
   .WSSQ12            0.544    0.115    4.736    0.000    0.544    0.345
    factor1           0.971    0.068   14.303    0.000    1.000    1.000
    factor2           0.890    0.065   13.715    0.000    1.000    1.000

TLI(NNFI),有可能會超過1

stucture part (SEM)

WSSQ.model <-
' factor1 =~ WSSQ1+WSSQ2+WSSQ3+ WSSQ4+ WSSQ5+WSSQ6
factor2 =~ WSSQ7+WSSQ8+WSSQ9+ WSSQ10+ WSSQ11+WSSQ12  
factor3=~PBC6+PBC7+PBC8+PBC9+PBC10

factor3~factor1+factor2
factor1~factor2
'

fit<-sem(WSSQ.model, data=dta)
summary(fit,fit.measures=T, standardized=T)
lavaan 0.6-9 ended normally after 46 iterations

  Estimator                                         ML
  Optimization method                           NLMINB
  Number of model parameters                        37
                                                      
  Number of observations                           325
                                                      
Model Test User Model:
                                                      
  Test statistic                               385.900
  Degrees of freedom                               116
  P-value (Chi-square)                           0.000

Model Test Baseline Model:

  Test statistic                              4159.722
  Degrees of freedom                               136
  P-value                                        0.000

User Model versus Baseline Model:

  Comparative Fit Index (CFI)                    0.933
  Tucker-Lewis Index (TLI)                       0.921

Loglikelihood and Information Criteria:

  Loglikelihood user model (H0)              -8174.601
  Loglikelihood unrestricted model (H1)      -7981.651
                                                      
  Akaike (AIC)                               16423.201
  Bayesian (BIC)                             16563.203
  Sample-size adjusted Bayesian (BIC)        16445.842

Root Mean Square Error of Approximation:

  RMSEA                                          0.085
  90 Percent confidence interval - lower         0.075
  90 Percent confidence interval - upper         0.094
  P-value RMSEA <= 0.05                          0.000

Standardized Root Mean Square Residual:

  SRMR                                           0.058

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
  factor1 =~                                                            
    WSSQ1             1.000                               0.991    0.664
    WSSQ2             1.336    0.103   13.012    0.000    1.324    0.828
    WSSQ3             1.281    0.095   13.444    0.000    1.270    0.863
    WSSQ4             1.086    0.089   12.213    0.000    1.077    0.767
    WSSQ5             0.942    0.090   10.417    0.000    0.934    0.638
    WSSQ6             1.137    0.094   12.116    0.000    1.127    0.759
  factor2 =~                                                            
    WSSQ7             1.000                               0.851    0.586
    WSSQ8             1.215    0.110   11.088    0.000    1.034    0.816
    WSSQ9             1.134    0.104   10.851    0.000    0.965    0.788
    WSSQ10            1.445    0.134   10.779    0.000    1.229    0.780
    WSSQ11            1.284    0.115   11.177    0.000    1.093    0.827
    WSSQ12            1.228    0.109   11.224    0.000    1.045    0.833
  factor3 =~                                                            
    PBC6              1.000                               1.597    0.916
    PBC7              0.911    0.037   24.897    0.000    1.455    0.878
    PBC8             -0.231    0.058   -4.009    0.000   -0.369   -0.223
    PBC9              1.031    0.034   30.253    0.000    1.646    0.942
    PBC10             1.014    0.036   27.893    0.000    1.619    0.916

Regressions:
                   Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
  factor3 ~                                                             
    factor1          -0.301    0.250   -1.206    0.228   -0.187   -0.187
    factor2           0.349    0.291    1.200    0.230    0.186    0.186
  factor1 ~                                                             
    factor2           1.017    0.111    9.156    0.000    0.873    0.873

Variances:
                   Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
   .WSSQ1             1.249    0.105   11.878    0.000    1.249    0.560
   .WSSQ2             0.806    0.078   10.310    0.000    0.806    0.315
   .WSSQ3             0.555    0.058    9.482    0.000    0.555    0.256
   .WSSQ4             0.814    0.073   11.162    0.000    0.814    0.412
   .WSSQ5             1.270    0.106   11.989    0.000    1.270    0.593
   .WSSQ6             0.933    0.083   11.233    0.000    0.933    0.423
   .WSSQ7             1.387    0.114   12.207    0.000    1.387    0.657
   .WSSQ8             0.535    0.050   10.656    0.000    0.535    0.334
   .WSSQ9             0.567    0.051   11.035    0.000    0.567    0.379
   .WSSQ10            0.974    0.087   11.128    0.000    0.974    0.392
   .WSSQ11            0.551    0.053   10.476    0.000    0.551    0.316
   .WSSQ12            0.481    0.046   10.369    0.000    0.481    0.306
   .PBC6              0.488    0.051    9.496    0.000    0.488    0.161
   .PBC7              0.627    0.059   10.691    0.000    0.627    0.228
   .PBC8              2.601    0.205   12.717    0.000    2.601    0.950
   .PBC9              0.345    0.044    7.860    0.000    0.345    0.113
   .PBC10             0.504    0.053    9.509    0.000    0.504    0.161
   .factor1           0.234    0.044    5.327    0.000    0.238    0.238
    factor2           0.724    0.129    5.611    0.000    1.000    1.000
   .factor3           2.526    0.237   10.666    0.000    0.991    0.991
WSSQ.model <-
' factor1 =~ WSSQ1+WSSQ2+WSSQ3+ WSSQ4+ WSSQ5+WSSQ6
factor2 =~ WSSQ7+WSSQ8+WSSQ9+ WSSQ10+ WSSQ11+WSSQ12  
factor3=~PBC6+PBC7+PBC8+PBC9+PBC10

#regression 想控制某些變項
factor3~Age+Gender+factor1+factor2
factor1~Age+Gender+factor2
'
#如果Gender已經是類別變項>2,就要dummy
#有些SEM的圖,不會在model上劃Age或Gender出來(比較美觀),因為只是要control的variables

fit<-sem(WSSQ.model, data=dta, estimator="DWLS")
summary(fit,fit.measures=T, standardized=T)
lavaan 0.6-9 ended normally after 70 iterations

  Estimator                                       DWLS
  Optimization method                           NLMINB
  Number of model parameters                        44
                                                      
  Number of observations                           325
                                                      
Model Test User Model:
                                                      
  Test statistic                               188.368
  Degrees of freedom                               146
  P-value (Chi-square)                           0.010

Model Test Baseline Model:

  Test statistic                              8479.225
  Degrees of freedom                               170
  P-value                                        0.000

User Model versus Baseline Model:

  Comparative Fit Index (CFI)                    0.995
  Tucker-Lewis Index (TLI)                       0.994

Root Mean Square Error of Approximation:

  RMSEA                                          0.030
  90 Percent confidence interval - lower         0.015
  90 Percent confidence interval - upper         0.042
  P-value RMSEA <= 0.05                          0.999

Standardized Root Mean Square Residual:

  SRMR                                           0.056

Parameter Estimates:

  Standard errors                             Standard
  Information                                 Expected
  Information saturated (h1) model        Unstructured

Latent Variables:
                   Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
  factor1 =~                                                            
    WSSQ1             1.000                               0.986    0.659
    WSSQ2             1.299    0.060   21.680    0.000    1.281    0.799
    WSSQ3             1.289    0.058   22.190    0.000    1.271    0.862
    WSSQ4             1.109    0.052   21.246    0.000    1.094    0.777
    WSSQ5             0.971    0.050   19.531    0.000    0.957    0.653
    WSSQ6             1.158    0.055   21.159    0.000    1.142    0.768
  factor2 =~                                                            
    WSSQ7             1.000                               0.943    0.648
    WSSQ8             1.091    0.052   20.886    0.000    1.029    0.812
    WSSQ9             1.006    0.048   20.900    0.000    0.949    0.774
    WSSQ10            1.303    0.062   20.994    0.000    1.229    0.779
    WSSQ11            1.112    0.053   20.912    0.000    1.049    0.793
    WSSQ12            1.077    0.051   20.986    0.000    1.016    0.809
  factor3 =~                                                            
    PBC6              1.000                               1.606    0.920
    PBC7              0.904    0.057   15.756    0.000    1.452    0.875
    PBC8             -0.222    0.039   -5.728    0.000   -0.357   -0.216
    PBC9              1.031    0.066   15.673    0.000    1.656    0.946
    PBC10             1.005    0.064   15.624    0.000    1.615    0.912

Regressions:
                   Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
  factor3 ~                                                             
    Age               0.003    0.023    0.129    0.897    0.002    0.005
    Gender           -1.095    0.117   -9.399    0.000   -0.682   -0.333
    factor1          -0.220    0.223   -0.985    0.325   -0.135   -0.135
    factor2           0.209    0.228    0.918    0.359    0.123    0.123
  factor1 ~                                                             
    Age               0.029    0.012    2.425    0.015    0.029    0.086
    Gender            0.087    0.065    1.329    0.184    0.088    0.043
    factor2           0.941    0.053   17.917    0.000    0.900    0.900

Covariances:
                   Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
  Age ~~                                                                
    Gender           -0.301    0.081   -3.722    0.000   -0.301   -0.209

Variances:
                   Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
   .WSSQ1             1.267    0.138    9.202    0.000    1.267    0.566
   .WSSQ2             0.928    0.162    5.729    0.000    0.928    0.361
   .WSSQ3             0.559    0.142    3.936    0.000    0.559    0.257
   .WSSQ4             0.783    0.151    5.197    0.000    0.783    0.396
   .WSSQ5             1.234    0.133    9.309    0.000    1.234    0.574
   .WSSQ6             0.907    0.142    6.372    0.000    0.907    0.410
   .WSSQ7             1.227    0.138    8.904    0.000    1.227    0.580
   .WSSQ8             0.549    0.123    4.464    0.000    0.549    0.341
   .WSSQ9             0.602    0.115    5.254    0.000    0.602    0.401
   .WSSQ10            0.982    0.152    6.459    0.000    0.982    0.394
   .WSSQ11            0.650    0.135    4.836    0.000    0.650    0.372
   .WSSQ12            0.544    0.115    4.734    0.000    0.544    0.345
   .PBC6              0.468    0.273    1.712    0.087    0.468    0.154
   .PBC7              0.643    0.248    2.598    0.009    0.643    0.234
   .PBC8              2.618    0.176   14.887    0.000    2.618    0.954
   .PBC9              0.322    0.281    1.144    0.253    0.322    0.105
   .PBC10             0.528    0.279    1.894    0.058    0.528    0.168
   .factor1           0.177    0.043    4.152    0.000    0.182    0.182
    factor2           0.890    0.065   13.713    0.000    1.000    1.000
   .factor3           2.277    0.198   11.494    0.000    0.883    0.883
    Age               8.698    0.856   10.163    0.000    8.698    1.000
    Gender            0.238    0.006   39.165    0.000    0.238    1.000

SEM結果解釋

看卡方值 Test statistic 188.368 Degrees of freedom 146 P-value (Chi-square) 0.010

看適配度 Comparative Fit Index (CFI) 0.995 Tucker-Lewis Index (TLI) 0.994 RMSEA(只有這個有分布,能夠算進賴區間) 0.030 90 Percent confidence interval - lower 0.015 90 Percent confidence interval - upper 0.042 P-value RMSEA <= 0.05 0.999 SRMR 0.056

看模型 =~表示測量模型 factor3: PBC-0.261 負的要看一下資料是不是反向題,或者考慮刪除

factor3 ~
Age 0.003 0.023 0.129 0.897 0.002 0.005 Gender -1.095 0.117 -9.399 0.000 -0.682 -0.333 Age部會影響到factor3 Gender顯著,表示在factor3是有影響的

factor1 ~                                                             
Age               0.029    0.012    2.425    0.015    0.029    0.086
Gender            0.087    0.065    1.329    0.184    0.088    0.043
factor2           0.941    0.053   17.917    0.000    0.900    0.900

age越高→factor1越高,factor2越高→factor1越高

Variances:看std.all有沒有違反規定(1.不可>1;2.不可為負值)

covariances Age~Gender (觀察到的才會做相關)

遵循節約原則(模型越簡單越好) 甚麼時候只考慮做簡單模型(structure part),可能複雜模型(measurement part)結果不好的時… # 單純發展量表→做CFA 想知道變項兼因果關係→做SEM(可用資料做出方向性)

Simple.model <-
' 
att =~Attitude_PA 
sn =~ SubNorm_PA  
PBC=~PBC_PA
int=~Int_PA
PA=~IPAQtotalMET2

#regression 想控制某些變項
int~att+sn+PBC
PA~PBC+int

'
fit<-sem(Simple.model, data=dta)
summary(fit,fit.measures=T, standardized=T)
lavaan 0.6-9 ended normally after 156 iterations

  Estimator                                         ML
  Optimization method                           NLMINB
  Number of model parameters                        13
                                                      
  Number of observations                           325
                                                      
Model Test User Model:
                                                      
  Test statistic                                 4.046
  Degrees of freedom                                 2
  P-value (Chi-square)                           0.132

Model Test Baseline Model:

  Test statistic                               382.161
  Degrees of freedom                                10
  P-value                                        0.000

User Model versus Baseline Model:

  Comparative Fit Index (CFI)                    0.995
  Tucker-Lewis Index (TLI)                       0.973

Loglikelihood and Information Criteria:

  Loglikelihood user model (H0)              -7173.500
  Loglikelihood unrestricted model (H1)      -7171.478
                                                      
  Akaike (AIC)                               14373.001
  Bayesian (BIC)                             14422.191
  Sample-size adjusted Bayesian (BIC)        14380.956

Root Mean Square Error of Approximation:

  RMSEA                                          0.056
  90 Percent confidence interval - lower         0.000
  90 Percent confidence interval - upper         0.136
  P-value RMSEA <= 0.05                          0.344

Standardized Root Mean Square Residual:

  SRMR                                           0.025

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
  att =~                                                                
    Attitude_PA       1.000                              13.919    1.000
  sn =~                                                                 
    SubNorm_PA        1.000                              26.133    1.000
  PBC =~                                                                
    PBC_PA            1.000                              26.955    1.000
  int =~                                                                
    Int_PA            1.000                              27.243    1.000
  PA =~                                                                 
    IPAQtotalMET2     1.000                              21.411    1.000

Regressions:
                   Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
  int ~                                                                 
    att               0.295    0.086    3.423    0.001    0.151    0.151
    sn                0.210    0.041    5.143    0.000    0.201    0.201
    PBC               0.574    0.045   12.732    0.000    0.568    0.568
  PA ~                                                                  
    PBC               0.219    0.058    3.805    0.000    0.276    0.276
    int               0.027    0.057    0.479    0.632    0.035    0.035

Covariances:
                   Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
  att ~~                                                                
    sn               48.258   20.354    2.371    0.018    0.133    0.133
    PBC             185.865   23.225    8.003    0.000    0.495    0.495
  sn ~~                                                                 
    PBC             142.892   39.869    3.584    0.000    0.203    0.203

Variances:
                   Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
   .Attitude_PA       0.000                               0.000    0.000
   .SubNorm_PA        0.000                               0.000    0.000
   .PBC_PA            0.000                               0.000    0.000
   .Int_PA            0.000                               0.000    0.000
   .IPAQtotalMET2     0.000                               0.000    0.000
    att             193.740   15.198   12.748    0.000    1.000    1.000
    sn              682.926   53.573   12.748    0.000    1.000    1.000
    PBC             726.557   56.996   12.748    0.000    1.000    1.000
   .int             352.779   27.674   12.748    0.000    0.475    0.475
   .PA              417.054   32.716   12.748    0.000    0.910    0.910
#不建議用DWLS,因為裡面是總分,改回default是ML(最大概似法)
#老師的寫法
Simple.model <-
' 
IPAQtotalMET2~Int_PA+PBC_PA
Int_PA~Attitude_PA+SubNorm_PA+PBC_PA
'
fit<-sem(Simple.model, data=dta)
summary(fit,fit.measures=T, standardized=T)
lavaan 0.6-9 ended normally after 17 iterations

  Estimator                                         ML
  Optimization method                           NLMINB
  Number of model parameters                         7
                                                      
  Number of observations                           325
                                                      
Model Test User Model:
                                                      
  Test statistic                                 4.046
  Degrees of freedom                                 2
  P-value (Chi-square)                           0.132

Model Test Baseline Model:

  Test statistic                               276.522
  Degrees of freedom                                 7
  P-value                                        0.000

User Model versus Baseline Model:

  Comparative Fit Index (CFI)                    0.992
  Tucker-Lewis Index (TLI)                       0.973

Loglikelihood and Information Criteria:

  Loglikelihood user model (H0)              -2855.907
  Loglikelihood unrestricted model (H1)      -2853.884
                                                      
  Akaike (AIC)                                5725.813
  Bayesian (BIC)                              5752.300
  Sample-size adjusted Bayesian (BIC)         5730.097

Root Mean Square Error of Approximation:

  RMSEA                                          0.056
  90 Percent confidence interval - lower         0.000
  90 Percent confidence interval - upper         0.136
  P-value RMSEA <= 0.05                          0.344

Standardized Root Mean Square Residual:

  SRMR                                           0.025

Parameter Estimates:

  Standard errors                             Standard
  Information                                 Expected
  Information saturated (h1) model          Structured

Regressions:
                   Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
  IPAQtotalMET2 ~                                                       
    Int_PA            0.027    0.057    0.479    0.632    0.027    0.035
    PBC_PA            0.219    0.058    3.805    0.000    0.219    0.276
  Int_PA ~                                                              
    Attitude_PA       0.295    0.086    3.423    0.001    0.295    0.151
    SubNorm_PA        0.210    0.041    5.143    0.000    0.210    0.201
    PBC_PA            0.574    0.045   12.732    0.000    0.574    0.568

Variances:
                   Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
   .IPAQtotalMET2   417.054   32.716   12.748    0.000  417.054    0.910
   .Int_PA          352.779   27.674   12.748    0.000  352.779    0.475
Simple.model <-
' 
att =~Attitude_PA 
sn =~ SubNorm_PA  
PBC=~PBC_PA
int=~Int_PA
PA=~IPAQtotalMET2

#regression 想控制某些變項
int~att+sn+PBC+WBIS_Total_Score
PA~PBC+int

'
fit1<-sem(Simple.model, data=dta)
summary(fit1,fit.measures=T, standardized=T)
lavaan 0.6-9 ended normally after 158 iterations

  Estimator                                         ML
  Optimization method                           NLMINB
  Number of model parameters                        14
                                                      
  Number of observations                           325
                                                      
Model Test User Model:
                                                      
  Test statistic                                48.652
  Degrees of freedom                                 6
  P-value (Chi-square)                           0.000

Model Test Baseline Model:

  Test statistic                               430.750
  Degrees of freedom                                15
  P-value                                        0.000

User Model versus Baseline Model:

  Comparative Fit Index (CFI)                    0.897
  Tucker-Lewis Index (TLI)                       0.744

Loglikelihood and Information Criteria:

  Loglikelihood user model (H0)              -7171.509
  Loglikelihood unrestricted model (H1)      -7147.183
                                                      
  Akaike (AIC)                               14371.017
  Bayesian (BIC)                             14423.991
  Sample-size adjusted Bayesian (BIC)        14379.584

Root Mean Square Error of Approximation:

  RMSEA                                          0.148
  90 Percent confidence interval - lower         0.111
  90 Percent confidence interval - upper         0.188
  P-value RMSEA <= 0.05                          0.000

Standardized Root Mean Square Residual:

  SRMR                                           0.081

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
  att =~                                                                
    Attitude_PA       1.000                              13.919    1.000
  sn =~                                                                 
    SubNorm_PA        1.000                              26.133    1.000
  PBC =~                                                                
    PBC_PA            1.000                              26.955    1.000
  int =~                                                                
    Int_PA            1.000                              27.095    1.000
  PA =~                                                                 
    IPAQtotalMET2     1.000                              21.410    1.000

Regressions:
                   Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
  int ~                                                                 
    att               0.319    0.086    3.720    0.000    0.164    0.164
    sn                0.183    0.040    4.514    0.000    0.176    0.176
    PBC               0.569    0.045   12.708    0.000    0.566    0.566
    WBIS_Total_Scr    0.230    0.108    2.125    0.034    0.008    0.081
  PA ~                                                                  
    PBC               0.219    0.058    3.805    0.000    0.276    0.276
    int               0.027    0.057    0.476    0.634    0.035    0.035

Covariances:
                   Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
  att ~~                                                                
    sn               48.258   20.354    2.371    0.018    0.133    0.133
    PBC             185.865   23.225    8.003    0.000    0.495    0.495
  sn ~~                                                                 
    PBC             142.892   39.869    3.584    0.000    0.203    0.203

Variances:
                   Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
   .Attitude_PA       0.000                               0.000    0.000
   .SubNorm_PA        0.000                               0.000    0.000
   .PBC_PA            0.000                               0.000    0.000
   .Int_PA            0.000                               0.000    0.000
   .IPAQtotalMET2     0.000                               0.000    0.000
    att             193.740   15.198   12.748    0.000    1.000    1.000
    sn              682.926   53.573   12.748    0.000    1.000    1.000
    PBC             726.557   56.996   12.748    0.000    1.000    1.000
   .int             348.481   27.337   12.748    0.000    0.475    0.475
   .PA              417.054   32.716   12.748    0.000    0.910    0.910
#不建議用DWLS,因為裡面是總分,改回default是ML(最大概似法)
Simple.model <-
' 
att =~Attitude_PA 
sn =~ SubNorm_PA  
PBC=~PBC_PA
int=~Int_PA
PA=~IPAQtotalMET2

#regression 想控制某些變項
WBIS_Total_Score~att
int~att+sn+PBC+WBIS_Total_Score
PA~PBC+int

'
fit2<-sem(Simple.model, data=dta)
summary(fit2,fit.measures=T, standardized=T)
lavaan 0.6-9 ended normally after 169 iterations

  Estimator                                         ML
  Optimization method                           NLMINB
  Number of model parameters                        16
                                                      
  Number of observations                           325
                                                      
Model Test User Model:
                                                      
  Test statistic                                46.579
  Degrees of freedom                                 5
  P-value (Chi-square)                           0.000

Model Test Baseline Model:

  Test statistic                               430.750
  Degrees of freedom                                15
  P-value                                        0.000

User Model versus Baseline Model:

  Comparative Fit Index (CFI)                    0.900
  Tucker-Lewis Index (TLI)                       0.700

Loglikelihood and Information Criteria:

  Loglikelihood user model (H0)              -8365.465
  Loglikelihood unrestricted model (H1)      -8342.175
                                                      
  Akaike (AIC)                               16762.929
  Bayesian (BIC)                             16823.470
  Sample-size adjusted Bayesian (BIC)        16772.720

Root Mean Square Error of Approximation:

  RMSEA                                          0.160
  90 Percent confidence interval - lower         0.120
  90 Percent confidence interval - upper         0.203
  P-value RMSEA <= 0.05                          0.000

Standardized Root Mean Square Residual:

  SRMR                                           0.083

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
  att =~                                                                
    Attitude_PA       1.000                              13.919    1.000
  sn =~                                                                 
    SubNorm_PA        1.000                              26.133    1.000
  PBC =~                                                                
    PBC_PA            1.000                              26.955    1.000
  int =~                                                                
    Int_PA            1.000                              27.013    1.000
  PA =~                                                                 
    IPAQtotalMET2     1.000                              21.409    1.000

Regressions:
                     Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
  WBIS_Total_Score ~                                                      
    att                -0.055    0.038   -1.442    0.149   -0.763   -0.080
  int ~                                                                   
    att                 0.319    0.086    3.711    0.000    0.164    0.164
    sn                  0.183    0.040    4.514    0.000    0.177    0.177
    PBC                 0.569    0.045   12.708    0.000    0.568    0.568
    WBIS_Total_Scr      0.230    0.109    2.119    0.034    0.009    0.081
  PA ~                                                                    
    PBC                 0.219    0.057    3.810    0.000    0.276    0.276
    int                 0.027    0.057    0.476    0.634    0.034    0.034

Covariances:
                   Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
  att ~~                                                                
    sn               48.258   20.354    2.371    0.018    0.133    0.133
    PBC             185.865   23.225    8.003    0.000    0.495    0.495
  sn ~~                                                                 
    PBC             142.892   39.869    3.584    0.000    0.203    0.203

Variances:
                   Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
   .Attitude_PA       0.000                               0.000    0.000
   .SubNorm_PA        0.000                               0.000    0.000
   .PBC_PA            0.000                               0.000    0.000
   .Int_PA            0.000                               0.000    0.000
   .IPAQtotalMET2     0.000                               0.000    0.000
   .WBIS_Total_Scr   90.880    7.129   12.748    0.000   90.880    0.994
    att             193.740   15.198   12.748    0.000    1.000    1.000
    sn              682.926   53.573   12.748    0.000    1.000    1.000
    PBC             726.557   56.996   12.748    0.000    1.000    1.000
   .int             348.481   27.337   12.748    0.000    0.478    0.478
   .PA              417.054   32.716   12.748    0.000    0.910    0.910
#老師的寫法
Simple.model <-
' 
IPAQtotalMET2~Int_PA+PBC_PA
Int_PA~WBIS_Total_Score+Attitude_PA+SubNorm_PA+PBC_PA
'
fit1<-sem(Simple.model, data=dta)
summary(fit1,fit.measures=T, standardized=T)
lavaan 0.6-9 ended normally after 19 iterations

  Estimator                                         ML
  Optimization method                           NLMINB
  Number of model parameters                         8
                                                      
  Number of observations                           325
                                                      
Model Test User Model:
                                                      
  Test statistic                                 9.767
  Degrees of freedom                                 3
  P-value (Chi-square)                           0.021

Model Test Baseline Model:

  Test statistic                               286.227
  Degrees of freedom                                 9
  P-value                                        0.000

User Model versus Baseline Model:

  Comparative Fit Index (CFI)                    0.976
  Tucker-Lewis Index (TLI)                       0.927

Loglikelihood and Information Criteria:

  Loglikelihood user model (H0)              -2853.915
  Loglikelihood unrestricted model (H1)      -2849.031
                                                      
  Akaike (AIC)                                5723.830
  Bayesian (BIC)                              5754.100
  Sample-size adjusted Bayesian (BIC)         5728.725

Root Mean Square Error of Approximation:

  RMSEA                                          0.083
  90 Percent confidence interval - lower         0.029
  90 Percent confidence interval - upper         0.144
  P-value RMSEA <= 0.05                          0.134

Standardized Root Mean Square Residual:

  SRMR                                           0.039

Parameter Estimates:

  Standard errors                             Standard
  Information                                 Expected
  Information saturated (h1) model          Structured

Regressions:
                   Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
  IPAQtotalMET2 ~                                                       
    Int_PA            0.027    0.057    0.479    0.632    0.027    0.035
    PBC_PA            0.219    0.058    3.805    0.000    0.219    0.276
  Int_PA ~                                                              
    WBIS_Total_Scr    0.230    0.115    2.002    0.045    0.230    0.081
    Attitude_PA       0.319    0.087    3.685    0.000    0.319    0.163
    SubNorm_PA        0.183    0.043    4.287    0.000    0.183    0.175
    PBC_PA            0.569    0.045   12.692    0.000    0.569    0.563

Variances:
                   Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
   .IPAQtotalMET2   417.054   32.716   12.748    0.000  417.054    0.910
   .Int_PA          348.481   27.337   12.748    0.000  348.481    0.470
#老師的寫法
Simple.model <-
' 
IPAQtotalMET2~Int_PA+PBC_PA
WBIS_Total_Score~Attitude_PA
Int_PA~WBIS_Total_Score+Attitude_PA+SubNorm_PA+PBC_PA
'
fit2<-sem(Simple.model, data=dta)
summary(fit2,fit.measures=T, standardized=T)
lavaan 0.6-9 ended normally after 22 iterations

  Estimator                                         ML
  Optimization method                           NLMINB
  Number of model parameters                        10
                                                      
  Number of observations                           325
                                                      
Model Test User Model:
                                                      
  Test statistic                                46.579
  Degrees of freedom                                 5
  P-value (Chi-square)                           0.000

Model Test Baseline Model:

  Test statistic                               325.111
  Degrees of freedom                                12
  P-value                                        0.000

User Model versus Baseline Model:

  Comparative Fit Index (CFI)                    0.867
  Tucker-Lewis Index (TLI)                       0.681

Loglikelihood and Information Criteria:

  Loglikelihood user model (H0)              -4047.871
  Loglikelihood unrestricted model (H1)      -4024.581
                                                      
  Akaike (AIC)                                8115.742
  Bayesian (BIC)                              8153.580
  Sample-size adjusted Bayesian (BIC)         8121.861

Root Mean Square Error of Approximation:

  RMSEA                                          0.160
  90 Percent confidence interval - lower         0.120
  90 Percent confidence interval - upper         0.203
  P-value RMSEA <= 0.05                          0.000

Standardized Root Mean Square Residual:

  SRMR                                           0.083

Parameter Estimates:

  Standard errors                             Standard
  Information                                 Expected
  Information saturated (h1) model          Structured

Regressions:
                     Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
  IPAQtotalMET2 ~                                                         
    Int_PA              0.027    0.057    0.476    0.634    0.027    0.034
    PBC_PA              0.219    0.057    3.810    0.000    0.219    0.276
  WBIS_Total_Score ~                                                      
    Attitude_PA        -0.055    0.038   -1.442    0.149   -0.055   -0.080
  Int_PA ~                                                                
    WBIS_Total_Scr      0.230    0.109    2.119    0.034    0.230    0.081
    Attitude_PA         0.319    0.086    3.711    0.000    0.319    0.164
    SubNorm_PA          0.183    0.040    4.514    0.000    0.183    0.177
    PBC_PA              0.569    0.045   12.708    0.000    0.569    0.568

Variances:
                   Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
   .IPAQtotalMET2   417.054   32.716   12.748    0.000  417.054    0.910
   .WBIS_Total_Scr   90.880    7.129   12.748    0.000   90.880    0.994
   .Int_PA          348.481   27.337   12.748    0.000  348.481    0.478
anova(fit1, fit2)
Chi-Squared Difference Test

     Df    AIC    BIC  Chisq Chisq diff Df diff Pr(>Chisq)    
fit1  3 5723.8 5754.1  9.767                                  
fit2  5 8115.7 8153.6 46.579     36.812       2  1.015e-08 ***
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

這兩個模型有顯著差異 比較兩個模式的卡方值,p=1.015e-08 AIC, BIC越小越好

若兩個模型沒有顯著差異,就選結構簡單的模型

測量衡等性measurement invariance

依據不同的group做分群的分析 如何檢測group間的factor loading是否一致 group.equal=c(“loadings”, “intercepts”) 如何檢測group間的Intercepts是否一致 形成三個模型(稱之為nested model) (1)figural model (2)loading-constrained model (3)loading & intercept constrained model (1)→(2)模型是否顯著變差,變差表示,把group限制在equal是不合理的,在因素負荷量不一致 (2)→(3)有變差,表示factor在起始點是不一致的 皆不能宣稱,模型具有測量衡等性(表示,如果是男生和女生,應該各自畫一個model)

依據Chen F.F, 2007 △CFI(CFI後-CFI前)>-0,01 △PRSEA<0.015 △SRMR<0.03在loading/ △SRMR<0.01在intercept △TLI(Chen F.F沒有做這個) 都符合的話,表示有測量衡等性