![]() |
时尚的熊猫 · Stata编程技巧(3): ...· 2 周前 · |
![]() |
阳刚的火腿肠 · 如何在stata中将字符型数据库 | ...· 2 周前 · |
![]() |
纯真的柠檬 · Stata数值型变成字符型_千锋教育· 2 周前 · |
![]() |
一身肌肉的山楂 · Stata学习笔记|数据处理3-类型转化_学 ...· 2 周前 · |
![]() |
豪爽的灯泡 · 《Stata软件操作》——经济学拔尖基地举办 ...· 2 周前 · |
![]() |
越狱的刺猬 · 快穿主受文集百度云 - 百度· 8 月前 · |
![]() |
爱跑步的电池 · 盘点86版《西游记》已经去世的17位演员,他 ...· 1 年前 · |
![]() |
沉稳的茶壶 · random --- 生成伪随机数 — ...· 1 年前 · |
![]() |
健身的咖啡豆 · Fortran程序中直接使用度(°)计算三角 ...· 1 年前 · |
![]() |
不拘小节的香烟 · The process started ...· 1 年前 · |
【図・グラフ】
autoデータセットを使います。
rep78*foreignのクロス表では,0名のセルが発生するので,
単純にするためにrep78の3未満をdropしておきます。
--------------------------------------------------------------------
foreign | Odds Ratio Std. Err. z P>|z| [95% Conf. Interval]
--------+-----------------------------------------------------------
mpg | 1.160921 .0614601 2.82 0.005 1.0465 1.287852
_cons | .019403 .0235867 -3.24 0.001 .0017911 .2101887
--------------------------------------------------------------------
-------------------------
b
-------------------------
foreign
mpg .1492138
_cons -3.942329
-------------------------
--------------------------------------------------------------------
foreign | Coef. Std. Err. z P>|z| [95% Conf. Interval]
--------+-----------------------------------------------------------
mpg | .1492138 .0529408 2.82 0.005 .0454517 .2529758
_cons | -3.942329 1.215624 -3.24 0.001 -6.324908 -1.55975
--------------------------------------------------------------------
name | command depvar npar title
-------------+-----------------------------------------
est1 | logistic foreign 2
est2 | logistic foreign 3
est3 | logistic foreign 6
-------------------------------------------------------
est1 est2 est3
b b b
---------------------------------------------------
foreign
mpg .1492138 -.0900729 -.1824287
length -.0963129 -.1063041
3.rep78 0
4.rep78 2.405568
5.rep78 3.729435
_cons -3.942329 18.82339 21.00963
---------------------------------------------------
est1 est2 est3
b/ci95 b/ci95 b/ci95
---------------------------------------------------
foreign
mpg .1492138 -.0900729 -.1824287
.0454517,.2529758 -.2432507,.0631049 -.3959393,.0310819
length -.0963129 -.1063041
-.1529248,-.0397009 -.1725313,-.0400769
3.rep78 0
0,0
4.rep78 2.405568
.3872429,4.423893
5.rep78 3.729435
1.175191,6.283679
---------------------------------------------------
est1 est2 est3
b/ci95 b/ci95 b/ci95
----------------------------------------------------------
foreign
mpg 1.160921 .9138646 .8332441
1.0465,1.287852 .7840749,1.065139 .6730476,1.03157
length .9081798 .8991512
.8581942,.9610768 .8415319,.9607155
3.rep78 1
1,1
4.rep78 11.08472
1.472914,83.42037
5.rep78 41.65555
3.23876,535.756
---------------------------------------------------
est1 est2 est3
b/ci95 b/ci95 b/ci95
---------------------------------------------------
foreign
mpg 1.2 0.9 0.8
1.0,1.3 0.8,1.1 0.7,1.0
length 0.9 0.9
0.9,1.0 0.8,1.0
3.rep78 1.0
1.0,1.0
4.rep78 11.1
1.5,83.4
5.rep78 41.7
3.2,535.8
est1 est2 est3
b ci95 b ci95 b ci95
----------------------------------------------------------------
foreign
mpg 1.2 1.0,1.3 0.9 0.8,1.1 0.8 0.7,1.0
length 0.9 0.9,1.0 0.9 0.8,1.0
3.rep78 1.0 1.0,1.0
4.rep78 11.1 1.5,83.4
5.rep78 41.7 3.2,535.8
est1 est2 est3
b ci95 b ci95 b ci95
---------------------------------------------------------------
foreign
mpg 1.2 [1.0,1.3] 0.9 [0.8,1.1] 0.8 [0.7,1.0]
length 0.9 [0.9,1.0] 0.9 [0.8,1.0]
3.rep78 1.0 [1.0,1.0]
4.rep78 11.1 [1.5,83.4]
5.rep78 41.7 [3.2,535.8]
est1 est2 est3本記事の解説では,Stata 13.1を使います。
b ci95 b ci95 b ci95
---------------------------------------------------------------
foreign
mpg 1.2 (1.0,1.3) 0.9 (0.8,1.1) 0.8 (0.7,1.0)
length 0.9 (0.9,1.0) 0.9 (0.8,1.0)
3.rep78 1.0 (1.0,1.0)
4.rep78 11.1 (1.5,83.4)
5.rep78 41.7 (3.2,535.8)
----------------------------------------------------------------------------------------------------------------
bdi | Coef. Std. Err. z P>|z| [95% Conf. Interval]
----------------+----------------------------------------------------------------------------------------------
treatment |
BtheB | -4.755128 2.211978 -2.15 0.032 -9.090525 -.4197319
|
month |
3 | -1.606839 1.160547 -1.38 0.166 -3.88147 .667791
5 | -3.214118 1.259442 -2.55 0.011 -5.68258 -.7456561
8 | -5.94658 1.328405 -4.48 0.000 -8.550205 -3.342955
|
treatment#month |
BtheB#3 | .5951418 1.62632 0.37 0.714 -2.592386 3.78267
BtheB#5 | 1.335008 1.774927 0.75 0.452 -2.143785 4.8138
BtheB#8 | 3.325952 1.847011 1.80 0.072 -.2941233 6.946027
|
_cons | 19.46667 1.619558 12.02 0.000 16.29239 22.64094
--------------------------------------------------------------------------------------------------------------------
---------------------------------------------------------------------
| df chi2 P>chi2
----------------+-------------------------------------------
bdi |
treatment#month | 3 3.46 0.3266
---------------------------------------------------------------------
1.1533333
-- Binomial Exact --
Variable | Obs Proportion Std. Err. [95% Conf. Interval]
-------------+---------------------------------------------------
foreign | 30 .1 .0547723 .0211171 .2652885
scalars:
r(N) = 30
r(proportion) = .1
r(se) = .0547722557505166
r(lb) = .0211171370297225
r(ub) = .2652884504742086
r(level) = 95
macros:
r(citype) : "exact"
r(proportion) = .1
r(lb) = .0211171370297225
r(ub) = .2652884504742086
.1 .02111714 .26528845
3 .1 .02111714 .26528845
4 .5 .26019058 .73980942
5 .81818182 .48224415 .9771688
| rep78 propor~n lower upper |
|----------------------------------------|
1. | 3 10 2.111714 26.52884 |
2. | 4 50 26.01906 73.98094 |
3. | 5 81.81818 48.22441 97.71688 |
Car type | Freq. Percent Cum.
------------+-----------------------------------
Domestic | 42 65.63 65.63
Foreign | 22 34.38 100.00
------------+-----------------------------------
Total | 64 100.00
-- Binomial Exact --
Variable | Obs Proportion Std. Err. [95% Conf. Interval]
----------+-------------------------------------------------
foreign | 64 .34375 .0593699 .2294632 .473023
-> rep78 = 3
-- Binomial Exact --
Variable | Obs Proportion Std. Err. [95% Conf. Interval]
------------+---------------------------------------------------
foreign | 30 .1 .0547723 .0211171 .2652885
----------------------------------------------------------------
-> rep78 = 4
-- Binomial Exact --
Variable | Obs Proportion Std. Err. [95% Conf. Interval]
-----------+----------------------------------------------------
foreign | 18 .5 .1178511 .2601906 .7398094
-----------------------------------------------------------------
-> rep78 = 5
-- Binomial Exact --
Variable | Obs Proportion Std. Err. [95% Conf. Interval]
-----------+----------------------------------------------------
foreign | 11 .8181818 .1162913 .4822441 .9771688
-----------------------------------------------------------------
-> rep78 = .
-- Binomial Exact - Variable | Obs Proportion Std. Err. [95% Conf. Interval]
---------+----------------------------------------------------
foreign | 5 .2 .1788854 .0050508 .7164179
| drug length treatm~t bdi0 bdi2 bdi3 bdi5 bdi8 id |
|------------------------------------------------------------------|
1. | No >6m TAU 29 2 2 . . 1 |
2. | Yes >6m BtheB 32 16 24 17 20 2 |
3. | Yes <6m TAU 25 20 . . . 3 |
4. | No >6m BtheB 21 17 16 10 9 4 |
5. | Yes >6m BtheB 26 23 . . . 5 |
| drug length treatm~t bdi0 bdi2 bdi3 bdi5 bdi8 id |
|------------------------------------------------------------------|
1. | Yes >6m BtheB 32 16 24 17 20 2 |
2. | No >6m BtheB 21 17 16 10 9 4 |
3. | Yes <6m BtheB 7 0 0 0 0 6 |
4. | Yes <6m TAU 17 7 7 3 7 7 |
5. | No >6m TAU 20 20 21 19 13 8 |
treatment | Freq. Percent Cum.
------------+-----------------------------------
TAU | 25 48.08 48.08
BtheB | 27 51.92 100.00
------------+-----------------------------------
Total | 52 100.00
| id month drug length treatm~t bdi |
|---------------------------------------------|
1. | 2 0 Yes >6m BtheB 32 |
2. | 2 2 Yes >6m BtheB 16 |
3. | 2 3 Yes >6m BtheB 24 |
4. | 2 5 Yes >6m BtheB 17 |
5. | 2 8 Yes >6m BtheB 20 |
|---------------------------------------------|
6. | 4 0 No >6m BtheB 21 |
7. | 4 2 No >6m BtheB 17 |
8. | 4 3 No >6m BtheB 16 |
9. | 4 5 No >6m BtheB 10 |
10. | 4 8 No >6m BtheB 9 |
------------------------------------------------------------------------------
Random-effects Parameters | Estimate Std. Err. [95% Conf. Interval]
-----------------------------+------------------------------------------------
id: Unstructured |
var(post) | 61.8672 18.85135 34.04816 112.4158
var(_cons) | 54.45944 16.9922 29.54506 100.3833
cov(post,_cons) | -28.03576 15.18228 -57.79248 1.720963
-----------------------------+------------------------------------------------
var(Residual) | 24.56581 2.836617 19.59038 30.80488
------------------------------------------------------------------------------
LR test vs. linear model: chi2(3) = 131.47 Prob > chi2 = 0.0000
-----------------------------------------------------------------------------------
bdi | Coef. Std. Err. z P>|z| [95% Conf. Interval]
------------------+----------------------------------------------------------------
drug | 1.123422 2.027048 0.55 0.579 -2.849519 5.096363
length | 7.225293 1.988499 3.63 0.000 3.327907 11.12268
treatment | -1.816101 2.534019 -0.72 0.474 -6.782687 3.150485
|
month |
0 | 0 (base)
2 | 3.068148 4.676631 0.66 0.512 -6.097881 12.23418
3 | -.8933333 4.676631 -0.19 0.849 -10.05936 8.272696
5 | -3.881481 4.676631 -0.83 0.407 -13.04751 5.284547
8 | -7.891852 4.676631 -1.69 0.092 -17.05788 1.274177
|
month#c.treatment |
0 | 0 (base)
2 | -7.108148 2.924213 -2.43 0.015 -12.8395 -1.376796
3 | -5.386667 2.924213 -1.84 0.065 -11.11802 .3446852
5 | -4.318519 2.924213 -1.48 0.140 -10.04987 1.412833
8 | -2.628148 2.924213 -0.90 0.369 -8.3595 3.103204
|
_cons | 12.6037 5.643376 2.23 0.026 1.54289 23.66452
-----------------------------------------------------------------------------------
-------------------------------------------------------------------
| Contrast Std. Err. [95% Conf. Interval]
------------------+------------------------------------------------
bdi |
month#c.treatment |
(1) | -4.86037 2.670517 -10.09449 .3737474
-------------------------------------------------------------------
------------------------------------------------------------------------------
Random-effects Parameters | Estimate Std. Err. [95% Conf. Interval]
-----------------------------+------------------------------------------------
id: Unstructured |
var(post) | 61.8672 18.85135 34.04816 112.4158
var(_cons) | 54.45944 16.9922 29.54506 100.3833
cov(post,_cons) | -28.03576 15.18228 -57.79248 1.720962
-----------------------------+------------------------------------------------
var(Residual) | 24.56581 2.836617 19.59038 30.80488
------------------------------------------------------------------------------
bdi | Coef. Std. Err. z P>|z| [95% Conf. Interval]
----------------+----------------------------------------------------------------
drug | 1.123422 2.027048 0.55 0.579 -2.849519 5.096363
length | 7.225293 1.988499 3.63 0.000 3.327907 11.12268
|
treatment |
TAU | 0 (base)
BtheB | -1.816101 2.534019 -0.72 0.474 -6.782687 3.150485
|
month |
0 | 0 (base)
2 | -4.04 2.10712 -1.92 0.055 -8.169879 .0898786
3 | -6.28 2.10712 -2.98 0.003 -10.40988 -2.150121
5 | -8.2 2.10712 -3.89 0.000 -12.32988 -4.070121
8 | -10.52 2.10712 -4.99 0.000 -14.64988 -6.390121
|
treatment#month |
TAU#0 | 0 (base)
TAU#2 | 0 (base)
TAU#3 | 0 (base)
TAU#5 | 0 (base)
TAU#8 | 0 (base)
BtheB#0 | 0 (base)
BtheB#2 | -7.108148 2.924213 -2.43 0.015 -12.8395 -1.376796
BtheB#3 | -5.386667 2.924213 -1.84 0.065 -11.11802 .3446852
BtheB#5 | -4.318519 2.924213 -1.48 0.140 -10.04987 1.412833
BtheB#8 | -2.628148 2.924213 -0.90 0.369 -8.3595 3.103204
|
_cons | 10.7876 4.579099 2.36 0.018 1.812733 19.76247
---------------------------------------------------------------------------------
---------------------------------------------------
| df chi2 P>chi2
----------------+----------------------------------
bdi |
treatment#month | 1 3.31 0.0688
---------------------------------------------------
-----------------------------------------------------------------
| Contrast Std. Err. [95% Conf. Interval]
----------------+------------------------------------------------
bdi |
treatment#month |
(1) (1) | -4.86037 2.670517 -10.09449 .3737474
-----------------------------------------------------------------
-----------------------------------------------------------------
| Contrast Std. Err. [95% Conf. Interval]
----------------+------------------------------------------------
bdi |
treatment#month |
(1) (1) | -12.12037 1.851671 -15.74958 -8.491163
-----------------------------------------------------------------
-----------------------------------------------------------------
| Contrast Std. Err. [95% Conf. Interval]
----------------+------------------------------------------------
bdi |
treatment#month |
(1) (1) | -7.26 1.924313 -11.03158 -3.488417
-----------------------------------------------------------------
--------------------------------------------------------------------------------以前も以下の記事で紹介した
bdi | Coef. Std. Err. z P>|z| [95% Conf. Interval]
---------------+----------------------------------------------------------------
drug | 1.123413 2.027048 0.55 0.579 -2.849528 5.096354
length | 7.225293 1.988499 3.63 0.000 3.327906 11.12268
|
treatment |
TAU | 0 (base)
BtheB | -1.816098 2.534022 -0.72 0.474 -6.782689 3.150493
|
post |
0 | 0 (base)
1 | -7.26 1.924314 -3.77 0.000 -11.03159 -3.488413
|
treatment#post |
TAU#0 | 0 (base)
TAU#1 | 0 (base)
BtheB#0 | 0 (base)
BtheB#1 | -4.86037 2.67052 -1.82 0.069 -10.09449 .373752
|
_cons | 10.78761 4.5791 2.36 0.018 1.812743 19.76248
--------------------------------------------------------------------------------
Repair |
Record | Car type
1978 | Domestic Foreign | Total
-----------+----------------------+----------
1 | 2 0 | 2
2 | 8 0 | 8
3 | 27 3 | 30
4 | 9 9 | 18
5 | 2 9 | 11
-----------+----------------------+----------
Total | 48 21 | 69
| rep78 foreign mpg reppg |
1. | 3 Domestic 17 19 |
2. | 3 Domestic 20 19 |
(略)
26. | 3 Domestic 19 19 |
27. | 3 Domestic 14 19 |
28. | 3 Foreign 23 23.33333 |
29. | 3 Foreign 21 23.33333 |
30. | 3 Foreign 26 23.33333 |
|-----------------------------------|
31. | 4 Domestic 14 18.44444 |
32. | 4 Domestic 18 18.44444 |
33. | 4 Domestic 22 18.44444 |
34. | 4 Domestic 15 18.44444 |
35. | 4 Domestic 14 18.44444 |
|-----------------------------------|
36. | 4 Domestic 28 18.44444 |
37. | 4 Domestic 18 18.44444 |
38. | 4 Domestic 16 18.44444 |
39. | 4 Domestic 21 18.44444 |
40. | 4 Foreign 23 24.88889 |
|-----------------------------------|
41. | 4 Foreign 23 24.88889 |
42. | 4 Foreign 21 24.88889 |
43. | 4 Foreign 25 24.88889 |
44. | 4 Foreign 25 24.88889 |
45. | 4 Foreign 24 24.88889 |
|-----------------------------------|
46. | 4 Foreign 28 24.88889 |
47. | 4 Foreign 30 24.88889 |
48. | 4 Foreign 25 24.88889 |
49. | 5 Domestic 30 32 |
50. | 5 Domestic 34 32 |
|-----------------------------------|
51. | 5 Foreign 18 26.33333 |
52. | 5 Foreign 18 26.33333 |
(略)
| rep78 foreign mpg reppg |autoデータを使って,車の値段をアウトカム,生産国(国産 or 外国),
|-----------------------------------|
1. | 3 Domestic 17 19 |
28. | 3 Foreign 23 23.33333 |
31. | 4 Domestic 14 18.44444 |
40. | 4 Foreign 23 24.88889 |
49. | 5 Domestic 30 32 |
|-----------------------------------|
51. | 5 Foreign 18 26.33333 |
--------------------------------------------------------------------------
price| Coef. Std. Err. t P>|t| [95% Conf. Interval]
----------------+---------------------------------------------------------
foreign|
Foreign | -2171.597 2829.409 -0.77 0.445 -7814.676 3471.482
weight| 2.994814 .4163132 7.19 0.000 2.164503 3.825124
|
foreign#c.weight|
Foreign | 2.367227 1.121973 2.11 0.038 .129522 4.604931
|
_cons| -3861.719 1410.404 -2.74 0.008 -6674.681 -1048.757
--------------------------------------------------------------------------
Variable | Obs Mean Std. Dev. Min Max
-------------+--------------------------------------------------------
weight | 74 3019.459 777.1936 1760 4840
Adjusted predictions Number of obs = 74
Model VCE : OLS
Expression : Linear prediction, predict()
1._at : weight = 1760
2._at : weight = 2260
3._at : weight = 2760
4._at : weight = 3260
5._at : weight = 3760
6._at : weight = 4260
7._at : weight = 4760
-----------------------------------------------------------------------
| Delta-method
| Margin Std. Err. t P>|t| [95% Conf. Interval]
------------+----------------------------------------------------------
_at#foreign |
1#Domestic | 1409.153 708.814 1.99 0.051 -4.532181 2822.838
1#Foreign | 3403.875 727.8271 4.68 0.000 1952.27 4855.48
2#Domestic | 2906.56 525.2356 5.53 0.000 1859.01 3954.109
2#Foreign | 6084.895 444.5963 13.69 0.000 5198.176 6971.614
3#Domestic | 4403.966 368.7627 11.94 0.000 3668.492 5139.44
3#Foreign | 8765.915 639.0249 13.72 0.000 7491.42 10040.41
4#Domestic | 5901.373 287.6764 20.51 0.000 5327.621 6475.126
4#Foreign | 11446.94 1077.865 10.62 0.000 9297.201 13596.67
5#Domestic | 7398.78 340.8634 21.71 0.000 6718.949 8078.61
5#Foreign | 14127.96 1567.797 9.01 0.000 11001.08 17254.83
6#Domestic | 8896.187 486.0826 18.30 0.000 7926.726 9865.648
6#Foreign | 16808.98 2072.905 8.11 0.000 12674.7 20943.25
7#Domestic | 10393.59 665.5998 15.62 0.000 9066.097 11721.09
7#Foreign | 19490 2584.306 7.54 0.000 14335.76 24644.23
-----------------------------------------------------------------------
解析にはStata13.1を使います。
次のリンク先を参考にしました。
Stata FAQ How can I perform a factor analysis with categorical (or categorical and continuous) variables?
データセットはRのパッケージpsychのbfiデータを使います。
bfiデータについては
こちら参照
。
単純にするために,変数A1~A5のみで解析します。
まずは欠損値の確認です。
Obs<.
+------------------------------
| | Unique
Variable | Obs=. Obs>. Obs<. | values Min Max
---------+----------------------------+------------------------------
A1 | 16 2,784 | 6 1 6
A2 | 27 2,773 | 6 1 6
A3 | 26 2,774 | 6 1 6
A4 | 19 2,781 | 6 1 6
A5 | 16 2,784 | 6 1 6
---------------------------------------------------------------------
Obs=.の列を見ると,1変数につき16~27名で欠損値がみられることが
わかります。次にパターンをみます。
Missing-value patterns
(1 means complete)
| Pattern
Frequency | 1 2 3 4 5
------------+------------------
2,709 | 1 1 1 1 1
|
22 | 1 1 1 1 0
20 | 1 1 1 0 1
15 | 1 0 1 1 1
12 | 0 1 1 1 1
12 | 1 1 0 1 1
3 | 1 1 0 0 0
2 | 0 1 0 1 1
1 | 0 0 1 1 1
1 | 0 1 1 0 1
1 | 1 1 0 0 1
1 | 1 1 0 1 0
1 | 1 1 1 0 0
------------+------------------
2,800 |
Variables are (1) A1 (2) A5 (3) A4 (4) A3 (5) A2
表の中身の1行目にあるように,変数のすべてで1であるもの,
つまり欠損値のないケースは2,709名だとわかります。
次にピアソンの相関行列をだします。
(obs=2709)
| A1 A2 A3 A4 A5
-------------+---------------------------------------------
A1 | 1.0000
A2 | -0.3416 1.0000
A3 | -0.2683 0.4868 1.0000
A4 | -0.1484 0.3352 0.3622 1.0000
A5 | -0.1827 0.3878 0.5052 0.3067 1.0000
次はポリコリック相関です。そのままでは出ないので,
ユーザー作成コマンドのpolychoricをインストールする必要があります。
ネットにつながっている環境で
と打ち,インストールしたら次のようにかきます。
Polychoric correlation matrix
A1 A2 A3 A4 A5
A1 1
A2 -.40888172 1
A3 -.32566935 .5575669 1
A4 -.17597901 .38965116 .41069263 1
A5 -.22843963 .44653766 .57349574 .35401781 1
上記コマンドの実行で,様々な情報が生成されていて,
確認するには次のコマンドを打ちます。
scalars:
r(pLR0) = 6.15755687868e-62
r(LR0) = 275.8067214420807
r(pX2) = .0003008227338877
r(dfX2) = 24
r(X2) = 55.1282052450148
r(pG2) = .0012040446647921
r(dfG2) = 24
r(G2) = 50.55156075192645
r(se_rho) = .0201740996318403
r(rho) = .3540178066269911
r(N) = 2709
r(sum_w) = 2709
macros:
r(type) : "polychoric"
matrices:
r(R) : 5 x 5
これらの情報は一時的なので次の解析を行うと消えてしまいます。
解析に用いた人数など,個別の値だけを見たいときには,
以下のようにします。
※r(N)とr(sum_w)の違いはヘルプを見ても詳しく書いてなかったので,
不明です
そして,この情報を用いた次の3行がポリコリック相関行列を
用いた探索的因子分析です。3行をいっぺんに実行します。
Factor analysis/correlation Number of obs = 2709
Method: principal factors Retained factors = 1
Rotation: (unrotated) Number of params = 5
--------------------------------------------------------------------
Factor | Eigenvalue Difference Proportion Cumulative
-------------+------------------------------------------------------
Factor1 | 1.95127 1.85836 1.1904 1.1904
Factor2 | 0.09291 0.14472 0.0567 1.2470
Factor3 | -0.05181 0.12276 -0.0316 1.2154
Factor4 | -0.17457 0.00401 -0.1065 1.1089
Factor5 | -0.17858 . -0.1089 1.0000
-----------------------------------------------------------------------
LR test: independent vs. saturated: chi2(10) = 3390.61 Prob>chi2 = 0.0000
Factor loadings (pattern matrix) and unique variances
---------------------------------------
Variable | Factor1 | Uniqueness
-------------+----------+--------------
A1 | -0.4376 | 0.8085
A2 | 0.7078 | 0.4990
A3 | 0.7558 | 0.4287
A4 | 0.5154 | 0.7343
A5 | 0.6494 | 0.5782
---------------------------------------
コマンドの解説をすると,まずlocalマクロ変数でポリコリック相関行列算出により出てきた
人数r(sum_w)をNと定義しています。次にポリコリック相関行列r(R)をrと定義します。
そして,3行目が相関行列を用いた探索的因子分析です。
因子数は1に指定しています。factormatコマンドの後に相関行列rを置き,オプションで
相関行列を出すのに用いた人数Nをいれています。デフォルトでは主因子法*です。
次にピアソン相関行列を用いた探索的因子分析をしてみます。
先ほど出したので,相関行列の表示は省略することにし,先頭にquiをつけます。
scalars:
r(N) = 2709
r(rho) = -.3416241810153322
matrices:
r(C) : 5 x 5
今度は,格納されている結果の名前が少し違っています。
Factor analysis/correlation Number of obs= 2709
Method: principal factors Retained factors = 1
Rotation: (unrotated) Number of params = 5
---------------------------------------------------------------------
Factor Eigenvalue Difference Proportion Cumulative
-------------+-------------------------------------------------------
Factor1 1.66236 1.59574 1.2699 1.2699
Factor2 0.06662 0.13026 0.0509 1.3208
Factor3 -0.06364 0.10961 -0.0486 1.2722
Factor4 -0.17325 0.00978 -0.1323 1.1398
Factor5 -0.18303 . -0.1398 1.0000
----------------------------------------------------------------------
LR test: independent vs. saturated: chi2(10) = 2531.30 Prob>chi2 = 0.0000
Factor loadings (pattern matrix) and unique variances
---------------------------------------
Variable Factor1 Uniqueness
-------------+----------+--------------
A1 -0.3868 0.8504
A2 0.6509 0.5763
A3 0.7029 0.5059
A4 0.4813 0.7684
A5 0.6027 0.6367
---------------------------------------
大枠は同じですが,数値はかなり違ったようになってきます。
ちなみに,ピアソン相関行列で行った因子分析は,下記のように
基本の因子分析を行った場合と同じ結果になります。
*推定法について,清水裕士先生(
@simizu706
)の↓の
ツイート
ポリコリック相関行列をそのまま因子分析に適用するのは,あまりよくない。
標準誤差を重みづけた,重みづき最小二乗法(WLS)を用いて推定したほうがいい。
が気になるので,この辺についてもその内Stataでのやり方を調べてみるつもりです。
SEMではできるぽいので。
本記事の内容について,清水先生のブログ記事↓も参考になります
カテゴリカルデータの相関係数
相関係数を出すときに使うpwcorr,およびcorrelate(略してcor)は,
どちらも指定した変数群の相関行列を出してくれますが,欠損値の有無で
結果が違います。例えば,Rのパッケージpsychのbfiデータの
変数A1-A5で試してみます。bfiデータについては
こちら
参照
| A1 A2 A3 A4 A5
-------------+---------------------------------------------
A1 | 1.0000
A2 | -0.3402 1.0000
A3 | -0.2652 0.4851 1.0000
A4 | -0.1464 0.3351 0.3604 1.0000
A5 | -0.1814 0.3901 0.5041 0.3075 1.0000
(obs=2709)
| A1 A2 A3 A4 A5
-------------+---------------------------------------------
A1 | 1.0000
A2 | -0.3416 1.0000
A3 | -0.2683 0.4868 1.0000
A4 | -0.1484 0.3352 0.3622 1.0000
A5 | -0.1827 0.3878 0.5052 0.3067 1.0000
この違いは,単純に計算に使われた人数の違いです。
corの方は,欠損のあるケースをリストワイズするからです。
そうすると(obs=2709)になるということが結果にも出ています。
したがって,pwcorrをリストワイズで出すオプションをつけると,
| A1 A2 A3 A4 A5
-------------+---------------------------------------------
A1 | 1.0000
A2 | -0.3416 1.0000
A3 | -0.2683 0.4868 1.0000
A4 | -0.1484 0.3352 0.3622 1.0000
A5 | -0.1827 0.3878 0.5052 0.3067 1.0000
となり,corの結果と一致します。
pwcorrのデフォルトではどのように解析がされているか確認するには,obs
オプションをつけます
| A1 A2 A3 A4 A5
-------------+---------------------------------------------
A1 | 1.0000
| 2784
|
A2 | -0.3402 1.0000
| 2757 2773
|
A3 | -0.2652 0.4851 1.0000
| 2759 2751 2774
|
A4 | -0.1464 0.3351 0.3604 1.0000
| 2767 2758 2759 2781
|
A5 | -0.1814 0.3901 0.5041 0.3075 1.0000
| 2769 2757 2758 2765 2784
相関係数の下にそれぞれのペアの人数が出てきました
2
3
4
1+1=2
1+2=3
1+3=4
1+1=2
1+2=3
1+3=4
2+1=3
2+2=4
2+3=5
3+1=4
3+2=5
3+3=6
このコマンドは反復測定ANOVAに基づき,ICC[2,1], ICC[2,k], ICC[3,1],
and ICC[3,k]についてrandom effects modelsのICCを算出するものです。
icc23 <dv> <classvar> <within_var>
classvarとは,個人内で繰り返される因子であり,
例として評定者,機器, 測定ポイント などがある
within_varとは,"被験者内"変数であり,例として,
評定される個人のことを指す
The individual AA-ICC corresponds to ICC(A,1) in McGraw and Wong (1996a)
or ICC(2,1) in Shrout and Fleiss (1979). The average AA-ICC corresponds to
ICC(A,k) in McGraw and Wong (1996a) or ICC(2,k) in Shrout and Fleiss (1979).
+---------------+
| make |
|---------------|
1. | AMC Concord |
2. | AMC Pacer |
3. | AMC Spirit |
4. | Buick Century |
5. | Buick Electra |
+---------------+
+-------------+
| make |
|-------------|
1. | AMC Concord |
+-------------+
74
Repair |
Record 1978 | Freq. Percent Cum.
------------+-----------------------------------
1 | 2 2.70 2.70
2 | 8 10.81 13.51
3 | 30 40.54 54.05
4 | 18 24.32 78.38
5 | 11 14.86 93.24
. | 5 6.76 100.00
------------+-----------------------------------
Total | 74 100.00
+-----------------------------+以前, 層別に平均値と標準偏差(SD)と人数だけを算出 という記事で解説
| rep78 id_by_~p n_by_rep |
|-----------------------------|
1. | 1 1 2 |
2. | 1 2 2 |
|-----------------------------|
3. | 2 1 8 |
4. | 2 2 8 |
5. | 2 3 8 |
6. | 2 4 8 |
7. | 2 5 8 |
|-----------------------------|
11. | 3 1 30 |
12. | 3 2 30 |
13. | 3 3 30 |
14. | 3 4 30 |
15. | 3 5 30 |
|-----------------------------|
41. | 4 1 18 |
42. | 4 2 18 |
43. | 4 3 18 |
44. | 4 4 18 |
45. | 4 5 18 |
|-----------------------------|
59. | 5 1 11 |
60. | 5 2 11 |
61. | 5 3 11 |
62. | 5 4 11 |
63. | 5 5 11 |
|-----------------------------|
70. | . 1 5 |
71. | . 2 5 |
72. | . 3 5 |
73. | . 4 5 |
74. | . 5 5 |
+-----------------------------+
-> foreign = Domestic
Variable | Obs Mean Std. Dev. Min Max
------------+---------------------------------------------
price | 52 6072.423 3097.104 3291 15906
mpg | 52 19.82692 4.743297 12 34
weight | 52 3317.115 695.3637 1800 4840
length | 52 196.1346 20.04605 147 233
---------------------------------------------------------
-> foreign = Foreign
Variable | Obs Mean Std. Dev. Min Max
------------+---------------------------------------------
price | 22 6384.682 2621.915 3748 12990
mpg | 22 24.77273 6.611187 14 41
weight | 22 2315.909 433.0035 1760 3420
length | 22 168.5455 13.68255 142 193
-> foreign = Domestic, rep78 = 1
Variable | Obs Mean Std. Dev. Min Max
------------+---------------------------------------------
price | 2 4564.5 522.5519 4195 4934
mpg | 2 21 4.242641 18 24
weight | 2 3100 523.259 2730 3470
length | 2 189 12.72792 180 198
----------------------------------------------------------
-> foreign = Domestic, rep78 = 2
Variable | Obs Mean Std. Dev. Min Max
------------+---------------------------------------------
price | 8 5967.625 3579.357 3667 14500
mpg | 8 19.125 3.758324 14 24
weight | 8 3353.75 445.9961 2690 3900
length | 8 199.375 13.97894 179 220
Summary statistics: mean
by categories of: foreign (Car type)
foreign | price mpg weight length
---------+----------------------------------------
Domestic | 6072.423 19.82692 3317.115 196.1346
Foreign | 6384.682 24.77273 2315.909 168.5455
---------+----------------------------------------
Total | 6165.257 21.2973 3019.459 187.9324
--------------------------------------------------
Summary statistics: mean
by categories of: foreign (Car type)
foreign | price mpg weight length
---------+----------------------------------------
Domestic | 6072.423 19.82692 3317.115 196.1346
Foreign | 6384.682 24.77273 2315.909 168.5455
--------------------------------------------------
foreign | mean
---------+----------
Domestic | 6072.423
| 19.82692
| 3317.115
| 196.1346
---------+----------
Foreign | 6384.682
| 24.77273
| 2315.909
| 168.5455
--------------------
foreign | mean
---------+----------
Domestic | 6072.423
| 19.82692
| 3317.115
| 196.1346
Foreign | 6384.682
| 24.77273
| 2315.909
| 168.5455
--------------------
foreign | mean N
---------+--------------------
Domestic | 6072.423 52
| 19.82692 52
| 3317.115 52
| 196.1346 52
Foreign | 6384.682 22
| 24.77273 22
| 2315.909 22
| 168.5455 22
------------------------------
foreign variable | mean
----------------------+----------
Domestic price | 6072.423
mpg | 19.82692
weight | 3317.115
length | 196.1346
Foreign price | 6384.682
mpg | 24.77273
weight | 2315.909
length | 168.5455
---------------------------------
-> foreign = Domestic
rep78 variable | mean
----------------------+----------
1 price | 4564.5
mpg | 21
weight | 3100
length | 189
2 price | 5967.625
mpg | 19.125
weight | 3353.75
length | 199.375
3 price | 6607.074
mpg | 19
weight | 3442.222
length | 197.8889
4 price | 5881.556
mpg | 18.44444
weight | 3532.222
length | 204.4444
5 price | 4204.5
mpg | 32
weight | 1960
length | 160
---------------------------------
-------------------------------------------------
-> foreign = Foreign
rep78 variable | mean
----------------------+----------
3 price | 4828.667
mpg | 23.33333
weight | 2010
length | 159
4 price | 6261.444
mpg | 24.88889
weight | 2207.778
length | 165.2222
5 price | 6292.667
mpg | 26.33333
weight | 2403.333
length | 172.4444
---------------------------------
------------------------------たとえば,100個の変数について性別とのクロス表をいっぺんに出したいという
Repair |
Record | Car type
1978 | Domestic Foreign
----------+-------------------
1 | 4,564.5
| 21
| 3,100
| 189
|
2 | 5,967.6
| 19.125
| 3,353.8
| 199.375
|
3 | 6,607.1 4,828.7
| 19 23.3333
| 3,442.2 2,010
| 197.889 159
|
4 | 5,881.6 6,261.4
| 18.4444 24.8889
| 3,532.2 2,207.8
| 204.444 165.222
|
5 | 4,204.5 6,292.7
| 32 26.3333
| 1,960 2,403.3
| 160 172.444
------------------------------
+--------------------------------------------------+
| moji |
|--------------------------------------------------|
1. | あいう(全角10字) |
2. | あいうえおかきく(全角15字) |
3. | あいうえおかきくけこさしす(全角20字) |
4. | あいうえおかきくけこさしすせたちつ(全角20字) |
5. | あいう(全角10字) |
|--------------------------------------------------|
6. | あいう(全角10字) |
7. | あいう(全角10字) |
8. | あいうえおかきく(全角15字) |
9. | あいうえおかきく(全角15字) |
10. | あいうえおかきくけこさしす(全角20字) |
|--------------------------------------------------|
11. | . |
12. | . |
+--------------------------------------------------+
moji | Freq. Percent Cum.
----------------------------------------+-----------------------------------
. | 2 16.67 16.67
あいう(全角10字) | 4 33.33 50.00
あいうえおかきく(全角15字) | 3 25.00 75.00
あいうえおかきくけこさしす(全角2 0 ・. | 2 16.67 91.67
あいうえおかきくけこさしすせそたち つ ・. | 1 8.33 100.00
----------------------------------------+-----------------------------------
Total | 12 100.00
-----------------------------------------------------
moji | Freq.
-----------------------------------------+-----------
. | 2
あいう(全角10字) | 4
あいうえおかきく(全角15字) | 3
あいうえおかきくけこさしす(全角20字) | 2
あいうえおかきくけこさしすせそたちつ( 全 | 1
-----------------------------------------------------
+----------------------------------------------------+
| moji |
|----------------------------------------------------|
1. | あいう(全角10字) |
2. | あいうえおかきく(全角15字) |
3. | あいうえおかきくけこさしす(全角20字) |
4. | あいうえおかきくけこさしすせそたちつ(全角25字) |
5. | . |
+----------------------------------------------------+
+-------------------------+
| h1 m1 h2 m2 |
|---------------------------|
1. | 9 0 17 30 |
2. | 9 0 17 0 |
3. | 9 0 26 0 |
+-------------------------+
+-------------------------------------------------------------------+
| h1 m1 h2 m2 in_min out_min difmin |
|-------------------------------------------------------------------|
1. | 9 0 17 30 540 1050 510 |
2. | 9 0 17 0 540 1020 480 |
3. | 9 0 26 0 540 1560 1020 |
+------------------------------------------------------------------+
Variable | Obs Mean Std. Dev. Min Max
----------------+-------------------------------------------------------------------------
difmin | 3 670 303.4798 480 1020
Variable | Obs Mean Std. Dev. Min Max
----------------+-----------------------------------------------------------------------
mpg | 74 21.2973 5.785503 12 41
Car type | Freq. Percent Cum.
----------------+-----------------------------------
Domestic | 52 70.27 70.27
Foreign | 22 29.73 100.00
----------------+-----------------------------------
Total | 74 100.00
Car type | Freq. Percent Cum.
---------------+-----------------------------------
0 | 52 70.27 70.27
1 | 22 29.73 100.00
---------------+-----------------------------------
Total | 74 100.00
Block 1: price
---------------------------------------------------------------------------------------------------------
mpg | Coef. Std. Err. t P>|t| [95% Conf. Interval]
-------------+-----------------------------------------------------------------------------------------
price | -.0009192 .0002042 -4.50 0.000 -.0013263 -.0005121
_cons | 26.96417 1.393952 19.34 0.000 24.18538 29.74297
---------------------------------------------------------------------------------------------------------
Block 2: foreign weight
----------------------------------------------------------------------------------------------------
mpg | Coef. Std. Err. t P>|t| [95% Conf. Interval]
-------------+--------------------------------------------------------------------------------------
price | .0000566 .0001922 0.29 0.769 -.0003268 .00044
foreign | -1.855891 1.289063 -1.44 0.154 -4.426846 .7150641
weight | -.0067758 .0009048 -7.49 0.000 -.0085805 -.0049712
_cons | 41.95948 2.377726 17.65 0.000 37.21725 46.7017
------------------------------------------------------------------------------------------------------
Block 3: length
--------------------------------------------------------------------------------------------------------
mpg | Coef. Std. Err. t P>|t| [95% Conf. Interval]
-------------+----------------------------------------------------------------------------------------
price | -.0000374 .0002009 -0.19 0.853 -.0004381 .0003634
foreign | -1.574443 1.292234 -1.22 0.227 -4.15238 1.003494
weight | -.0041499 .0019865 -2.09 0.040 -.0081128 -.0001871
length | -.086156 .058149 -1.48 0.143 -.2021601 .029848
_cons | 50.71772 6.364007 7.97 0.000 38.02187 63.41357
------------------------------------------------------------------------------------------------------
+--------------------------------------------------------------------------------+
| | Block Residual Change |
| Block | F df df Pr > F R2 in R2 |
|----------+----------------------------------------------------------------------|
| 1 | 20.26 1 72 0.0000 0.2196 |
| 2 | 46.08 2 70 0.0000 0.6631 0.4435 |
| 3 | 2.20 1 69 0.1430 0.6735 0.0104 |
+--------------------------------------------------------------------------------+
25 Personality items representing 5 factors
5因子を表すパーソナリティに関する25項目
Variable | Obs Mean Std. Dev. Min Max
--------------+------------------------------------------------------------------------
A1 | 2784 2.413434 1.407737 1 6
A2 | 2773 4.80238 1.17202 1 6
A3 | 2774 4.603821 1.301834 1 6
A4 | 2781 4.699748 1.479633 1 6
A5 | 2784 4.560345 1.258512 1 6
-------------+--------------------------------------------------------
C1 | 2779 4.502339 1.241347 1 6
C2 | 2776 4.369957 1.318347 1 6
C3 | 2780 4.303957 1.288552 1 6
C4 | 2774 2.553353 1.375118 1 6
C5 | 2784 3.296695 1.628542 1 6
-------------+-------------------------------------------------------------------------
----------------------------------------------------------------------------
Fit statistic | Value Description
-------------------------------+------------------------------------------------------
Likelihood ratio |
chi2_ms(265) | 4165.467 model vs. saturated
p > chi2 | 0.000
chi2_bs(300) | 18222.116 baseline vs. saturated
p > chi2 | 0.000
-------------------------------+------------------------------------------------------
Population error |
RMSEA | 0.078 Root mean squared error of approximation
90% CI, lower bound | 0.076
upper bound | 0.080
pclose | 0.000 Probability RMSEA <= 0.05
-------------------------------+------------------------------------------------------
Information criteria |
AIC | 199850.476 Akaike's information criterion
BIC | 200343.316 Bayesian information criterion
-------------------------------+------------------------------------------------------
Baseline comparison |
CFI | 0.782 Comparative fit index
TLI | 0.754 Tucker-Lewis index
-------------------------------+------------------------------------------------------
Size of residuals |
SRMR | 0.073 Standardized root mean squared residual
CD | 0.999 Coefficient of determination
-----------------------------------------------------------------------------------------
-----------------------------------------------------------------------------------------------------
price | Coef. Std. Err. t P>|t| [95% Conf. Interval]
-----------------+-----------------------------------------------------------------------------------
weight | 2.994814 .4163132 7.19 0.000 2.164503 3.825124
|
foreign |
Foreign | -2171.597 2829.409 -0.77 0.445 -7814.676 3471.482
|
foreign#c.weight |
Foreign | 2.367227 1.121973 2.11 0.038 .129522 4.604931
|
_cons | -3861.719 1410.404 -2.74 0.008 -6674.681 -1048.757
-----------------------------------------------------------------------------------------------------
Variable | Obs Mean Std. Dev. Min Max
----------------+------------------------------------------------------------------------
weight | 74 3019.459 777.1936 1760 4840
Adjusted predictions Number of obs = 74
Model VCE : OLS
Expression : Linear prediction, predict()
1._at : weight = 1760
2._at : weight = 2260
3._at : weight = 2760
4._at : weight = 3260
5._at : weight = 3760
6._at : weight = 4260
7._at : weight = 4760
----------------------------------------------------------------------------------------------------
Delta-method
| Margin Std. Err. t P>|t| [95% Conf. Interval]
-------------------+--------------------------------------------------------------------------------------
_at#foreign |
1#Domestic | 1409.153 708.814 1.99 0.051 -4.532181 2822.838
1#Foreign | 3403.875 727.8271 4.68 0.000 1952.27 4855.48
2#Domestic | 2906.56 525.2356 5.53 0.000 1859.01 3954.109
2#Foreign | 6084.895 444.5963 13.69 0.000 5198.176 6971.614
3#Domestic | 4403.966 368.7627 11.94 0.000 3668.492 5139.44
3#Foreign | 8765.915 639.0249 13.72 0.000 7491.42 10040.41
4#Domestic | 5901.373 287.6764 20.51 0.000 5327.621 6475.126
4#Foreign | 11446.94 1077.865 10.62 0.000 9297.201 13596.67
5#Domestic | 7398.78 340.8634 21.71 0.000 6718.949 8078.61
5#Foreign | 14127.96 1567.797 9.01 0.000 11001.08 17254.83
6#Domestic | 8896.187 486.0826 18.30 0.000 7926.726 9865.648
6#Foreign | 16808.98 2072.905 8.11 0.000 12674.7 20943.25
7#Domestic | 10393.59 665.5998 15.62 0.000 9066.097 11721.09
7#Foreign | 19490 2584.306 7.54 0.000 14335.76 24644.23
----------------------------------------------------------------------------------------------------
SASではleast squares means (lsmeans)とよばれ,
SPSSでは estimated marginal means (emmeans) とよばれる
----------------------------------------------------------------------------------------------------------
| Delta-method
| Margin Std. Err. z P>|z| [95% Conf. Interval]
--------------------+------------------------------------------------------------------------------------
treatment#month |
TAU#2 | 19.46667 1.619558 12.02 0.000 16.29239 22.64094
TAU#3 | 17.85983 1.693887 10.54 0.000 14.53987 21.17978
TAU#5 | 16.25255 1.763116 9.22 0.000 12.7969 19.70819
TAU#8 | 13.52009 1.81302 7.46 0.000 9.966633 17.07354
BtheB#2 | 14.71154 1.506611 9.76 0.000 11.75864 17.66444
BtheB#3 | 13.69984 1.617249 8.47 0.000 10.53009 16.86959
BtheB#5 | 12.83243 1.697532 7.56 0.000 9.505326 16.15953
BtheB#8 | 12.09091 1.721696 7.02 0.000 8.716448 15.46537
---------------------------------------------------------------------------------
Repair |
Record | rep78r
1978 | 0 1 | Total
------------+-----------------------+----------
1 | 0 2 | 2
2 | 8 0 | 8
3 | 0 30 | 30
4 | 18 0 | 18
5 | 0 11 | 11
------------+------------------------+----------
Total | 26 43 | 69
Repair |
Record | rep78r2
1978 | 0 1 | Total
--------------+-----------------------+----------
1 | 0 2 | 2
2 | 8 0 | 8
3 | 0 30 | 30
4 | 18 0 | 18
5 | 0 11 | 11
--------------+-----------------------+----------
Total | 26 43 | 69
"Honda Accord"
"Honda Civic"
"Mazda GLC"
"Subaru"
"Toyota Celica"
"Toyota Corolla"
"Toyota Corona"
mpg weight
mpg 1.0000
weight -0.8072 1.0000
Confidence interval for Pearson's product-moment correlation
of mpg and weight, based on Fisher's transformation.
Correlation = -0.807 on 74 observations (95% CI: -0.874 to -0.710)
| Summary of Mileage (mpg)
Car type | Mean Std. Dev. Freq.
-----------------+-------------------------------------------------
Domestic | 19.826923 4.7432972 52
Foreign | 24.772727 6.6111869 22
-----------------+-------------------------------------------------
Total | 21.297297 5.7855032 74
-------------------------------------------------------------------
Car type | mean(mpg) sd(mpg) N(mpg)
---------------+--------------------------------------------------
Domestic | 19.8269 4.743297 52
Foreign | 24.7727 6.611187 22
---------------------------------------------------------------------
Summary for variables: mpg
by categories of: foreign (Car type)
foreign | mean sd N
--------------+-------------------------------------------
Domestic | 19.82692 4.743297 52
Foreign | 24.77273 6.611187 22
--------------+------------------------------------------
Total | 21.2973 5.785503 74
----------------------------------------
Summary statistics: mean, sd, N
by categories of: foreign (Car type)
foreign | mpg price weight length
--------------+-----------------------------------------------------------
Domestic | 19.82692 6072.423 3317.115 196.1346
| 4.743297 3097.104 695.3637 20.04605
| 52 52 52 52
--------------+--------------------------------------------------------------
Foreign | 24.77273 6384.682 2315.909 168.5455
| 6.611187 2621.915 433.0035 13.68255
| 22 22 22 22
--------------+----------------------------------------
Total | 21.2973 6165.257 3019.459 187.9324
| 5.785503 2949.496 777.1936 22.26634
| 74 74 74 74
--------------------------------------------------------------------------------
| Summary of Mileage (mpg)
Car type | Mean Std. Dev. Freq.
-----------------+------------------------------------------------
Domestic | 19.826923 4.7432972 52
Foreign | 24.772727 6.6111869 22
-----------------+------------------------------------------------
Total | 21.297297 5.7855032 74
| Summary of Price
Car type | Mean Std. Dev. Freq.
-----------------+------------------------------------
Domestic | 6,072.423 3,097.104 52
Foreign | 6,384.682 2,621.915 22
-----------------+------------------------------------
Total | 6,165.257 2,949.496 74
| Summary of Weight (lbs.)
Car type | Mean Std. Dev. Freq.
-----------------+------------------------------------------------
Domestic | 3,317.115 695.36374 52
Foreign | 2,315.909 433.00345 22
-----------------+------------------------------------------------
Total | 3,019.459 777.19357 74
| Summary of Length (in.)
Car type | Mean Std. Dev. Freq.
-----------------+-------------------------------------------------
Domestic | 196.13462 20.046054 52
Foreign | 168.54545 13.682548 22
-----------------+-------------------------------------------------
Total | 187.93243 22.26634 74
--------------------------------------------------
Car type | mean(mpg) sd(mpg)
---------------+-----------------------------------
Domestic | 19.8269 4.743297
Foreign | 24.7727 6.611187
----------------------------------------------------
-------------------------------------------------
Car type | mean(price) sd(price)
---------------+----------------------------------
Domestic | 6,072.4 3097.104
Foreign | 6,384.7 2621.915
---------------------------------------------------
-------------------------------------------------------
Car type | mean(weight) sd(weight)
---------------+--------------------------------------
Domestic | 3,317.1 695.3638
Foreign | 2,315.9 433.0034
-----------------------------------------------------
---------------------------------------------------
Car type | mean(length) sd(length)
---------------+------------------------------------
Domestic | 196.135 20.04605
Foreign | 168.545 13.68255
-----------------------------------------------------
+----------------------------------------------------------------------------+
| id month drug length treatm~t bdi_pre bdi bdin |
|------------------------------------------------------------------------------|
1. | 1 2 No >6m TAU 29 2 2 |
2. | 1 3 No >6m TAU 29 2 2 |
3. | 1 5 No >6m TAU 29 . 2 |
4. | 1 8 No >6m TAU 29 . 2 |
|------------------------------------------------------------------------------|
5. | 2 2 Yes >6m BtheB 32 16 16 |
6. | 2 3 Yes >6m BtheB 32 24 24 |
7. | 2 5 Yes >6m BtheB 32 17 17 |
8. | 2 8 Yes >6m BtheB 32 20 20 |
|------------------------------------------------------------------------------|
9. | 3 2 Yes <6m TAU 25 20 20 |
10. | 3 3 Yes <6m TAU 25 . 20 |
11. | 3 5 Yes <6m TAU 25 . 20 |
12. | 3 8 Yes <6m TAU 25 . 20 |
|------------------------------------------------------------------------------|
13. | 4 2 No >6m BtheB 21 17 17 |
14. | 4 3 No >6m BtheB 21 16 16 |
15. | 4 5 No >6m BtheB 21 10 10 |
16. | 4 8 No >6m BtheB 21 9 9 |
|------------------------------------------------------------------------------|
17. | 5 2 Yes >6m BtheB 26 23 23 |
18. | 5 3 Yes >6m BtheB 26 . 23 |
19. | 5 5 Yes >6m BtheB 26 . 23 |
20. | 5 8 Yes >6m BtheB 26 . 23 |
+-----------------------------------------------------------------------------+
Obs<.
+-------------------------
| | Unique
Variable | Obs=. Obs>. Obs<. | values Min Max
------------+-------------------------------------+-------------------------
bdi2 | 3 97 | 37 0 48
bdi3 | 27 73 | 33 0 53
bdi5 | 42 58 | 33 0 47
bdi8 | 48 52 | 24 0 40
----------------------------------------------------------------------------
Missing-value patterns
(1 means complete)
| Pattern
Frequency | 1 2 3 4
-----------------+-------------
52 | 1 1 1 1
|
24 | 1 0 0 0
15 | 1 1 0 0
6 | 1 1 1 0
3 | 0 0 0 0
-----------------+-------------
100 |
Variables are (1) bdi2 (2) bdi3 (3) bdi5 (4) bdi8
id bdi2 bdi3 bdi5 bdi8 drug length treatm~t bdi_pre
------------------------------------------------------------
1. 1 2 2 . . No >6m TAU 29
2. 2 16 24 17 20 Yes >6m BtheB 32
3. 3 20 . . . Yes <6m TAU 25
4. 4 17 16 10 9 No >6m BtheB 21
5. 5 23 . . . Yes >6m BtheB 26
------------------------------------------------------------
6. 6 0 0 0 0 Yes <6m BtheB 7
7. 7 7 7 3 7 Yes <6m TAU 17
8. 8 20 21 19 13 No >6m TAU 20
9. 9 13 14 20 11 Yes <6m BtheB 18
10. 10 5 5 8 12 Yes >6m BtheB 20
+------------------------------------------------------------+
+----------------------------------------------------
id month bdi drug length treatm~t bdi_pre
-----------------------------------------------------
1. 1 2 2 No >6m TAU 29
2. 1 3 2 No >6m TAU 29
3. 1 5 . No >6m TAU 29
4. 1 8 . No >6m TAU 29
5. 2 2 16 Yes >6m BtheB 32
-----------------------------------------------------
6. 2 3 24 Yes >6m BtheB 32
7. 2 5 17 Yes >6m BtheB 32
8. 2 8 20 Yes >6m BtheB 32
9. 3 2 20 Yes <6m TAU 25
10. 3 3 . Yes <6m TAU 25
+----------------------------------------------------
m p
-> foreign = Domestic
Variable | Obs Mean Std. Dev. Min Max
-------------+---------------------------------------------------
mpg | 52 19.82692 4.743297 12 34
------------------------
-> foreign = Foreign
Variable | Obs Mean Std. Dev. Min Max
-------------+---------------------------------------------------
mpg | 22 24.77273 6.611187 14 41
+--------------------------------------------+
make foreign mpg mpg2
--------------------------------------------
1. Merc. Zephyr Domestic 20 19.82692
2. Chev. Chevette Domestic 29 19.82692
3. Chev. Monza Domestic 24 19.82692
4. Toyota Corolla Foreign 31 24.77273
5. Subaru Foreign 35 24.77273
--------------------------------------------
6. AMC Spirit Domestic 22 19.82692
7. Merc. Bobcat Domestic 22 19.82692
8. Renault Le Car Foreign 26 24.77273
9. Chev. Nova Domestic 19 19.82692
10. Dodge Colt Domestic 30 19.82692
+--------------------------------------------+
Repair |
Record | Car type
1978 | Domestic Foreign | Total
-----------+------------------------------+----------
1 | 2 0 | 2
| 100.00 0.00 | 100.00
-----------+--------------------------------+----------
2 | 8 0 | 8
| 100.00 0.00 | 100.00
-----------+--------------------------------+----------
3 | 27 3 | 30
| 90.00 10.00 | 100.00
-----------+--------------------------------+----------
4 | 9 9 | 18
| 50.00 50.00 | 100.00
-----------+--------------------------------+----------
5 | 2 9 | 11
| 18.18 81.82 | 100.00
-----------+---------------------------------+----------
Total | 48 21 | 69
| 69.57 30.43 | 100.00
+----------------------------------+
make rep78 foreignp
----------------------------------
1. AMC Concord 3 .1
2. AMC Pacer 3 .1
3. AMC Spirit . .2
4. Audi 5000 5 .8181818
5. Audi Fox 3 .1
----------------------------------
6. BMW 320i 4 .5
7. Buick Century 3 .1
8. Buick Electra 4 .5
9. Buick LeSabre 3 .1
10. Buick Opel . .2
+----------------------------------+
+----------------------------------+
make rep78 foreignp
----------------------------------
1. AMC Concord 3 10
2. AMC Pacer 3 10
3. AMC Spirit . 20
4. Audi 5000 5 81.81818
5. Audi Fox 3 10
----------------------------------
6. BMW 320i 4 50
7. Buick Century 3 10
8. Buick Electra 4 50
9. Buick LeSabre 3 10
10. Buick Opel . 20
+----------------------------------+
| foreign price mpg weight
-------------+------------------------------------
foreign | 1.0000
price | 0.0487 1.0000
mpg | 0.3934 -0.4686 1.0000
weight | -0.5928 0.5386 -0.8072 1.0000
---------------------------------------------------------
Effect Size | Estimate [95% Conf. Interval]
--------------------+------------------------------------
Point-Biserial r | -.0487195 -.2693882 .1795464
---------------------------------------------------------
---------------------------------------------------------
Effect Size | Estimate [95% Conf. Interval]
--------------------+------------------------------------
Point-Biserial r | -.3933974 -.555367 -.1821459
---------------------------------------------------------
---------------------------------------------------------
Effect Size | Estimate [95% Conf. Interval]
--------------------+------------------------------------
Point-Biserial r | .5928299 .4281699 .7051208
---------------------------------------------------------
Number of obs = 150 R-squared = 0.9414
Root MSE = .430334 Adj R-squared = 0.9406
Source | Partial SS df MS F Prob > F
-----------+----------------------------------------------------
Model | 437.102798 2 218.551399 1180.16 0.0000
|
nspecies | 437.102798 2 218.551399 1180.16 0.0000
|
Residual | 27.2225992 147 .18518775
-----------+----------------------------------------------------
Total | 464.325397 149 3.11627783
R-squared = 0.9414
Adj R-squared = 0.9406
Effect sizes for linear models
-------------------------------------------------------------------
Source | Eta-Squared df [95% Conf. Interval]
--------------------+----------------------------------------------
Model | .9413717 2 .9239033 .9518341
|
nspecies | .9413717 2 .9239033 .9518341
-------------------------------------------------------------------
Effect sizes for linear models
-------------------------------------------------------------------
Source | Omega-Squared df [95% Conf. Interval]
--------------------+----------------------------------------------
Model | .9405741 2 .9228679 .9511788
|
nspecies | .9405741 2 .9228679 .9511788
-------------------------------------------------------------------
Source | SS df MS Number of obs = 150
-------------+------------------------------ F( 2, 147) = 1180.16
Model | 437.102798 2 218.551399 Prob > F = 0.0000
Residual | 27.2225992 147 .18518775 R-squared = 0.9414
-------------+------------------------------ Adj R-squared = 0.9406
Total | 464.325397 149 3.11627783 Root MSE = .43033
------------------------------------------------------------------------------
petallength | Coef. Std. Err. t P>|t| [95% Conf. Interval]
-------------+----------------------------------------------------------------
nspecies |
versicolor | 2.798 .0860669 32.51 0.000 2.627912 2.968088
virginica | 4.09 .0860669 47.52 0.000 3.919912 4.260088
|
_cons | 1.462 .0608585 24.02 0.000 1.341729 1.582271
------------------------------------------------------------------------------
low Odds Ratio Std. Err. z P>z [95% Conf. Interval]
race
black 2.327536 1.078613 1.82 0.068 .9385072 5.772385
other 1.889234 .6571342 1.83 0.067 .9554577 3.735597
_cons .3150685 .0753382 -4.83 0.000 .1971825 .503433
+-----------------------------------+
| 1b. 2. 3. |
| race race race race |
|-------------------------------------|
1. | black 0 1 0 |
2. | other 0 0 1 |
3. | white 0 0 0 |
4. | white 0 0 0 |
5. | white 0 0 0 |
+-----------------------------------+
low Odds Ratio Std. Err. z P>z [95% Conf. Interval]
race
white 1 (base)
black 2.327536 1.078613 1.82 0.068 .9385072 5.772385
other 1.889234 .6571342 1.83 0.067 .9554577 3.735597
_cons .3150685 .0753382 -4.83 0.000 .1971825 .503433
low Odds Ratio Std. Err. z P>z [95% Conf. Interval]
race
1 1 (base)
2 2.327536 1.078613 1.82 0.068 .9385072 5.772385
3 1.889234 .6571342 1.83 0.067 .9554577 3.735597
_cons .3150685 .0753382 -4.83 0.000 .1971825 .503433
( 1) [low]2.race = 0
( 2) [low]3.race = 0
chi2( 2) = 4.92
Prob > chi2 = 0.0853
Contrasts of marginal linear predictions
Margins : asbalanced
------------------------------------------------
| df chi2 P>chi2
-------------+----------------------------------
race | 2 4.92 0.0853
------------------------------------------------
low Odds Ratio Std. Err. z P>z [95% Conf. Interval]
smoke
smoker 2.021944 .6462989 2.20 0.028 1.08066 3.783112
_cons .3372093 .0724103 -5.06 0.000 .2213694 .5136667
-> race = white
low Odds Ratio Std. Err. z P>z [95% Conf. Interval]
smoke
smoker 5.757576 3.444621 2.93 0.003 1.782321 18.59916
_cons .1 .0524404 -4.39 0.000 .0357788 .2794949
2013/12/25 こまごま修正と追記
-> race = black
low Odds Ratio Std. Err. z P>z [95% Conf. Interval]
smoke
smoker 3.3 2.775878 1.42 0.156 .6346062 17.16025
_cons .4545455 .2451636 -1.46 0.144 .1579332 1.308222
-> race = other
low Odds Ratio Std. Err. z P>z [95% Conf. Interval]
smoke
smoker 1.25 .8114691 0.34 0.731 .350212 4.461584
_cons .5714286 .1601748 -2.00 0.046 .3298869 .9898259
Source | SS df MS Number of obs = 74
----------+---------------------------------- F( 2, 71) = 69.75
Model | 1619.2877 2 809.643849 Prob > F = 0.0000
Residual | 824.171761 71 11.608053 R-squared = 0.6627
----------+------------------------------ Adj R-squared = 0.6532
Total | 2443.45946 73 33.4720474 Root MSE = 3.4071
---------------------------------------------------------------------------
mpg | Coef. Std. Err. t P>|t| [95% Conf. Interval]
----------+----------------------------------------------------------------
weight | -.0065879 .0006371 -10.34 0.000 -.0078583 -.0053175
foreign | -1.650029 1.075994 -1.53 0.130 -3.7955 .4954422
_cons | 41.6797 2.165547 19.25 0.000 37.36172 45.99768
---------------------------------------------------------------------------
------------------------------------------------------------------------------
mpg | Coef. Std. Err. t P>|t| [95% Conf. Interval]
-------------+----------------------------------------------------------------
weight | -.0065879 .0006371 -10.34 0.000 -.0078583 -.0053175
|
foreign |
Domestic| 0 (base)
Foreign | -1.650029 1.075994 -1.53 0.130 -3.7955 .4954422
|
_cons | 41.6797 2.165547 19.25 0.000 37.36172 45.99768
------------------------------------------------------------------------------
------------------------------------------------------------------------------
mpg | Coef. Std. Err. t P>|t| [95% Conf. Interval]
-------------+----------------------------------------------------------------
weight | -.0060087 .0005179 -11.60 0.000 -.0070411 -.0049763
_cons | 39.44028 1.614003 24.44 0.000 36.22283 42.65774
------------------------------------------------------------------------------
------------------------------------------------------------------------------
mpg | Coef. Std. Err. t P>|t| [95% Conf. Interval]
-------------+----------------------------------------------------------------
foreign | 4.945804 1.362162 3.63 0.001 2.230384 7.661225
_cons | 19.82692 .7427186 26.70 0.000 18.34634 21.30751
------------------------------------------------------------------------------
------------------------------------------------------------------------------
mpg | Coef. Std. Err. t P>|t| [95% Conf. Interval]
-------------+----------------------------------------------------------------
price | -.0009192 .0002042 -4.50 0.000 -.0013263 -.0005121
_cons | 26.96417 1.393952 19.34 0.000 24.18538 29.74297
------------------------------------------------------------------------------
Repair |
Record 1978 | Freq. Percent Cum.
------------+-----------------------------------
1 | 2 2.70 2.70
2 | 8 10.81 13.51
3 | 30 40.54 54.05
4 | 18 24.32 78.38
5 | 11 14.86 93.24
. | 5 6.76 100.00
------------+-----------------------------------
Total | 74 100.00
------------------------------------------------------------------------------
mpg | Coef. Std. Err. t P>|t| [95% Conf. Interval]
-------------+----------------------------------------------------------------
weight | -.0044096 .0006225 -7.08 0.000 -.0056847 -.0031346
_cons | 33.98076 2.104537 16.15 0.000 29.66981 38.2917
------------------------------------------------------------------------------
mpg | Coef. Std. Err. t P>|t| [95% Conf. Interval]
-------------+----------------------------------------------------------------
weight | -.0081081 . . . . .
_cons | 46.13514 . . . . .
------------------------------------------------------------------------------
------------------------------------------------------------------------------
mpg | Coef. Std. Err. t P>|t| [95% Conf. Interval]
-------------+----------------------------------------------------------------
weight | -.0080464 .0010219 -7.87 0.000 -.010547 -.0055459
_cons | 46.11072 3.45372 13.35 0.000 37.65977 54.56167
------------------------------------------------------------------------------
------------------------------------------------------------------------------
mpg | Coef. Std. Err. t P>|t| [95% Conf. Interval]
-------------+----------------------------------------------------------------
weight | -.0044096 .0006225 -7.08 0.000 -.0056847 -.0031346
_cons | 33.98076 2.104537 16.15 0.000 29.66981 38.2917
------------------------------------------------------------------------------
------------------------------------------------------------------------------
mpg | Coef. Std. Err. t P>|t| [95% Conf. Interval]
-------------+----------------------------------------------------------------
weight | -.0049572 .0005596 -8.86 0.000 -.0061435 -.0037709
_cons | 35.89382 1.680188 21.36 0.000 32.33198 39.45566
------------------------------------------------------------------------------
------------------------------------------------------------------------------
mpg | Coef. Std. Err. t P>|t| [95% Conf. Interval]
-------------+----------------------------------------------------------------
weight | -.01816 .0036908 -4.92 0.001 -.0265091 -.009811
_cons | 69.54448 8.69354 8.00 0.000 49.87832 89.21063
------------------------------------------------------------------------------
Two-sample t test with equal variances
--------------------------------------------------------------------------------------------------------------
Group | Obs Mean Std. Err. Std. Dev. [95% Conf. Interval]
---------+---------------------------------------------------------------------------------------------------
Domestic | 52 19.82692 .657777 4.743297 18.50638 21.14747
Foreign | 22 24.77273 1.40951 6.611187 21.84149 27.70396
---------+-----------------------------------------------------------------------------------------------------
combined | 74 21.2973 .6725511 5.785503 19.9569 22.63769
---------+-----------------------------------------------------------------------------------------------------
diff | -4.945804 1.362162 -7.661225 -2.230384
---------------------------------------------------------------------------------------------------------------
diff = mean(Domestic) - mean(Foreign) t = -3.6308
Ho: diff = 0 degrees of freedom = 72
Ha: diff < 0 Ha: diff != 0 Ha: diff > 0
Pr(T < t) = 0.0003 Pr(|T| > |t|) = 0.0005 Pr(T > t) = 0.9997
Effect size based on mean comparison
Obs per group:
Domestic = 52
Foreign = 22
-----------------------------------------------------------------------------
Effect Size | Estimate [95% Conf. Interval]
--------------------+--------------------------------------------------------
Cohen's d | -.9234449 -1.441225 -.3997744
Hedges's g | -.9137865 -1.426151 -.3955932
-----------------------------------------------------------------------------
Effect size based on mean comparison
Obs per group:
Group 1 = 52
Group 2 = 22
---------------------------------------------------------
Effect Size | Estimate [95% Conf. Interval]
--------------------+------------------------------------
Cohen's d | -.923446 -1.441226 -.3997755
Hedges's g | -.9137876 -1.426153 -.3955942
---------------------------------------------------------
Mileage
(mpg) Freq. Percent Cum.
12 2 2.70 2.70
14 6 8.11 10.81
・・・(略)・・・
35 2 2.70 98.65
41 1 1.35 100.00
Total 74 100.00
Variable Obs Mean Std. Dev. Min Max
mpg 74 21.2973 5.785503 12 41
Variable N Mean SD Min Max日付データは,普通は統計ソフトに読みこんだときは文字型の
mpg 74 21.30 5.79 12.00 41.00 Mileage (mpg)
+----------------------+
t1 t2
----------------------
1. 1959/12/1 1961/1/1
+----------------------+
+-----------+
t1r t2r
-----------
1. -31 366
+-----------+
+-----+
dif
-----
1. 397
+-----+
+-------------------------+
t1 t2
-------------------------
1. 12-01-1959 01-01-1961
+-------------------------+
+-----------+
t1r t2r
-----------
1. -31 366
+-----------+
19359
+--------+
female
--------
1. 0
2. 0
3. 1
4. 1
5. 1
+--------+
female Freq. Percent Cum.
0 2 40.00 40.00
1 3 60.00 100.00
Total 5 100.00
性別 Freq. Percent Cum.
0 2 40.00 40.00
1 3 60.00 100.00
Total 5 100.00
性別 Freq. Percent Cum.
男性 2 40.00 40.00
女性 3 60.00 100.00
Total 5 100.00
+--------+
female
--------
1. 男性
2. 男性
3. 女性
4. 女性
5. 女性
+--------+
性別 Freq. Percent Cum.
0 2 40.00 40.00
1 3 60.00 100.00
Total 5 100.00