パス解析は、観測変数間の因果関係を仮定できる場合に用いる。複数の結果変数を同時に扱える点が回帰分析と異なる。
dat <- read.csv("data/data_ch10-1.csv",fileEncoding = "shift-jis", header = TRUE)
head(dat)
student | 興味関心 | 理解度 | 説明 | 学生対応 |
---|---|---|---|---|
S001 | 3 | 3 | 3 | 3 |
S002 | 2 | 4 | 1 | 4 |
S003 | 4 | 5 | 5 | 3 |
S004 | 5 | 5 | 5 | 5 |
S005 | 4 | 5 | 5 | 5 |
S006 | 3 | 5 | 4 | 3 |
因果の方向が決まっており、起点となった変数に戻ることがない。
model.RM <- '
興味関心 ~ 学生対応 + 説明
理解度 ~ 説明 + 興味関心 '
model parameter は Regressions、Variancesに現れる6つである。(モデルでは「説明」と「学生対応」の相関は想定していない)
fit.RM <- sem(model.RM, data = dat, estimator = "ML")
fit.RM
## lavaan 0.6.15 ended normally after 1 iteration
##
## Estimator ML
## Optimization method NLMINB
## Number of model parameters 6
##
## Number of observations 200
##
## Model Test User Model:
##
## Test statistic 0.097
## Degrees of freedom 1
## P-value (Chi-square) 0.755
summary(fit.RM, fit.measures = TRUE, standardized = TRUE, rsquare = TRUE)
## lavaan 0.6.15 ended normally after 1 iteration
##
## Estimator ML
## Optimization method NLMINB
## Number of model parameters 6
##
## Number of observations 200
##
## Model Test User Model:
##
## Test statistic 0.097
## Degrees of freedom 1
## P-value (Chi-square) 0.755
##
## Model Test Baseline Model:
##
## Test statistic 166.684
## Degrees of freedom 5
## P-value 0.000
##
## User Model versus Baseline Model:
##
## Comparative Fit Index (CFI) 1.000
## Tucker-Lewis Index (TLI) 1.028
##
## Loglikelihood and Information Criteria:
##
## Loglikelihood user model (H0) -458.956
## Loglikelihood unrestricted model (H1) -458.907
##
## Akaike (AIC) 929.912
## Bayesian (BIC) 949.702
## Sample-size adjusted Bayesian (SABIC) 930.693
##
## Root Mean Square Error of Approximation:
##
## RMSEA 0.000
## 90 Percent confidence interval - lower 0.000
## 90 Percent confidence interval - upper 0.128
## P-value H_0: RMSEA <= 0.050 0.808
## P-value H_0: RMSEA >= 0.080 0.132
##
## Standardized Root Mean Square Residual:
##
## SRMR 0.005
##
## Parameter Estimates:
##
## Standard errors Standard
## Information Expected
## Information saturated (h1) model Structured
##
## Regressions:
## Estimate Std.Err z-value P(>|z|) Std.lv Std.all
## 興味関心 ~
## 学生対応 -0.006 0.062 -0.099 0.921 -0.006 -0.007
## 説明 0.425 0.059 7.160 0.000 0.425 0.474
## 理解度 ~
## 説明 0.145 0.047 3.065 0.002 0.145 0.184
## 興味関心 0.492 0.053 9.282 0.000 0.492 0.557
##
## Variances:
## Estimate Std.Err z-value P(>|z|) Std.lv Std.all
## .興味関心 0.776 0.078 10.000 0.000 0.776 0.777
## .理解度 0.435 0.044 10.000 0.000 0.435 0.559
##
## R-Square:
## Estimate
## 興味関心 0.223
## 理解度 0.441
User Model の自由度
外生変数「説明」「学生対応」の分散と相関のパラメーター3個を除いて. 10-6-(3)=1.
Baseline Model の自由度
パスのない場合だから、 10-2-(3)=5.(1+4 パス係数の個数4を加えてもよい)
par(family = "HiraKakuProN-W3") #日本語フォントの指定
semPaths(fit.RM, what = "stand", style = "lisrel", layout = "tree", rotation = 2, nCharNodes = 0, nCharEdges = 0, fade = FALSE, edge.width = 0.2, label.scale = FALSE, label.cex = 1.2, theme = 'gray', asize = 6.0, node.width = 2.0, curve = 2.0)
複数の観測変数によって1つの潜在変数が規定される(因子分析とはパスが逆)
dat.2 <- read.csv("data/data_ch10-2.csv",fileEncoding = "shift-jis", header = TRUE)
head(dat.2)
student | 理解度 | 興味関心 | 進み具合 | 説明 | 話し方 | 学生対応 |
---|---|---|---|---|---|---|
S001 | 3 | 3 | 3 | 3 | 3 | 3 |
S002 | 4 | 2 | 4 | 1 | 2 | 4 |
S003 | 5 | 4 | 5 | 5 | 5 | 3 |
S004 | 5 | 5 | 5 | 5 | 5 | 5 |
S005 | 5 | 4 | 5 | 5 | 5 | 5 |
S006 | 5 | 3 | 5 | 4 | 5 | 3 |
観測変数の因果関係に1つの潜在変数を仮定するモデル.
model.MIMIC <- '
指導技術 =~ 進み具合 + 興味関心 + 理解度
指導技術 ~ 学生対応 + 話し方 + 説明 '
fit.MIMIC <- sem(model.MIMIC, data = dat.2, estimator = "ML")
summary(fit.MIMIC, fit.measures = TRUE, standardized = TRUE, rsquare = TRUE)
## lavaan 0.6.15 ended normally after 23 iterations
##
## Estimator ML
## Optimization method NLMINB
## Number of model parameters 9
##
## Number of observations 200
##
## Model Test User Model:
##
## Test statistic 12.559
## Degrees of freedom 6
## P-value (Chi-square) 0.051
##
## Model Test Baseline Model:
##
## Test statistic 241.642
## Degrees of freedom 12
## P-value 0.000
##
## User Model versus Baseline Model:
##
## Comparative Fit Index (CFI) 0.971
## Tucker-Lewis Index (TLI) 0.943
##
## Loglikelihood and Information Criteria:
##
## Loglikelihood user model (H0) -746.920
## Loglikelihood unrestricted model (H1) -740.640
##
## Akaike (AIC) 1511.840
## Bayesian (BIC) 1541.524
## Sample-size adjusted Bayesian (SABIC) 1513.012
##
## Root Mean Square Error of Approximation:
##
## RMSEA 0.074
## 90 Percent confidence interval - lower 0.000
## 90 Percent confidence interval - upper 0.132
## P-value H_0: RMSEA <= 0.050 0.207
## P-value H_0: RMSEA >= 0.080 0.487
##
## Standardized Root Mean Square Residual:
##
## SRMR 0.035
##
## 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
## 指導技術 =~
## 進み具合 1.000 0.663 0.556
## 興味関心 1.119 0.157 7.138 0.000 0.742 0.743
## 理解度 1.139 0.157 7.279 0.000 0.756 0.857
##
## Regressions:
## Estimate Std.Err z-value P(>|z|) Std.lv Std.all
## 指導技術 ~
## 学生対応 -0.005 0.044 -0.116 0.908 -0.008 -0.008
## 話し方 0.163 0.057 2.873 0.004 0.245 0.266
## 説明 0.233 0.059 3.979 0.000 0.352 0.392
##
## Variances:
## Estimate Std.Err z-value P(>|z|) Std.lv Std.all
## .進み具合 0.985 0.109 9.036 0.000 0.985 0.691
## .興味関心 0.447 0.065 6.876 0.000 0.447 0.448
## .理解度 0.207 0.052 4.007 0.000 0.207 0.266
## .指導技術 0.284 0.074 3.817 0.000 0.645 0.645
##
## R-Square:
## Estimate
## 進み具合 0.309
## 興味関心 0.552
## 理解度 0.734
## 指導技術 0.355
par(family = "HiraKakuProN-W3") #日本語フォントの指定
semPaths(fit.MIMIC, what = "stand", style = "lisrel", layout = "tree", rotation = 2, nCharNodes = 0, nCharEdges = 0, fade = FALSE, optimizeLatRes = TRUE, edge.width = 0.2, label.scale = FALSE, label.cex = 1.2, theme = 'gray', asize = 6.0, node.width = 1.5)
一方の潜在変数が予測変数、もう一方の潜在変数が結果変数
dat.3 <- read.csv("data/data_ch10-3.csv",fileEncoding = "shift-jis", header = TRUE)
head(dat.3)
student | item1 | item2 | item4 | item6 | item8 | item9 |
---|---|---|---|---|---|---|
S001 | 3 | 3 | 3 | 3 | 3 | 3 |
S002 | 2 | 1 | 4 | 4 | 4 | 2 |
S003 | 5 | 5 | 5 | 3 | 5 | 4 |
S004 | 5 | 5 | 5 | 5 | 5 | 5 |
S005 | 5 | 5 | 5 | 5 | 5 | 4 |
S006 | 5 | 4 | 5 | 3 | 5 | 3 |
model.MIC <- '
授業満足度 =~ item8 + item9 + item4
指導技術 =~ item2 + item1 + item6
授業満足度 ~ 指導技術 '
fit.MIC <- sem(model.MIC, data = dat.3, estimator = "ML")
summary(fit.MIC, fit.measures = TRUE, standardized = TRUE, rsquare = TRUE)
## lavaan 0.6.15 ended normally after 23 iterations
##
## Estimator ML
## Optimization method NLMINB
## Number of model parameters 13
##
## Number of observations 200
##
## Model Test User Model:
##
## Test statistic 13.786
## Degrees of freedom 8
## P-value (Chi-square) 0.088
##
## Model Test Baseline Model:
##
## Test statistic 377.790
## Degrees of freedom 15
## P-value 0.000
##
## User Model versus Baseline Model:
##
## Comparative Fit Index (CFI) 0.984
## Tucker-Lewis Index (TLI) 0.970
##
## Loglikelihood and Information Criteria:
##
## Loglikelihood user model (H0) -1581.788
## Loglikelihood unrestricted model (H1) -1574.895
##
## Akaike (AIC) 3189.576
## Bayesian (BIC) 3232.455
## Sample-size adjusted Bayesian (SABIC) 3191.269
##
## Root Mean Square Error of Approximation:
##
## RMSEA 0.060
## 90 Percent confidence interval - lower 0.000
## 90 Percent confidence interval - upper 0.112
## P-value H_0: RMSEA <= 0.050 0.327
## P-value H_0: RMSEA >= 0.080 0.305
##
## Standardized Root Mean Square Residual:
##
## SRMR 0.036
##
## 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
## 授業満足度 =~
## item8 1.000 0.756 0.857
## item9 0.980 0.106 9.261 0.000 0.741 0.742
## item4 0.881 0.121 7.296 0.000 0.666 0.558
## 指導技術 =~
## item2 1.000 0.929 0.834
## item1 0.905 0.102 8.846 0.000 0.842 0.776
## item6 0.463 0.089 5.169 0.000 0.430 0.403
##
## Regressions:
## Estimate Std.Err z-value P(>|z|) Std.lv Std.all
## 授業満足度 ~
## 指導技術 0.538 0.073 7.326 0.000 0.662 0.662
##
## Variances:
## Estimate Std.Err z-value P(>|z|) Std.lv Std.all
## .item8 0.207 0.052 3.987 0.000 0.207 0.266
## .item9 0.449 0.065 6.887 0.000 0.449 0.450
## .item4 0.982 0.109 9.021 0.000 0.982 0.689
## .item2 0.379 0.089 4.273 0.000 0.379 0.305
## .item1 0.468 0.081 5.762 0.000 0.468 0.398
## .item6 0.954 0.100 9.564 0.000 0.954 0.838
## .授業満足度 0.321 0.064 5.037 0.000 0.562 0.562
## 指導技術 0.864 0.143 6.041 0.000 1.000 1.000
##
## R-Square:
## Estimate
## item8 0.734
## item9 0.550
## item4 0.311
## item2 0.695
## item1 0.602
## item6 0.162
## 授業満足度 0.438
par(family = "HiraKakuProN-W3") #日本語フォントの指定
semPaths(fit.MIC, what = "stand", style = "lisrel", layout = "tree", rotation = 2, nCharNodes = 0, nCharEdges = 0, fade = FALSE, optimizeLatRes = TRUE, edge.width = 0.2, label.scale = FALSE, label.cex = 1.2, theme = 'gray', asize = 6.0, node.width = 1.5)