井出草平の研究ノート

確証的因子分析におけるMIMICモデル[R][Mplus]

複数の観測変数によって1つの構成概念が規定され、その構成概念が別の観測変数群に影響を与えているようなモデルをMIMIC(Multiple Indicator Multiple Cause)モデルと呼ぶ。

MIMICモデルのデモを見ていると、Mplusの例5.8を使ったものが多かったので、それを走らせてみたい。 このケースは確証的因子分析(Confirmatory Factor Analysis)の拡張モデルである。

f:id:iDES:20200530002347p:plain

R lavaan

まずlavaanで扱えるようにデータを整える。

# Example 5.8 from Mplus user guide:
Data <- read.table("http://www.statmodel.com/usersguide/chap5/ex5.8.dat") 
# Add variable names
names(Data) <- c(paste("y", 1:6, sep = ""), paste("x", 1:3, sep = "")) 

このようなデータになる。

f:id:iDES:20200530002402p:plain

実行コードは下記。

library("lavaan")
model <- '
  f1 =~ y1 + y2 + y3
  f2 =~ y4 + y5 + y6
  f1 + f2 ~ x1 + x2 + x3'
fit <- lavaan:::cfa(model, data = Data, std.lv = TRUE)
summary(fit, standardized=TRUE, fit.measures=TRUE)

結果。

lavaan 0.6-5 ended normally after 36 iterations

  Estimator                                         ML
  Optimization method                           NLMINB
  Number of free parameters                         19
                                                      
  Number of observations                           500
                                                      
Model Test User Model:
                                                      
  Test statistic                                20.023
  Degrees of freedom                                20
  P-value (Chi-square)                           0.457

Model Test Baseline Model:

  Test statistic                              4176.601
  Degrees of freedom                                33
  P-value                                        0.000

User Model versus Baseline Model:

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

Loglikelihood and Information Criteria:

  Loglikelihood user model (H0)              -4000.617
  Loglikelihood unrestricted model (H1)      -3990.606
                                                      
  Akaike (AIC)                                8039.235
  Bayesian (BIC)                              8119.312
  Sample-size adjusted Bayesian (BIC)         8059.005

Root Mean Square Error of Approximation:

  RMSEA                                          0.002
  90 Percent confidence interval - lower         0.000
  90 Percent confidence interval - upper         0.038
  P-value RMSEA <= 0.05                          0.994

Standardized Root Mean Square Residual:

  SRMR                                           0.008

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
  f1 =~                                                                 
    y1                0.849    0.036   23.407    0.000    1.643    0.914
    y2                0.876    0.037   23.627    0.000    1.696    0.921
    y3                0.867    0.037   23.733    0.000    1.679    0.925
  f2 =~                                                                 
    y4                0.802    0.035   23.067    0.000    1.748    0.922
    y5                0.780    0.033   23.504    0.000    1.700    0.937
    y6                0.783    0.034   23.046    0.000    1.707    0.921

Regressions:
                   Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
  f1 ~                                                                  
    x1                0.585    0.037   15.786    0.000    0.302    0.517
    x2                0.667    0.043   15.414    0.000    0.345    0.497
    x3                0.814    0.058   13.950    0.000    0.420    0.429
  f2 ~                                                                  
    x1                0.846    0.045   18.783    0.000    0.388    0.663
    x2                0.750    0.046   16.237    0.000    0.344    0.496
    x3                0.539    0.054    9.975    0.000    0.247    0.252

Covariances:
                   Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
 .f1 ~~                                                                 
   .f2                0.336    0.051    6.621    0.000    0.336    0.336

Variances:
                   Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
   .y1                0.529    0.046   11.505    0.000    0.529    0.164
   .y2                0.512    0.046   11.056    0.000    0.512    0.151
   .y3                0.477    0.044   10.806    0.000    0.477    0.145
   .y4                0.541    0.046   11.678    0.000    0.541    0.151
   .y5                0.399    0.038   10.490    0.000    0.399    0.121
   .y6                0.522    0.044   11.722    0.000    0.522    0.152
   .f1                1.000                               0.267    0.267
   .f2                1.000                               0.210    0.210

パス図

ついでにsemPlotパッケージで描画もしておこう。

library(semPlot)
semPaths(fit, title = FALSE, curvePivot = TRUE)

f:id:iDES:20200530002447p:plain

やはり手書きの方がキレイに描けるが、自動でここまでやってくれるのだから文句も言えないだろう。

Mplus

Mplusの例を使ったので、Mplusでも同じように走らせておこう。ちなみに結果は微妙に違っている。

inpファイルは下記。

TITLE: this is an example of a CFA with
          covariates (MIMIC) with continuous factor
          indicators 
DATA: FILE IS ex5.8.dat;
VARIABLE: NAMES ARE y1-y6 x1-x3;
MODEL: f1 BY y1-y3;
       f2 BY y4-y6;
       f1 f2 ON x1-x3;

データはこちらからダウンロード。 http://www.statmodel.com/usersguide/chapter5.shtml

this is an example of a CFA with
covariates (MIMIC) with continuous factor
indicators

SUMMARY OF ANALYSIS

Number of groups                                                 1
Number of observations                                         500

Number of dependent variables                                    6
Number of independent variables                                  3
Number of continuous latent variables                            2

Observed dependent variables

  Continuous
   Y1          Y2          Y3          Y4          Y5          Y6

Observed independent variables
   X1          X2          X3

Continuous latent variables
   F1          F2


Estimator                                                       ML
Information matrix                                        OBSERVED
Maximum number of iterations                                  1000
Convergence criterion                                    0.500D-04
Maximum number of steepest descent iterations                   20

Input data file(s)
  ex5.8.dat

Input data format  FREE



UNIVARIATE SAMPLE STATISTICS


     UNIVARIATE HIGHER-ORDER MOMENT DESCRIPTIVE STATISTICS

         Variable/         Mean/     Skewness/   Minimum/ % with                Percentiles
        Sample Size      Variance    Kurtosis    Maximum  Min/Max      20%/60%    40%/80%    Median

     Y1                    2.066      -0.174      -2.827    0.20%       0.516      1.668      2.111
             500.000       3.227      -0.300       6.876    0.20%       2.616      3.685
     Y2                    2.088       0.021      -2.785    0.20%       0.544      1.611      2.178
             500.000       3.388      -0.114       7.456    0.20%       2.561      3.658
     Y3                    2.088       0.036      -2.223    0.20%       0.534      1.685      2.046
             500.000       3.295      -0.323       6.987    0.20%       2.510      3.553
     Y4                    1.663      -0.017      -3.780    0.20%       0.067      1.162      1.694
             500.000       3.595      -0.233       7.734    0.20%       2.122      3.307
     Y5                    1.623      -0.138      -3.931    0.20%       0.039      1.236      1.649
             500.000       3.290      -0.253       5.979    0.20%       2.060      3.303
     Y6                    1.596      -0.104      -3.491    0.20%       0.040      1.122      1.588
             500.000       3.434      -0.338       6.396    0.20%       2.087      3.243
     X1                   -0.061      -0.070      -5.568    0.20%      -1.405     -0.513     -0.093
             500.000       2.921       0.161       4.844    0.20%       0.268      1.410
     X2                    1.033      -0.175      -4.642    0.20%      -0.089      0.776      1.082
             500.000       2.082       0.136       4.880    0.20%       1.424      2.167
     X3                    2.090       0.036      -0.597    0.20%       1.176      1.777      2.115
             500.000       1.042      -0.377       4.840    0.20%       2.374      3.002


THE MODEL ESTIMATION TERMINATED NORMALLY



MODEL FIT INFORMATION

Number of Free Parameters                       25

Loglikelihood

          H0 Value                       -4000.617
          H1 Value                       -3990.606

Information Criteria

          Akaike (AIC)                    8051.235
          Bayesian (BIC)                  8156.600
          Sample-Size Adjusted BIC        8077.248
            (n* = (n + 2) / 24)

Chi-Square Test of Model Fit

          Value                             20.023
          Degrees of Freedom                    20
          P-Value                           0.4565

RMSEA (Root Mean Square Error Of Approximation)

          Estimate                           0.002
          90 Percent C.I.                    0.000  0.038
          Probability RMSEA <= .05           0.994

CFI/TLI

          CFI                                1.000
          TLI                                1.000

Chi-Square Test of Model Fit for the Baseline Model

          Value                           4176.601
          Degrees of Freedom                    33
          P-Value                           0.0000

SRMR (Standardized Root Mean Square Residual)

          Value                              0.008



MODEL RESULTS

                                                    Two-Tailed
                    Estimate       S.E.  Est./S.E.    P-Value

 F1       BY
    Y1                 1.000      0.000    999.000    999.000
    Y2                 1.032      0.030     34.711      0.000
    Y3                 1.022      0.029     34.981      0.000

 F2       BY
    Y4                 1.000      0.000    999.000    999.000
    Y5                 0.973      0.026     38.093      0.000
    Y6                 0.977      0.027     35.735      0.000

 F1       ON
    X1                 0.497      0.026     18.964      0.000
    X2                 0.566      0.031     18.283      0.000
    X3                 0.691      0.043     15.968      0.000

 F2       ON
    X1                 0.678      0.026     25.863      0.000
    X2                 0.601      0.030     20.268      0.000
    X3                 0.432      0.040     10.711      0.000

 F2       WITH
    F1                 0.228      0.040      5.762      0.000

 Intercepts
    Y1                 0.068      0.108      0.633      0.527
    Y2                 0.025      0.110      0.227      0.820
    Y3                 0.046      0.109      0.421      0.674
    Y4                 0.179      0.101      1.774      0.076
    Y5                 0.180      0.096      1.873      0.061
    Y6                 0.147      0.099      1.488      0.137

 Residual Variances
    Y1                 0.529      0.046     11.496      0.000
    Y2                 0.512      0.046     11.064      0.000
    Y3                 0.477      0.044     10.789      0.000
    Y4                 0.541      0.046     11.655      0.000
    Y5                 0.399      0.038     10.485      0.000
    Y6                 0.522      0.045     11.659      0.000
    F1                 0.720      0.061     11.717      0.000
    F2                 0.643      0.056     11.471      0.000

MplusのDiagrammer

RのsemPlotパッケージよりこちらの方がキレイに出力される気がする。
何も手を入れていないが、いろいろと手が入れられるので、もう少しキレイな感じに仕上げることができる。

f:id:iDES:20200530014231p:plain

参考

sachaepskamp.com

https://personality-project.org/revelle/syllabi/454/454.wk9.pdf