井出草平の研究ノート

lavaanパッケージを用いて階層因子分析を推定する[R]

階層因子分析(hierarchical factor analysis)について松田淑美・狩野裕「高次因子分析モデルと階層因子分析モデルについて」から説明を引用しよう。

http://www.sigmath.es.osaka-u.ac.jp/~kano/research/meeting/20050827_BSJ33/matsudaABS.pdf

階層因子分析モデルは,全ての観測変数を説明する一般因子(general factor)と,一部の観測変数を説明するグループ因子(group factor)からなる.このモデルには,いくつかの「層 (layer)」があり,各層において,観測変数は,ひとつの因子に負荷する.層の順番は,各層に含まれる因子の数によって決まり,因子数の最も多い層が第1 層となる.図 2のモデルでは,F1 ∼ F4 が第 1 層,F5 ∼ F6 が第2層,Gが第3層となる.また,F1 ∼ F6がグループ因子,G が一般因子である.これらの因子は全て,互いに直交している.

f:id:iDES:20200613005426p:plain

特に,2 層のモデル(ひとつの一般因子といくつかのグループ因子からなるモデル)は双因子モデル(bi–factor model)とも言う(図 3).

f:id:iDES:20200613005439p:plain

データ

lavaanパッケージに同梱されているHolzingerSwineford1939を使用する。

ドキュメントには次のようにデータの説明が書かれてある。

古典的なHolzinger and Swineford (1939)のデータセットは、2つの異なる学校(PasteurとGrant-White)の7年生と8年生の子供たちの精神能力テストのスコアで構成されている。オリジナルのデータセット(MBESSパッケージで利用可能)には、26のテストのスコアがある。しかし、9つの変数を持つより小さなサブセットが、文献ではより広く使われている(たとえば、Joreskogの1969年の論文では、Grant-Whiteの学校からの145人の被験者のみを使用している)。

  • x1 Visual perception
  • x2 Cubes
  • x3 Lozenges
  • x4 Paragraph comprehension
  • x5 Sentence completion
  • x6 Word meaning
  • x7 Speeded addition
  • x8 Speeded counting of dots
  • x9 Speeded discrimination straight and curved capitals

因子

visual textual speed
Visual perception Paragraph comprehension Speeded addition
Cubes Sentence completion Speeded counting of dots
Lozenges Word meaning Speeded discrimination straight and curved capitals

モデル

すべての観測変数に共通して影響を与える構成概念として「知能(intelligence)」を想定する。 この一般因子とグループ因子との聞の相関は,あらかじめ0に固定する。

library(lavaan)
HS1.model <- 'visual =~ x1 + x2 + x3
             textual =~ x4 + x5 + x6
             speed =~ x7 + x8 + x9
             intelligence =~ x1 + x2 + x3 + x4 + x5 + x6 + x7 + x8 + x9
             intelligence ~~ 0*visual + 0*textual + 0*speed'

実行

HS1.fit <- sem(HS2.model, data = HolzingerSwineford1939, std.lv=T)
summary(HS1.fit, standardized=TRUE) 

分散

Variances:
                   Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
   .x1                0.395    0.214    1.848    0.065    0.395    0.290
   .x2                1.155    0.116    9.944    0.000    1.155    0.836
   .x3               -0.079    1.656   -0.048    0.962   -0.079   -0.062
   .x4                0.386    0.048    8.122    0.000    0.386    0.286
   .x5                0.383    0.061    6.233    0.000    0.383    0.230
   .x6                0.371    0.042    8.732    0.000    0.371    0.310
   .x7                0.654    0.099    6.604    0.000    0.654    0.552
   .x8                0.453    0.085    5.318    0.000    0.453    0.444
   .x9                0.578    0.062    9.337    0.000    0.578    0.569

x3の分散がマイナスになっている。これは不適解であるため、x3にも制約を課す必要がある。

モデルの改善

library(lavaan)
HS2.model <- 'visual =~ x1 + x2 + x3
             textual =~ x4 + x5 + x6
             speed =~ x7 + x8 + x9
             intelligence =~ x1 + x2 + x3 + x4 + x5 + x6 + x7 + x8 + x9
             intelligence ~~ 0*visual + 0*textual + 0*speed
             x3 ~~ a*x3; a>0'

実行

HS2.fit <- sem(HS2.model, data = HolzingerSwineford1939, std.lv=T)
summary(HS2.fit, standardized=TRUE) 

結果。

  Estimator                                         ML
  Optimization method                           NLMINB
  Number of free parameters                         30
  Number of inequality constraints                   1
                                                      
  Number of observations                           301
                                                      
Model Test User Model:
                                                      
  Test statistic                                26.016
  Degrees of freedom                                15
  P-value (Chi-square)                           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
  visual =~                                                             
    x1               -0.251    0.200   -1.255    0.209   -0.251   -0.216
    x2                0.084    0.094    0.891    0.373    0.084    0.071
    x3                0.779    0.123    6.320    0.000    0.779    0.690
  textual =~                                                            
    x4                0.868    0.065   13.256    0.000    0.868    0.747
    x5                1.058    0.066   15.930    0.000    1.058    0.821
    x6                0.790    0.063   12.620    0.000    0.790    0.722
  speed =~                                                              
    x7                0.722    0.080    9.019    0.000    0.722    0.664
    x8                0.706    0.075    9.469    0.000    0.706    0.698
    x9                0.465    0.064    7.300    0.000    0.465    0.461
  intelligence =~                                                       
    x1                0.949    0.097    9.810    0.000    0.949    0.814
    x2                0.472    0.073    6.433    0.000    0.472    0.402
    x3                0.817    0.127    6.460    0.000    0.817    0.724
    x4                0.460    0.094    4.891    0.000    0.460    0.396
    x5                0.397    0.104    3.835    0.000    0.397    0.308
    x6                0.449    0.088    5.092    0.000    0.449    0.411
    x7                0.097    0.070    1.377    0.169    0.097    0.089
    x8                0.264    0.066    3.985    0.000    0.264    0.261
    x9                0.471    0.067    7.082    0.000    0.471    0.468

Covariances:
                   Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
  visual ~~                                                             
    intelligence      0.000                               0.000    0.000
  textual ~~                                                            
    intelligence      0.000                               0.000    0.000
  speed ~~                                                              
    intelligence      0.000                               0.000    0.000
  visual ~~                                                             
    textual          -0.240    0.094   -2.566    0.010   -0.240   -0.240
    speed            -0.002    0.094   -0.021    0.983   -0.002   -0.002
  textual ~~                                                            
    speed             0.122    0.083    1.473    0.141    0.122    0.122

Variances:
                   Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
   .x3         (a)   -0.000                              -0.000   -0.000
   .x1                0.394    0.216    1.822    0.068    0.394    0.290
   .x2                1.152    0.098   11.799    0.000    1.152    0.834
   .x4                0.386    0.048    8.120    0.000    0.386    0.286
   .x5                0.383    0.061    6.252    0.000    0.383    0.231
   .x6                0.371    0.042    8.731    0.000    0.371    0.310
   .x7                0.653    0.099    6.620    0.000    0.653    0.552
   .x8                0.454    0.085    5.357    0.000    0.454    0.444
   .x9                0.577    0.060    9.582    0.000    0.577    0.569
    visual            1.000                               1.000    1.000
    textual           1.000                               1.000    1.000
    speed             1.000                               1.000    1.000
    intellignc        1.000                               1.000    1.000

Constraints:
                                               |Slack|
    a - 0                                        0.000

パス図の描画

library(semPlot)
semPaths(HS2.fit,layout="spring",
whatLabels="stand",sizeMan=5,
shapeLat="ellipse",sizeLat=8,sizeLat2=5,
exoCov=F,residuals=F,nCharNodes=0,
edge.label.cex=0.9,edge.color="black")

f:id:iDES:20200613010114p:plain