井出草平の研究ノート

lavaanパッケージを用いてPLSモデルを推定する

PLS(Partial Least Squares)モデルについて。日本語にすると部分的最小二乗回帰である。

PLSモデルは,複数の観測変数によって純粋に指標化された新たな変数が,別の複数の観測変数の背後に仮定される構成概念へ及ぼす影響の強さについて検討するモデルであると捉えることができます。(豊田秀樹『共分散構造分析[R編]』p.55)

前回と同じくlavaanパッケージに同梱されているPoliticalDemocracyのデータを使用してPLSモデルをlavaanパッケージで推定してみたい。

モデル

末尾のsemPlotパッケージで作成したパス図を先に示す。

f:id:iDES:20200604175731p:plain

1) x1-x3から回帰分析を行いf1を作成する。

  • x1 1960年の一人当たり国民総生産(GNP)
  • x2 1960年の一人当たりの無生物エネルギー消費量
  • x3 1960年の産業界における労働力の割合

2) y1-y4からf1という潜在変数を作成する。

  • y1 1960年の報道の自由に関する専門家の評価
  • y2 1960年の政治的反対運動の自由
  • y3 1960年の選挙の公平性
  • y4 1960年の選出立法府の有効性

3) f1からf2への影響を見る。

コード

パッケージの読み込み

library(lavaan)

モデルの構築

model <- '
  # measurement model
    f1 ~ x1 + x2 + x3 # regression
    f2 =~ y1 + y2 + y3 + y4 # measurement model
    f1 =~ f2
    f1 ~~ 0*f1
    f2 ~~ f2'

f1~~0*f1は、f_1の分散を0に固定することを表している。特定の値をとるようにあらかじめ指定された母数を固定母数(fixed paramteter)という。固定母数は*の前に固定したい値を示すことで特定される。ここでは、因子の分散を0に固定することで、当該因子に誤差を仮定しないことを表現している。

fit <- sem(model=model, data=PoliticalDemocracy, estimator="ML")
summary(fit, standardized=TRUE) # 標準化

結果。

lavaan 0.6-5 ended normally after 34 iterations

  Estimator                                         ML
  Optimization method                           NLMINB
  Number of free parameters                         11
                                                      
  Number of observations                            75
                                                      
Model Test User Model:
                                                      
  Test statistic                                22.240
  Degrees of freedom                                11
  P-value (Chi-square)                           0.023

Parameter Estimates:

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

Latent Variables:
                   Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
  f2 =~                                                                 
    y1                1.000                               2.108    0.809
    y2                1.400    0.200    6.994    0.000    2.951    0.753
    y3                1.093    0.169    6.471    0.000    2.305    0.707
    y4                1.413    0.168    8.405    0.000    2.978    0.895
  f1 =~                                                                 
    f2                1.000                               0.471    0.471

Regressions:
                   Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
  f1 ~                                                                  
    x1                1.097    0.725    1.513    0.130    1.104    0.804
    x2                0.237    0.399    0.595    0.552    0.239    0.359
    x3               -0.120    0.319   -0.376    0.707   -0.121   -0.168

Variances:
                   Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
   .f1                0.000                               0.000    0.000
   .f2                3.458    0.864    4.001    0.000    0.778    0.778
   .y1                2.343    0.509    4.600    0.000    2.343    0.345
   .y2                6.665    1.303    5.116    0.000    6.665    0.434
   .y3                5.309    0.989    5.366    0.000    5.309    0.500
   .y4                2.198    0.719    3.058    0.002    2.198    0.199

パス図は下記のコードで出力した。rotationというオプションで90度回転ができるようだ。edge.label.cexというオプションで推定値の文字の大きさも調整できるようだ。いろいろ調整すればsemPlotパッケージでの作図も悪くないのかもしれない。

library(semPlot)
semPaths(fit, layout = "tree", shapeLat="ellipse", whatLabels  = "stand", 
         nDigits=3, shapeMan="square", sizeMan =8, 
         sizeLat =8, sizeLat2 =8, style = "lisrel",
         residScale=12, curve=2, optimizeLatRes=T,edge.color="black",
         rotation = 2, edge.label.cex=1)