1
##讀進資料, 並將資料隨機分成兩部分,請報告每部分的樣本數
dta <- read.table('bfi.dat',header=T)
sid <- sample(1:2800,1400)
dta1 <- dta[sid,]
dta2 <- dta[-sid,]
dim(dta)
## [1] 2800 28
dim(dta1)
## [1] 1400 28
dim(dta2)
## [1] 1400 28
str(dta1)
## 'data.frame': 1400 obs. of 28 variables:
## $ A1 : int 2 1 2 4 2 6 3 3 3 2 ...
## $ A2 : int 5 5 5 6 5 4 6 4 5 5 ...
## $ A3 : int 5 6 5 4 6 6 3 3 5 4 ...
## $ A4 : int 6 5 5 2 5 6 5 6 5 4 ...
## $ A5 : int 4 5 3 5 5 5 3 3 3 4 ...
## $ C1 : int 4 2 4 5 5 6 4 4 5 4 ...
## $ C2 : int 5 1 2 4 5 5 NA 4 5 5 ...
## $ C3 : int 4 4 6 5 6 5 2 4 6 5 ...
## $ C4 : int 2 4 2 2 1 1 4 2 2 5 ...
## $ C5 : int 3 6 5 5 1 1 4 1 2 5 ...
## $ E1 : int 2 2 1 NA 3 5 4 5 4 5 ...
## $ E2 : int 3 4 4 4 1 1 5 4 4 6 ...
## $ E3 : int 4 5 3 4 5 2 3 2 4 3 ...
## $ E4 : int 4 5 5 4 5 5 2 3 3 2 ...
## $ E5 : int 5 6 6 5 6 5 2 3 5 2 ...
## $ N1 : int 3 1 3 1 1 6 5 3 5 3 ...
## $ N2 : int 3 1 4 3 1 4 5 3 4 4 ...
## $ N3 : int 1 1 3 1 1 4 4 3 4 2 ...
## $ N4 : int 1 3 2 2 1 2 5 4 4 5 ...
## $ N5 : int 2 2 4 1 1 2 4 4 4 6 ...
## $ O1 : int 5 6 4 4 6 4 5 3 5 2 ...
## $ O2 : int 1 2 3 2 1 1 2 1 4 4 ...
## $ O3 : int 4 4 5 4 6 5 2 3 3 4 ...
## $ O4 : int 4 5 5 4 4 6 5 3 4 6 ...
## $ O5 : int 2 2 2 2 1 5 4 4 4 4 ...
## $ gender : int 2 2 2 1 1 2 1 1 2 1 ...
## $ education: int 3 4 2 2 4 5 1 1 3 4 ...
## $ age : int 38 29 33 21 35 44 31 46 26 24 ...
##CFA檢驗五大性格向度模型(斜交五因素模型,每因素依序五題)
require(lavaan)
## Loading required package: lavaan
## This is lavaan 0.5-23.1097
## lavaan is BETA software! Please report any bugs.
dat <- as.matrix(dta1)
modela <-
'
Open =~ O1+O2+O3+O4+O5
Conscien =~ C1+C2+C3+C4+C5
Extraversion =~ E1+E2+E3+E4+E5
Agreeable =~ A1+A2+A3+A4+A5
EmotionalS =~ N1+N2+N3+N4+N5
'
fita <- cfa(modela, data=dta1,std.lv=TRUE)
summary(fita, fit.measures=TRUE)
## lavaan (0.5-23.1097) converged normally after 37 iterations
##
## Used Total
## Number of observations 1228 1400
##
## Estimator ML
## Minimum Function Test Statistic 2300.893
## Degrees of freedom 265
## P-value (Chi-square) 0.000
##
## Model test baseline model:
##
## Minimum Function Test Statistic 9609.573
## Degrees of freedom 300
## P-value 0.000
##
## User model versus baseline model:
##
## Comparative Fit Index (CFI) 0.781
## Tucker-Lewis Index (TLI) 0.752
##
## Loglikelihood and Information Criteria:
##
## Loglikelihood user model (H0) -50087.952
## Loglikelihood unrestricted model (H1) -48937.505
##
## Number of free parameters 60
## Akaike (AIC) 100295.903
## Bayesian (BIC) 100602.692
## Sample-size adjusted Bayesian (BIC) 100412.106
##
## Root Mean Square Error of Approximation:
##
## RMSEA 0.079
## 90 Percent Confidence Interval 0.076 0.082
## P-value RMSEA <= 0.05 0.000
##
## Standardized Root Mean Square Residual:
##
## SRMR 0.078
##
## Parameter Estimates:
##
## Information Expected
## Standard Errors Standard
##
## Latent Variables:
## Estimate Std.Err z-value P(>|z|)
## Open =~
## O1 0.603 0.036 16.533 0.000
## O2 -0.604 0.051 -11.773 0.000
## O3 0.859 0.041 21.073 0.000
## O4 0.225 0.041 5.474 0.000
## O5 -0.511 0.044 -11.671 0.000
## Conscien =~
## C1 0.727 0.037 19.841 0.000
## C2 0.823 0.040 20.658 0.000
## C3 0.722 0.039 18.308 0.000
## C4 -0.932 0.039 -23.685 0.000
## C5 -1.036 0.048 -21.728 0.000
## Extraversion =~
## E1 -0.931 0.046 -20.089 0.000
## E2 -1.098 0.044 -24.867 0.000
## E3 0.857 0.038 22.842 0.000
## E4 1.048 0.040 26.197 0.000
## E5 0.742 0.038 19.414 0.000
## Agreeable =~
## A1 -0.483 0.043 -11.324 0.000
## A2 0.741 0.033 22.220 0.000
## A3 0.996 0.036 27.964 0.000
## A4 0.766 0.044 17.345 0.000
## A5 0.943 0.035 26.733 0.000
## EmotionalS =~
## N1 1.289 0.040 32.549 0.000
## N2 1.210 0.038 31.693 0.000
## N3 1.159 0.042 27.630 0.000
## N4 0.889 0.043 20.513 0.000
## N5 0.848 0.046 18.365 0.000
##
## Covariances:
## Estimate Std.Err z-value P(>|z|)
## Open ~~
## Conscien 0.297 0.038 7.786 0.000
## Extraversion 0.515 0.033 15.447 0.000
## Agreeable 0.321 0.037 8.631 0.000
## EmotionalS -0.144 0.037 -3.834 0.000
## Conscien ~~
## Extraversion 0.354 0.034 10.523 0.000
## Agreeable 0.310 0.034 9.000 0.000
## EmotionalS -0.276 0.033 -8.283 0.000
## Extraversion ~~
## Agreeable 0.713 0.023 31.141 0.000
## EmotionalS -0.236 0.033 -7.059 0.000
## Agreeable ~~
## EmotionalS -0.226 0.033 -6.751 0.000
##
## Variances:
## Estimate Std.Err z-value P(>|z|)
## .O1 0.841 0.043 19.400 0.000
## .O2 1.987 0.088 22.646 0.000
## .O3 0.671 0.056 11.990 0.000
## .O4 1.402 0.058 24.373 0.000
## .O5 1.447 0.064 22.690 0.000
## .C1 0.988 0.048 20.720 0.000
## .C2 1.135 0.056 20.247 0.000
## .C3 1.197 0.056 21.488 0.000
## .C4 0.974 0.054 17.979 0.000
## .C5 1.563 0.080 19.547 0.000
## .E1 1.743 0.079 22.035 0.000
## .E2 1.362 0.069 19.853 0.000
## .E3 1.056 0.050 20.924 0.000
## .E4 1.059 0.056 18.991 0.000
## .E5 1.205 0.054 22.261 0.000
## .A1 1.705 0.071 23.993 0.000
## .A2 0.835 0.040 20.924 0.000
## .A3 0.738 0.044 16.785 0.000
## .A4 1.660 0.073 22.733 0.000
## .A5 0.776 0.043 17.946 0.000
## .N1 0.805 0.051 15.698 0.000
## .N2 0.794 0.048 16.633 0.000
## .N3 1.198 0.060 19.935 0.000
## .N4 1.601 0.071 22.701 0.000
## .N5 1.905 0.082 23.196 0.000
## Open 1.000
## Conscien 1.000
## Extraversion 1.000
## Agreeable 1.000
## EmotionalS 1.000
##請列出修改指標中,最高的五項。
modi <-modindices(fita)
modi[order(-modi$mi),][1:5,]
## lhs op rhs mi epc sepc.lv sepc.all sepc.nox
## 456 N1 ~~ N2 199.598 0.777 0.777 0.329 0.329
## 124 Extraversion =~ N4 129.512 -0.494 -0.494 -0.319 -0.319
## 95 Conscien =~ E5 78.274 0.377 0.377 0.284 0.284
## 74 Open =~ E4 71.444 -0.465 -0.465 -0.317 -0.317
## 120 Extraversion =~ A5 65.473 0.526 0.526 0.408 0.408
##挑N1N2,且使用原來資料適配
modelb <-
'
Open =~ O1+O2+O3+O4+O5
Conscien =~ C1+C2+C3+C4+C5
Extraversion =~ E1+E2+E3+E4+E5
Agreeable =~ A1+A2+A3+A4+A5
EmotionalS =~ N1+N2+N3+N4+N5
N1~~N2
'
fitb <- cfa(modelb, data=dta1,std.lv=TRUE)
summary(fitb, fit.measures=TRUE)
## lavaan (0.5-23.1097) converged normally after 34 iterations
##
## Used Total
## Number of observations 1228 1400
##
## Estimator ML
## Minimum Function Test Statistic 2134.228
## Degrees of freedom 264
## P-value (Chi-square) 0.000
##
## Model test baseline model:
##
## Minimum Function Test Statistic 9609.573
## Degrees of freedom 300
## P-value 0.000
##
## User model versus baseline model:
##
## Comparative Fit Index (CFI) 0.799
## Tucker-Lewis Index (TLI) 0.772
##
## Loglikelihood and Information Criteria:
##
## Loglikelihood user model (H0) -50004.619
## Loglikelihood unrestricted model (H1) -48937.505
##
## Number of free parameters 61
## Akaike (AIC) 100131.239
## Bayesian (BIC) 100443.140
## Sample-size adjusted Bayesian (BIC) 100249.378
##
## Root Mean Square Error of Approximation:
##
## RMSEA 0.076
## 90 Percent Confidence Interval 0.073 0.079
## P-value RMSEA <= 0.05 0.000
##
## Standardized Root Mean Square Residual:
##
## SRMR 0.075
##
## Parameter Estimates:
##
## Information Expected
## Standard Errors Standard
##
## Latent Variables:
## Estimate Std.Err z-value P(>|z|)
## Open =~
## O1 0.602 0.037 16.492 0.000
## O2 -0.602 0.051 -11.722 0.000
## O3 0.861 0.041 21.101 0.000
## O4 0.227 0.041 5.513 0.000
## O5 -0.509 0.044 -11.646 0.000
## Conscien =~
## C1 0.722 0.037 19.689 0.000
## C2 0.817 0.040 20.500 0.000
## C3 0.721 0.039 18.281 0.000
## C4 -0.937 0.039 -23.852 0.000
## C5 -1.042 0.048 -21.910 0.000
## Extraversion =~
## E1 -0.932 0.046 -20.114 0.000
## E2 -1.108 0.044 -25.173 0.000
## E3 0.850 0.038 22.637 0.000
## E4 1.049 0.040 26.256 0.000
## E5 0.740 0.038 19.365 0.000
## Agreeable =~
## A1 -0.481 0.043 -11.261 0.000
## A2 0.743 0.033 22.305 0.000
## A3 0.999 0.036 28.064 0.000
## A4 0.766 0.044 17.344 0.000
## A5 0.939 0.035 26.580 0.000
## EmotionalS =~
## N1 1.069 0.044 24.045 0.000
## N2 0.996 0.043 23.188 0.000
## N3 1.267 0.043 29.252 0.000
## N4 1.026 0.044 23.552 0.000
## N5 0.937 0.047 19.972 0.000
##
## Covariances:
## Estimate Std.Err z-value P(>|z|)
## .N1 ~~
## .N2 0.628 0.056 11.255 0.000
## Open ~~
## Conscien 0.295 0.038 7.738 0.000
## Extraversion 0.513 0.033 15.380 0.000
## Agreeable 0.321 0.037 8.639 0.000
## EmotionalS -0.154 0.039 -4.001 0.000
## Conscien ~~
## Extraversion 0.354 0.034 10.516 0.000
## Agreeable 0.309 0.034 8.998 0.000
## EmotionalS -0.312 0.034 -9.203 0.000
## Extraversion ~~
## Agreeable 0.711 0.023 30.986 0.000
## EmotionalS -0.299 0.034 -8.923 0.000
## Agreeable ~~
## EmotionalS -0.221 0.035 -6.395 0.000
##
## Variances:
## Estimate Std.Err z-value P(>|z|)
## .O1 0.842 0.043 19.431 0.000
## .O2 1.990 0.088 22.671 0.000
## .O3 0.667 0.056 11.860 0.000
## .O4 1.401 0.057 24.369 0.000
## .O5 1.448 0.064 22.703 0.000
## .C1 0.995 0.048 20.828 0.000
## .C2 1.145 0.056 20.371 0.000
## .C3 1.198 0.056 21.520 0.000
## .C4 0.965 0.054 17.872 0.000
## .C5 1.549 0.080 19.452 0.000
## .E1 1.743 0.079 22.057 0.000
## .E2 1.341 0.068 19.728 0.000
## .E3 1.068 0.051 21.062 0.000
## .E4 1.057 0.056 19.020 0.000
## .E5 1.208 0.054 22.304 0.000
## .A1 1.707 0.071 24.000 0.000
## .A2 0.831 0.040 20.868 0.000
## .A3 0.731 0.044 16.643 0.000
## .A4 1.659 0.073 22.727 0.000
## .A5 0.784 0.043 18.047 0.000
## .N1 1.322 0.070 19.005 0.000
## .N2 1.266 0.065 19.464 0.000
## .N3 0.936 0.066 14.150 0.000
## .N4 1.339 0.067 19.922 0.000
## .N5 1.746 0.080 21.739 0.000
## Open 1.000
## Conscien 1.000
## Extraversion 1.000
## Agreeable 1.000
## EmotionalS 1.000
##將新模型用在第二部分dta2上
fit2 <- cfa(modelb, data=dta2,std.lv=TRUE)
summary(fit2, fit.measures=TRUE)
## lavaan (0.5-23.1097) converged normally after 35 iterations
##
## Used Total
## Number of observations 1208 1400
##
## Estimator ML
## Minimum Function Test Statistic 1949.783
## Degrees of freedom 264
## P-value (Chi-square) 0.000
##
## Model test baseline model:
##
## Minimum Function Test Statistic 8936.297
## Degrees of freedom 300
## P-value 0.000
##
## User model versus baseline model:
##
## Comparative Fit Index (CFI) 0.805
## Tucker-Lewis Index (TLI) 0.778
##
## Loglikelihood and Information Criteria:
##
## Loglikelihood user model (H0) -49613.067
## Loglikelihood unrestricted model (H1) -48638.175
##
## Number of free parameters 61
## Akaike (AIC) 99348.134
## Bayesian (BIC) 99659.034
## Sample-size adjusted Bayesian (BIC) 99465.273
##
## Root Mean Square Error of Approximation:
##
## RMSEA 0.073
## 90 Percent Confidence Interval 0.070 0.076
## P-value RMSEA <= 0.05 0.000
##
## Standardized Root Mean Square Residual:
##
## SRMR 0.074
##
## Parameter Estimates:
##
## Information Expected
## Standard Errors Standard
##
## Latent Variables:
## Estimate Std.Err z-value P(>|z|)
## Open =~
## O1 0.674 0.037 18.089 0.000
## O2 -0.697 0.052 -13.509 0.000
## O3 0.867 0.040 21.879 0.000
## O4 0.332 0.040 8.375 0.000
## O5 -0.715 0.043 -16.460 0.000
## Conscien =~
## C1 0.627 0.038 16.352 0.000
## C2 0.729 0.039 18.503 0.000
## C3 0.687 0.039 17.607 0.000
## C4 -1.008 0.041 -24.535 0.000
## C5 -0.996 0.049 -20.120 0.000
## Extraversion =~
## E1 -0.910 0.049 -18.755 0.000
## E2 -1.168 0.045 -25.844 0.000
## E3 0.828 0.040 20.936 0.000
## E4 1.016 0.041 24.731 0.000
## E5 0.744 0.040 18.512 0.000
## Agreeable =~
## A1 -0.485 0.045 -10.859 0.000
## A2 0.791 0.034 23.208 0.000
## A3 0.969 0.037 26.260 0.000
## A4 0.746 0.044 16.768 0.000
## A5 0.797 0.036 21.923 0.000
## EmotionalS =~
## N1 1.062 0.045 23.377 0.000
## N2 1.000 0.046 21.926 0.000
## N3 1.265 0.044 28.700 0.000
## N4 1.077 0.045 23.812 0.000
## N5 0.877 0.048 18.173 0.000
##
## Covariances:
## Estimate Std.Err z-value P(>|z|)
## .N1 ~~
## .N2 0.716 0.060 11.841 0.000
## Open ~~
## Conscien 0.310 0.038 8.257 0.000
## Extraversion 0.384 0.035 10.844 0.000
## Agreeable 0.284 0.037 7.581 0.000
## EmotionalS -0.082 0.039 -2.119 0.034
## Conscien ~~
## Extraversion 0.365 0.034 10.664 0.000
## Agreeable 0.359 0.035 10.336 0.000
## EmotionalS -0.318 0.035 -9.182 0.000
## Extraversion ~~
## Agreeable 0.650 0.026 24.832 0.000
## EmotionalS -0.314 0.034 -9.284 0.000
## Agreeable ~~
## EmotionalS -0.195 0.036 -5.445 0.000
##
## Variances:
## Estimate Std.Err z-value P(>|z|)
## .O1 0.879 0.046 18.988 0.000
## .O2 1.983 0.090 22.033 0.000
## .O3 0.744 0.053 13.952 0.000
## .O4 1.282 0.054 23.701 0.000
## .O5 1.286 0.063 20.356 0.000
## .C1 1.140 0.052 21.839 0.000
## .C2 1.134 0.054 20.830 0.000
## .C3 1.141 0.054 21.283 0.000
## .C4 0.929 0.059 15.809 0.000
## .C5 1.694 0.085 19.860 0.000
## .E1 1.882 0.086 21.927 0.000
## .E2 1.275 0.071 18.053 0.000
## .E3 1.178 0.056 21.061 0.000
## .E4 1.111 0.059 18.906 0.000
## .E5 1.297 0.059 22.012 0.000
## .A1 1.785 0.075 23.706 0.000
## .A2 0.773 0.041 19.050 0.000
## .A3 0.770 0.047 16.281 0.000
## .A4 1.606 0.072 22.263 0.000
## .A5 0.926 0.047 19.920 0.000
## .N1 1.370 0.072 19.012 0.000
## .N2 1.443 0.073 19.764 0.000
## .N3 0.941 0.068 13.769 0.000
## .N4 1.367 0.071 19.145 0.000
## .N5 1.875 0.085 22.044 0.000
## Open 1.000
## Conscien 1.000
## Extraversion 1.000
## Agreeable 1.000
## EmotionalS 1.000
2
##將影響轉業的認知因素間的相互關係的不同看法,整理成以下五個模型。
#Sager, Griffeth & Hom (1998)收集了資料,並在文章中呈現了相關係數如q2.cov (N = 245)。
#其中 TQ, IS, IQ 分別依序由三題(Y1-Y3)、五題(Y4-Y8)、七題(Y9-Y15)測量,TO 由最後一題測量。
dta <- read.table('q2.cov',header=T)
dta <- as.matrix(dta)
dta
## Y1 Y2 Y3 Y4 Y5 Y6 Y7 Y8 Y9 Y10 Y11
## Y1 1.00 0.64 0.53 0.38 0.50 0.44 0.47 0.50 0.50 0.30 0.45
## Y2 0.64 1.00 0.81 0.56 0.57 0.53 0.57 0.63 0.63 0.34 0.66
## Y3 0.53 0.81 1.00 0.57 0.56 0.49 0.56 0.60 0.63 0.38 0.63
## Y4 0.38 0.56 0.57 1.00 0.53 0.44 0.49 0.55 0.73 0.33 0.71
## Y5 0.50 0.57 0.56 0.53 1.00 0.89 0.90 0.83 0.59 0.34 0.59
## Y6 0.44 0.53 0.49 0.44 0.89 1.00 0.88 0.77 0.48 0.28 0.50
## Y7 0.47 0.57 0.56 0.49 0.90 0.88 1.00 0.81 0.56 0.31 0.53
## Y8 0.50 0.63 0.60 0.55 0.83 0.77 0.81 1.00 0.64 0.37 0.65
## Y9 0.50 0.63 0.63 0.73 0.59 0.48 0.56 0.64 1.00 0.35 0.72
## Y10 0.30 0.34 0.38 0.33 0.34 0.28 0.31 0.37 0.35 1.00 0.36
## Y11 0.45 0.66 0.63 0.71 0.59 0.50 0.53 0.65 0.72 0.36 1.00
## Y12 0.46 0.69 0.71 0.71 0.65 0.58 0.63 0.65 0.69 0.31 0.75
## Y13 0.51 0.70 0.73 0.69 0.70 0.59 0.67 0.70 0.75 0.36 0.73
## Y14 0.55 0.74 0.70 0.61 0.70 0.60 0.68 0.73 0.73 0.35 0.72
## Y15 0.51 0.69 0.63 0.57 0.66 0.58 0.66 0.71 0.64 0.35 0.62
## TO -0.16 -0.20 -0.25 -0.20 -0.15 -0.14 -0.17 -0.25 -0.23 -0.06 -0.28
## Y12 Y13 Y14 Y15 TO
## Y1 0.46 0.51 0.55 0.51 -0.16
## Y2 0.69 0.70 0.74 0.69 -0.20
## Y3 0.71 0.73 0.70 0.63 -0.25
## Y4 0.71 0.69 0.61 0.57 -0.20
## Y5 0.65 0.70 0.70 0.66 -0.15
## Y6 0.58 0.59 0.60 0.58 -0.14
## Y7 0.63 0.67 0.68 0.66 -0.17
## Y8 0.65 0.70 0.73 0.71 -0.25
## Y9 0.69 0.75 0.73 0.64 -0.23
## Y10 0.31 0.36 0.35 0.35 -0.06
## Y11 0.75 0.73 0.72 0.62 -0.28
## Y12 1.00 0.93 0.78 0.67 -0.22
## Y13 0.93 1.00 0.87 0.76 -0.20
## Y14 0.78 0.87 1.00 0.90 -0.22
## Y15 0.67 0.76 0.90 1.00 -0.21
## TO -0.22 -0.20 -0.22 -0.21 1.00
##檢驗三因素十五個題目(Y1-Y15)的CFA模型
model0 <-
'
TQ =~ Y1+Y2+Y3
IS =~ Y4+Y5+Y6+Y7+Y8
IQ =~ Y9+Y10+Y11+Y12+Y13+Y14+Y15
TOF =~ TO
TO~~0*TO
'
fit0 <- cfa(model0,sample.cov=dta,sample.nobs=245)
summary(fit0, fit.measures=TRUE)
## lavaan (0.5-23.1097) converged normally after 60 iterations
##
## Number of observations 245
##
## Estimator ML
## Minimum Function Test Statistic 647.731
## Degrees of freedom 99
## P-value (Chi-square) 0.000
##
## Model test baseline model:
##
## Minimum Function Test Statistic 4196.468
## Degrees of freedom 120
## P-value 0.000
##
## User model versus baseline model:
##
## Comparative Fit Index (CFI) 0.865
## Tucker-Lewis Index (TLI) 0.837
##
## Loglikelihood and Information Criteria:
##
## Loglikelihood user model (H0) -3779.854
## Loglikelihood unrestricted model (H1) -3455.988
##
## Number of free parameters 37
## Akaike (AIC) 7633.708
## Bayesian (BIC) 7763.255
## Sample-size adjusted Bayesian (BIC) 7645.968
##
## Root Mean Square Error of Approximation:
##
## RMSEA 0.150
## 90 Percent Confidence Interval 0.139 0.162
## P-value RMSEA <= 0.05 0.000
##
## Standardized Root Mean Square Residual:
##
## SRMR 0.085
##
## Parameter Estimates:
##
## Information Expected
## Standard Errors Standard
##
## Latent Variables:
## Estimate Std.Err z-value P(>|z|)
## TQ =~
## Y1 1.000
## Y2 1.392 0.115 12.135 0.000
## Y3 1.331 0.113 11.809 0.000
## IS =~
## Y4 1.000
## Y5 1.721 0.169 10.164 0.000
## Y6 1.640 0.165 9.937 0.000
## Y7 1.682 0.167 10.059 0.000
## Y8 1.552 0.161 9.664 0.000
## IQ =~
## Y9 1.000
## Y10 0.495 0.079 6.229 0.000
## Y11 1.001 0.071 14.119 0.000
## Y12 1.148 0.067 17.125 0.000
## Y13 1.205 0.065 18.428 0.000
## Y14 1.162 0.067 17.452 0.000
## Y15 1.052 0.070 15.102 0.000
## TOF =~
## TO 1.000
##
## Covariances:
## Estimate Std.Err z-value P(>|z|)
## TQ ~~
## IS 0.250 0.042 5.905 0.000
## IQ 0.445 0.060 7.406 0.000
## TOF -0.160 0.047 -3.415 0.001
## IS ~~
## IQ 0.342 0.052 6.609 0.000
## TOF -0.100 0.038 -2.630 0.009
## IQ ~~
## TOF -0.189 0.054 -3.523 0.000
##
## Variances:
## Estimate Std.Err z-value P(>|z|)
## .TO 0.000
## .Y1 0.561 0.054 10.343 0.000
## .Y2 0.153 0.027 5.599 0.000
## .Y3 0.225 0.030 7.494 0.000
## .Y4 0.685 0.063 10.899 0.000
## .Y5 0.075 0.012 6.285 0.000
## .Y6 0.160 0.018 9.026 0.000
## .Y7 0.117 0.015 8.040 0.000
## .Y8 0.247 0.025 9.910 0.000
## .Y9 0.371 0.036 10.434 0.000
## .Y10 0.843 0.077 11.000 0.000
## .Y11 0.370 0.035 10.431 0.000
## .Y12 0.172 0.019 9.233 0.000
## .Y13 0.088 0.012 7.104 0.000
## .Y14 0.151 0.017 8.912 0.000
## .Y15 0.305 0.030 10.212 0.000
## TQ 0.435 0.077 5.663 0.000
## IS 0.311 0.066 4.694 0.000
## IQ 0.625 0.084 7.410 0.000
## TOF 0.996 0.090 11.068 0.000
##驗證五個模型
modela <-'
TQ =~ Y1+Y2+Y3
IS =~ Y4+Y5+Y6+Y7+Y8
IQ =~ Y9+Y10+Y11+Y12+Y13+Y14+Y15
TO~IQ
IQ~IS
IS~TQ'
modelb <-'
TQ =~ Y1+Y2+Y3
IS =~ Y4+Y5+Y6+Y7+Y8
IQ =~ Y9+Y10+Y11+Y12+Y13+Y14+Y15
TO~IQ+IS
IQ~IS
IQ~TQ'
modelc <-'
TQ =~ Y1+Y2+Y3
IS =~ Y4+Y5+Y6+Y7+Y8
IQ =~ Y9+Y10+Y11+Y12+Y13+Y14+Y15
TO~IQ+IS
IS~IQ
IQ~TQ'
modeld <-'
TQ =~ Y1+Y2+Y3
IS =~ Y4+Y5+Y6+Y7+Y8
IQ =~ Y9+Y10+Y11+Y12+Y13+Y14+Y15
TOF =~ TO
TO~~0*TO
TO~IS
IS~IQ
IQ~TQ'
modele <-'
TQ =~ Y1+Y2+Y3
IS =~ Y4+Y5+Y6+Y7+Y8
IQ =~ Y9+Y10+Y11+Y12+Y13+Y14+Y15
TOF =~ TO
TO~TQ+IQ+IS
TQ~IS+IQ
IQ~IS'
#modindices(fit0)
fit1 <- sem(modela,sample.cov=dta,sample.nobs=245)
fit2 <- sem(modelb,sample.cov=dta,sample.nobs=245)
fit3 <- sem(modelc,sample.cov=dta,sample.nobs=245)
fit4 <- sem(modeld,sample.cov=dta,sample.nobs=245)
fit5 <- sem(modele,sample.cov=dta,sample.nobs=245)
## Warning in lav_model_vcov(lavmodel = lavmodel, lavsamplestats = lavsamplestats, : lavaan WARNING: could not compute standard errors!
## lavaan NOTE: this may be a symptom that the model is not identified.
result1 <- fitMeasures(fit1, c("chisq", "df", "pvalue", "rmsea", "srmr","nnfi","cfi","AIC"))
result2 <- fitMeasures(fit2, c("chisq", "df", "pvalue", "rmsea", "srmr","nnfi","cfi","AIC"))
result3 <- fitMeasures(fit3, c("chisq", "df", "pvalue", "rmsea", "srmr","nnfi","cfi","AIC"))
result4 <- fitMeasures(fit4, c("chisq", "df", "pvalue", "rmsea", "srmr","nnfi","cfi","AIC"))
result5 <- fitMeasures(fit5, c("chisq", "df", "pvalue", "rmsea", "srmr","nnfi","cfi","AIC"))
result <- rbind(result1,result2,result3,result4,result5)
round(result,3)
## chisq df pvalue rmsea srmr nnfi cfi aic
## result1 756.358 102 0 0.162 0.121 0.811 0.839 7736.335
## result2 648.722 100 0 0.150 0.085 0.838 0.865 7632.699
## result3 649.153 101 0 0.149 0.085 0.840 0.866 7631.129
## result4 648.837 101 0 0.149 0.086 0.840 0.866 7630.814
## result5 647.731 98 0 0.151 0.085 0.835 0.865 7635.708
summary(fit3, fit.measures=TRUE)
## lavaan (0.5-23.1097) converged normally after 53 iterations
##
## Number of observations 245
##
## Estimator ML
## Minimum Function Test Statistic 649.153
## Degrees of freedom 101
## P-value (Chi-square) 0.000
##
## Model test baseline model:
##
## Minimum Function Test Statistic 4196.468
## Degrees of freedom 120
## P-value 0.000
##
## User model versus baseline model:
##
## Comparative Fit Index (CFI) 0.866
## Tucker-Lewis Index (TLI) 0.840
##
## Loglikelihood and Information Criteria:
##
## Loglikelihood user model (H0) -3780.565
## Loglikelihood unrestricted model (H1) -3455.988
##
## Number of free parameters 35
## Akaike (AIC) 7631.129
## Bayesian (BIC) 7753.673
## Sample-size adjusted Bayesian (BIC) 7642.726
##
## Root Mean Square Error of Approximation:
##
## RMSEA 0.149
## 90 Percent Confidence Interval 0.138 0.160
## P-value RMSEA <= 0.05 0.000
##
## Standardized Root Mean Square Residual:
##
## SRMR 0.085
##
## Parameter Estimates:
##
## Information Expected
## Standard Errors Standard
##
## Latent Variables:
## Estimate Std.Err z-value P(>|z|)
## TQ =~
## Y1 1.000
## Y2 1.395 0.115 12.136 0.000
## Y3 1.331 0.113 11.791 0.000
## IS =~
## Y4 1.000
## Y5 1.721 0.169 10.168 0.000
## Y6 1.639 0.165 9.939 0.000
## Y7 1.681 0.167 10.061 0.000
## Y8 1.552 0.161 9.666 0.000
## IQ =~
## Y9 1.000
## Y10 0.495 0.079 6.242 0.000
## Y11 1.001 0.071 14.151 0.000
## Y12 1.145 0.067 17.097 0.000
## Y13 1.202 0.065 18.406 0.000
## Y14 1.163 0.066 17.508 0.000
## Y15 1.053 0.069 15.166 0.000
##
## Regressions:
## Estimate Std.Err z-value P(>|z|)
## TO ~
## IQ -0.330 0.134 -2.457 0.014
## IS 0.043 0.189 0.226 0.821
## IS ~
## IQ 0.548 0.066 8.255 0.000
## IQ ~
## TQ 1.026 0.103 9.967 0.000
##
## Variances:
## Estimate Std.Err z-value P(>|z|)
## .Y1 0.561 0.054 10.347 0.000
## .Y2 0.150 0.027 5.507 0.000
## .Y3 0.227 0.030 7.531 0.000
## .Y4 0.685 0.063 10.899 0.000
## .Y5 0.075 0.012 6.268 0.000
## .Y6 0.160 0.018 9.031 0.000
## .Y7 0.117 0.015 8.047 0.000
## .Y8 0.247 0.025 9.912 0.000
## .Y9 0.370 0.035 10.429 0.000
## .Y10 0.842 0.077 11.000 0.000
## .Y11 0.369 0.035 10.425 0.000
## .Y12 0.176 0.019 9.272 0.000
## .Y13 0.091 0.013 7.254 0.000
## .Y14 0.149 0.017 8.873 0.000
## .Y15 0.301 0.030 10.195 0.000
## .TO 0.937 0.085 11.039 0.000
## TQ 0.434 0.077 5.658 0.000
## .IS 0.123 0.027 4.599 0.000
## .IQ 0.169 0.027 6.153 0.000