(2)社会調査士のためのこれからの因子分析 で話が合わないなあと思ってよくよく見たら,
両方で,コマンドの入力順序で,分析対象のデータセットが違っている。
示されたように,
library(psych)
library(ltm)
library(mirt)
data(Science)
の順で入力すると,Science は
Comfort Work Future Benefit
1 4 4 3 2
2 3 3 3 3
3 3 2 2 3
4 3 2 2 3
5 3 4 4 1
6 4 4 3 3
になる。
しかし,著者は,(2)の方では,
> head(ltm::Science)
Comfort Environment Work Future Technology Industry Benefit
1 strongly agree strongly agree strongly agree agree strongly agree agree disagree
2 agree strongly agree agree agree agree agree agree
3 agree disagree disagree disagree strongly agree strongly agree agree
4 agree agree disagree disagree strongly agree strongly agree agree
5 agree strongly disagree strongly agree strongly agree disagree agree strongly disagree
6 strongly agree agree strongly agree agree agree strongly agree agree
を使用した結果を示している。
示された順でコンソール入力すると,library(mirt) の後に,
> 次のパッケージを付け加えます: '‘mirt’'
> The following object(s) are masked from ‘package:ltm’:
> Science
が出ている。つまり,mirt と ltm のローディングの順序で,実際に使われる Science の内容が異なるということである。
著者は,(1)の方で,以下のような矛盾に気づいていない(私も,さっき気づいたばかり)。
> サンプルデータはltmパッケージにあるScienceデータを使います。4件法で7つの項目があります。← 4つの項目しかない
> data(Science)
> summary(Science)
> ## Comfort Work Future Benefit
> ## Min. :1.00 Min. :1.00 Min. :1.00 Min. :1.00
> ## 1st Qu.:3.00 1st Qu.:2.00 1st Qu.:3.00 1st Qu.:2.00
> ## Median :3.00 Median :3.00 Median :3.00 Median :3.00
> ## Mean :3.12 Mean :2.72 Mean :2.99 Mean :2.84
> ## 3rd Qu.:3.00 3rd Qu.:3.00 3rd Qu.:3.00 3rd Qu.:3.00
> ## Max. :4.00 Max. :4.00 Max. :4.00 Max. :4.00
最初の方に,
> 途中,エラーが出たりRそのもののアウトプットと異なる場所がありますが,おそらくknitrあたりの問題で,実際はちゃんと結果が出てたりします。
と書いてあったのは,このことか???
このようなことを避けるためには,データの場合には,mirt::Science とか ltm::Science のようにちゃんと書き分けて,混乱が生じないようにする必要があるということだ。