Upload
others
View
3
Download
0
Embed Size (px)
Citation preview
��������������� ����Nonparametric Statistics
��. ���� ���� � !"��#�$�$ #�����%&'(�'$�ก�*�����
�+'��,��+�-.*����� �/�#�0!�&1!.��%ก��Web: http://home.kku.ac.th/nikom
Email: [email protected]
���������� � �����������
���������� � ������: �� ��� �-�������������ก �� ก!"�ก �#$ก#$�%��&�-��������'(�ก )%��&������ก �� *��* ) + ���ก� +* )��ก�-Interval/Ratio Scale %��&��� Normal
��<�ก �%������� ��������� � ������=��ก)*���
- ��<�ก ����'(�������������� � ���������#��$��� (truly nonparametric procedures) �=E+��<�ก �%�������������� � ������ ������*��+'$� � � ������%�=��( ก� �(+ก ��*�) ก ��*�) run, goodness of fit -��<�ก �#$ก#$�#))���� (distribution-free procedures)
ก ��*�) Run Test '(�'+ก ��*�)ก ��K� (randomness) �(+ก ��Lก! ���%��&�=M������%� � )ก ����$ ����Lก�&�=M��+ก�� %��&����&=#))� ก!"� M F M F M F M F #�*��&=#))%��&�#))��� (mixed) ��� M M M M F F F F �=E+�&=#))ก�K� (cluster) QL��� ก!"�� R�����'(�&=#))����ก�*S*��K�
H0 : ก �������V * )%��&��=E+� ก!"��K�HA : ก �������V * )%��&����=E+� ก!"��K�
. list
sex1 sex2 sex3
1. 1 1 1
2. 0 1 0
3. 1 1 0
4. 0 1 1
5. 1 0 0
6. 0 0 1
7. 1 0 1
8. 0 0 0
. runtest sex1
N(sex1 <= .5) = 4
N(sex1 > .5) = 4
obs = 8
N(runs) = 8
z = 2.29
Prob>|z| = .02
. runtest sex2
N(sex2 <= .5) = 4
N(sex2 > .5) = 4
obs = 8
N(runs) = 2
z = -2.29
Prob>|z| = .02
. runtest sex3
N(sex3 <= .5) = 4
N(sex3 > .5) = 4
obs = 8
N(runs) = 6
z = .76
Prob>|z| = .45
ก �'(����������� � ������'(����������� � ������������-%��ก�����=E+�=� ��������� � ������ �(+ ����* )ก �� * (�� �� ��+��ก�#� ก �#$ก#$�#))��=ก�� �� �#=�=��+���� ก +-%��&�����* )ก �� * + ���ก� +* )��ก�-%��&���$V +�+��� ก
��#<��=ก��%<ก%< >?��'��-A/B�<��+�<�ก.B��C&����(� D. su chol,de
chol
-------------------------------------------------------------
Percentiles Smallest
1% 150 150
5% 150 155
10% 152.5 155 Obs 10
25% 155 160 Sum of Wgt. 10
50% 165 Mean 169
Largest Std. Dev. 16.46545
. su hei,de
hei
-------------------------------------------------------------
Percentiles Smallest
1% 150 150
5% 150 160
10% 155 162 Obs 10
25% 162 163.5 Sum of Wgt. 10
50% 165 Mean 177.55
Largest Std. Dev. 30.15925
chol hei
155 150.0
155 163.5
150 170.0
200 210.0
180 180.0
170 165.0
160 165.0
160 162.0
170 160.0
190 250.0
. swilk chol hei
Shapiro-Wilk W test for normal data
Variable | Obs W V z Prob>z
-------------+-------------------------------------------------
chol | 10 0.92386 1.173 0.279 0.39027
hei | 10 0.75492 3.777 2.644 0.00410
. pwcorr chol hei, sig
| chol hei
-------------+------------------
chol | 1.0000
|
|
hei | 0.7838 1.0000
| 0.0073
|
. spearman chol hei
Number of obs = 10
Spearman's rho = 0.5890
Test of Ho: chol and hei are independent
Prob > |t| = 0.0732
���$�) %��&��)� � �#=� Cholesterol =ก��#� hei ��ก �#$ก#$���=ก��
Paired t-test Wilcoxon Match paired sign rank testindependent Wilcoxon rank sum testt-test (Mann-Whithany test)Pearson Spearman rankCorrlelation Correlationone-way Kruskal-WallisANOVA ANOVA
ก$%&'()*(++,-./$0
1230 45$+6-ก-3$7%8953$7ก:,3+Parametric : <2=43$1>:?@ANonparametric: <2=43$+BCA/$01DE043$&?@ <2=<0ก$%&'()*1230ก$%&'()*45$+6-ก-3$7F)7%8'B*cholesterol %8953$7 sex
ก$%&'()*(++,-./$0T-test H0 : 43$1>:?@AF)7%8'B* cholesterol 1JK2$A6:89L.7M+36-ก-3$7กB0 H0 : 43$1>:?@AF)7%8'B* cholesterol 1JK2$A6:89L.76-ก-3$7กB0Wilcoxon Rank sum Test H0 : +BCA/$0F)7%8'B* cholesterol 1JK2$A6:89L.7M+36-ก-3$7กB0 H0 : +BCA/$0F)7%8'B* cholesterol 1JK2$A6:89L.76-ก-3$7กB0
4O$05P43$: <2=:O$'B*&?@<0ก$%4O$05P ก%P?Q:%5+ rank 1&3$R กB0 1230 %8'B* cholesterol %8953$71JK2$A 1JK9L.7 1JK2$A 1JK9L.7 200 (1) 220 (2) 230 (4) 225 (3) 255 (6) 240 (5) %5+ 11 10Danial W.W. 1978 (applied nonparametic statistics)
0O$MD<2=4O$05P p-value -3)MD
Two-sample Wilcoxon rank-sum (Mann-Whitney) test
sex | obs rank sum expected
---------+---------------------------------
1 | 3 11 10.5
2 | 3 10 10.5
---------+---------------------------------
combined | 6 21 21
unadjusted variance 5.25
adjustment for ties 0.00
----------
adjusted variance 5.25
Ho: chol(sex==1) = chol(sex==2)
z = 0.218
Prob > |z| = 0.8273
����� Rank�ก� �����ก��
����������� p-value
4O$05P43$: <2=:O$'B*&?@<0ก$%4O$05P ก%P?Q:%5+6-ก-3$7กB0 1230 %8'B* cholesterol %8953$71JK2$A 1JK9L.7 1JK2$A 1JK9L.7 250 (5) 195 (1) 260 (6) 200 (2) 270 (7) 205 (3)
280 (8) 210 (4) %5+ 26 10
0O$MD<2=4O$05P p-value -3)MD
Two-sample Wilcoxon rank-sum (Mann-Whitney) test
sex | obs rank sum expected
---------+---------------------------------
1 | 4 26 18
2 | 4 10 18
---------+---------------------------------
combined | 8 36 36
unadjusted variance 12.00
adjustment for ties 0.00
----------
adjusted variance 12.00
Ho: chol(sex==1) = chol(sex==2)
z = 2.309
Prob > |z| = 0.0209
����� Rank ���ก��
(_.-. Wilcoxon sign rank test F=)+̀:2,'1'?A5
���� T = minimum(T+, T-)
������� - �������ก�������������������ก�������ก����- ���������������� �ก����!"��ก- #����������ก�������� (������$%� #��#&����������'����)
24/)12)(1(
4/)1(
++
+−=
nnn
nnTZ
48
3
24
)12)(1(
4/)1(
∑ ∑−−++
+−=
ttnnn
nnTZ
ก��������
����� ��������� sysbp ��ก������������� �����กก!�� 40 $% bmi 20-25 �����+,ก,��-ก.� 120 mmHg 2�3 4��
- 7 7 -20120140
-4.54.5 -15120135
-4.5 4.5 -15120135
- 1010 -45120165
-9 9 -39120159
-33 -13120133
- 1 1-10120130
- 2 2-11120131
-8 8-31120151
- 66-16120136
T+T- rankdi yi xi
T- = 55, T+ = 0
T=minimum(55, 0) = 0
- 7 7 -20120140
-4.54.5 -15120135
-4.5 4.5 -15120135
- 1010 -45120165
-9 9 -39120159
-33 -13120133
- 1 1-10120130
- 2 2-11120131
-8 8-31120151
- 66-16120136
T+T- rankdi yi xi
48
3
24
)12)(1(
4/)1(
∑ ∑−−++
+−=
ttnnn
nnTZ
80.2
48232
24
)1)10(2)(110(10
4/)110(100=
∑ ∑−−++
+−=Z
ก��������
���������� � ������: ก�"�%��&� 2 (K*Mann-Whitney Test
'(��*�)%��&� 2 (K* ����=E+�����ก +
�� กก ��*�)�� � <�[ +%�%��&� 2 ก�K��� ก + �����%�
�V * )��� '+#���ก�K� (����'���V * )��� (Rank) %��&����ก +) $���� ��#�ก� �ก +
−+
+
−+
+
=
2T
2
1)2
(n2
n
2n
1n
1T
2
1)1
(n1
n
2n
1n
minu
Mann-Whitney Test����
n1 = bO$050-B5)A3$7F)743$(B71ก-&?@+?bO$0500=)An2 = bO$050-B5)A3$7F)743$(B71ก-&?@+?bO$050+$กT1 = Q:%5+:O$'B*&?@<0ก:,3+ n1T2 = Q:%5+:O$'B*&?@<0ก:,3+ n2
���
ก�"�%+ *� �� �%+ *'�]
2
1)n(nTu 1
+−=
1)/12n(nnn
2
nn-U
z2121
21
++=
�������� ��ก��ก� ����ก��� �������� cholesterol ��!���"#$%�&�!'(� ������
%8'B* cholesterol %8953$71JK2$A 1JK9L.7 1JK2$A 1JK9L.7 200 220 230 225 255 240
ก ��*�) (manual)1. � R����K��[ +2. '���V * )���%��&� $ ก+���=� ก �V * )����� ก +'���V * )����`����3. � �����%��V * )���� R� 2 ก�K�4. �V +�"� %������ Mann-Whitney
n1 = $V +�+(K*%��&�(K*��� 1n2 = $V +�+(K*%��&�(K*��� 2���� n1 < n2
5. �=g*� � �� p-value /��K=��
Mann-Whitney U Test
ก�������ก)!���!* M1 "-.���/%0�����*���&$1�234 1 M2 "-.���/%0�����*���&$1�234 21. ������� �!"�# Two Tailed Ho : M1 = M2
HA : M1 < M2
2. ก%�&#��'���#���%�(�) 0.05
-<9=:O$'B*&?@ /%5+Q:%5+F)7 rank %8'B* cholesterol %8953$71JK2$A 1JK9L.7 1JK2$A 1JK9L.7 200 (1) 220 (2) 230 (4) 225 (3) 255 (6) 240 (5)
%5+ 11 10
Mann-Whitney U Test(%�#�,(������-!�!
−+
+
−+
+
=
2T
2
1)2
(n2
n
2n
1n
1T
2
1)1
(n1
n
2n
1n
minu
=
−+
+
−+
+=
5
4
102
1)3(33(3)
112
1)3(33(3)
minu
2
1)n(nTu 1
+−=
410 =+
−=2
1)3(3u
./0������ k .�23� n1=n2=3 ; p-value >.10 [non significant]
.ranksum chol, by(sex)
Two-sample Wilcoxon rank-sum (Mann-Whitney) test
sex | obs rank sum expected
---------+---------------------------------
1 | 3 11 10.5
2 | 3 10 10.5
---------+---------------------------------
combined | 6 21 21
unadjusted variance 5.25
adjustment for ties 0.00
----------
adjusted variance 5.25
Ho: chol(sex==1) = chol(sex==2)
z = 0.218
Prob > |z| = 0.8273
+BCA/$0%8'B* cholesterol %8953$71JK2$A6:81JK9L.7M+36-ก-3$7กB0 (p=.8273)
Wilcoxon Match paired sign rank test!"#$%�����&�'��($�( $�)� 2 +,"!�-������#��.��&/ก�� -Pretest-Post test (repeated measure) -Twins, litter mates -match pair
Wilcoxon Matched-pair Signed rank Test(̀-% T = minimum(T+ or T- ) T+ = Q:%5+F)7:O$'B*&?@&?@+?14%e@)79+$A*5ก
T- = Q:%5+F)7:O$'B*&?@&?@+?14%e@)79+$A:*
1)/241)(2nn(n
4
1)n(n-T
z++
+
=
48
3
24
)12)(1(
4/)1(
∑ ∑−−++
+−=
ttnnn
nnTZ
ก��������
ก�����!� Wilcoxon sum rank test ���!������A��!ก.�
Wilcoxon Matched-pair Signedrank Test-B5)A3$7 ก��?@กA���B-$�ก��C�,"#)%%,C��-���� �$��� FEV1 � ก ���ก�%ก�$���Hก#)%C�B$I�� ??@กA����) #)%%,C��-KL���� 10 �� ��"���FEV1 2 ���N� ���!�-�� ��K#���OP�.�$" ��QP��C���K�ก�� ��K���N���ก6 �"B$�
idno fev1 fev1p1 83 802 76 763 80 774 76 745 75 736 78 707 77 728 85 799 80 7510 77 71
ก ��*�) (manual)1. � R����K��[ +2. � ��� �%�%��&� 2 (K* (di)2. '���V * )��� (di) $ ก+���=� ก �V * )����� ก +'���V * )����`����
3. � �����%��V * )��� (T+ or T-)4. �V +�"� %������5. �=g*� � �� p-value /��K=��
idno fev1p fev1 di T- T+1 80 83 3 - 3.52 76 76 0 - �������3 77 80 3 - 3.54 74 76 2 - 1.55 73 75 2 - 1.56 70 78 8 - 97 72 77 5 - 5.58 79 85 6 - 7.59 75 80 5 - 5.510 71 77 6 - 7.5� ! 0 45
1. (++,-./$0 H0 : Mdi = 0 HA : Mdi < 02. กO$90'%8'B* 0BA(O$4BL 0.053. (̀-%T = min(T+ or T- ) = min(0, 45) = 0
4. P-Value 1Dh'-$%$7 T=0,n = 9 ; p-value<.0001.signrank fev1= fev1pWilcoxon signed-rank test
sign | obs sum ranks expected
---------+---------------------------------
positive | 9 54 27
negative | 0 0 27
zero | 1 1 1
---------+---------------------------------
all | 10 55 55
unadjusted variance 96.25
adjustment for ties -0.50
adjustment for zeros -0.25
----------
adjusted variance 95.50
Ho: fev1 = fev1p
z = 2.763
Prob > |z| = 0.0057
+BCA/$0%8'B* FEV1 ก3)06-ก-3$7กB*9:B79A,'(`**,9%?@ )A3$7+?0BA(O$4BL&$7(_.-. (p-value = 0.0057)
Kruskal-Wallis ANOVA&'()*45$+6-ก-3$743$+BCA/$0F)7F=)+:̀ >22,' &?@1DE0).(%8-3)กB0
-ordinal scale-Interval/ratio Scale (non normal)-Unequal Variance
ก ��*�) (manual)1. � R����K��[ +2. '���V * )���%��&� $ ก+���=� ก �V * )����� ก +'���V * )����`����3. � �����%��V * )����Kกก�K� [R]4. �V +�"� %������
5. �=g*� � �� p-value /��K=�� k >3 [or] ni >5 '(�� � � Chi-Square
∑=
+−+
=k
1i
1)3(N
in
2
iR
1)N(N
12H
�������� ��ก��ก� ����ก��� �������� cholesterol ��!����$3#���@ ������
%8'B* cholesterol F)7)$2?J-3$7R 1กp-%ก%%+ %B*%$2ก$% 4=$F$A
200 240 250 300 270 280 210 260 290
-<9=:O$'B*&?@ /%5+Q:%5+F)7 rank
%8'B* cholesterol F)7)$2?J-3$7R 1กp-%ก%%+ %B*%$2ก$% 4=$F$A 200 (1) 240 (3) 250 (4) 300 (9) 270 (6) 280 (7) 210 (2) 260 (5) 290 (8)
%5+ 12 14 19
(%�#�,(������-!�!
∑=
+−+
=k
1i
1)3(N
in
2
iR
1)N(N
12H
1)3(9-]3
19
3
14
3
12[
1)9(9
12H
222
++++
=
= 1.15 ./0������ H=1.15 n1=n2=n3=3 ;p-value>0.10+BCA/$0F)7%8'B* cholesterol %8953$7ก:,3+)$2?J-3$7R M+36-ก-3$7กB0
. kwallis chol,by(occ)Test: Equality of populations (Kruskal-Wallis Test)
occ _Obs _RankSum
1 3 12.00
2 3 14.00
3 3 19.00
chi-squared = 1.156 with 2 d.f.
probability = 0.5611
_=$ก$%5.14%$89q Kruskal-Wallis ANOVA Q:ก$%&'()* 6-ก-3$7 <9=&'()*45$+ 6-ก-3$7'=5A Multiple comparison-1230 Dunn , Wilcoxon ranksum test r'A&'()*&?@:84̀3
0.05
Chi-Square disribution d.f. = 2
Critical Values of Chi-square
df .50 .25 .10 .05 .025 .01 .001
1 0.45 1.32 2.71 3.84 5.02 6.63 10.83
2 1.39 2.77 4.61 5.99 7.38 9.21 13.82
3 2.37 4.11 6.25 7.81 9.35 11.34 16.27
...
100 99.33 109.14 118.50 124.34 129.56 135.81 149.45
EF!0F��=0 ?&'�C� %&' (� != 0 !=��� ก1=p-value A/�� 0��ก1=
k =<I��#�ก&-��
$��กI�/�F k= 3 alpha=.15
2
k
α
05.
)!23(!2
!3
15.0;
α;15.0 =
−
=
2
3α
Multiple comparison
�������� ��ก��ก� ����ก��� �������� cholesterol ��!����$3#���@ ������
%8'B* cholesterol F)7)$2?J-3$7R 1กp-%ก%%+ %B*%$2ก$% 4=$F$A
200 240 300 250 270 280 210 260 290
. kwallis chol,by(gr)
Test: Equality of populations (Kruskal-Wallis test)
+---------------------+
| gr | Obs | Rank Sum |
|----+-----+----------|
| 1 | 3 | 7.00 |
| 2 | 3 | 14.00 |
| 3 | 3 | 24.00 |
+---------------------+
chi-squared = 6.489 with 2 d.f.
probability = 0.0390
chi-squared with ties = 6.489 with 2 d.f.
probability = 0.0390
. ranksum chol if (occ==1 | occ==2) , by(occ)
Two-sample Wilcoxon rank-sum (Mann-Whitney) test
occ | obs rank sum expected
-------------+---------------------------------
1 | 3 7 10.5
2 | 3 14 10.5
-------------+---------------------------------
combined | 6 21 21
unadjusted variance 5.25
adjustment for ties 0.00
----------
adjusted variance 5.25
Ho: chol(occ==1) = chol(occ==2)
z = -1.528
Prob > |z| = 0.1266
. ranksum chol if (occ==1 | occ==3) , by(occ)
Two-sample Wilcoxon rank-sum (Mann-Whitney) test
occ | obs rank sum expected
-------------+---------------------------------
1 | 3 6 10.5
3 | 3 15 10.5
-------------+---------------------------------
combined | 6 21 21
unadjusted variance 5.25
adjustment for ties 0.00
----------
adjusted variance 5.25
Ho: chol(occ==1) = chol(occ==3)
z = -1.964
Prob > |z| = 0.0495
. ranksum chol if (occ==2 | occ==3) , by(occ)
Two-sample Wilcoxon rank-sum (Mann-Whitney) test
occ | obs rank sum expected
-------------+---------------------------------
2 | 3 6 10.5
3 | 3 15 10.5
-------------+---------------------------------
combined | 6 21 21
unadjusted variance 5.25
adjustment for ties 0.00
----------
adjusted variance 5.25
Ho: chol(occ==2) = chol(occ==3)
z = -1.964
Prob > |z| = 0.0495
����� Spearman Rank correlation-#1F�#���1�1�,��'/#���1#%(� 2 �1#%(�-ordinal scale, interval & ratio scale(non-normal)
yxi
d
1)2n(n
2i
d61
sr
−=
−
∑−=
����� Spearman Rank correlationก�+ � ���UDI�ก1�
∑ ∑
∑ ∑ ∑−+=
22
22
2 yx
dy i2x
sr
∑ ∑−−
= xTnn
x12
32
∑ ∑−−
= yTnn
y12
32
12
3tt
T ii
−=∑
�>?� i = x, y AFX
�1#�!�� A/B#� ���'/��#���1�1�,��'/#���'F1=�#�� �� !FA�ก��0I���ก1=�'F1=�#��Y�A<A�ก��0I��� stress sat
1 52 43 34 25 2
ก��0F��= (manual)1. �1D���-��Z��2. กI�/�F�'F1=�1!�I��1[3. A/B&I�F1=0 ?.B��C&<�ก�B�!�(��กA�%��&'ก&-�� &I�F1=0 ? 0��ก1�A/B&I�F1=0 ? \& ?!3. /��#��%�ก����'/#�� rank dj = R(x)-(R(y)4. �I��#+���.������5. (_F����/� p-value /��-(`&
30;2,1
2
30;
2≤−=
−
−=
>=
nndfr
nrt
n
s
1-nrZ s
0ρ:H0;ρ:0H s0s ≠=
stress sat rx ry d d21 5 1 5 -4 162 4 2 4 -2 43 3 3 3 0 04 2 4 1.5 2.5 6.255 2 5 1.5 3.5 12.25
∑ ∑
∑ ∑ ∑−+=
22
22
2 yx
dy i2x
sr
5.912
22
12
55 332 =
−−
−=∑ x 10
12
5532 =
−=∑ y
12
3tt
T ii
−=
∑ ∑
∑ ∑ ∑−+=
22
22
2 yx
dy i2x
sr
974679.)10(5.92
5.38105.9−=
−+=
sr
(_F����/� p-value <.005
2,1
22
−=−
−= ndf
r
nrt
s
25,167.6)9747.(1
259747.
2−=−=
−−
−−= dft
. spearman stress sat
Number of obs = 5
Spearman's rho = -0.9747
Test of Ho: stress and sat are independent
Prob > |t| = 0.0048
��-(`& �#�� �� !F� �#���1�1�,�0�&=ก1=�#��Y�A<A��� �!��� �1!�I��1[0������ (rs = -.9747,p-value =.0048)