Professional Documents
Culture Documents
Stata Ttest Nk2552u PDF
Stata Ttest Nk2552u PDF
one-sample t-test
independent t-test/paired t-test
.
Email: nikom@kku.ac.th
WebPage: http://home.kku.ac.th/nikom
$ $
Research Process
$
1.
(objective)
2.
(study design)
3. Assumption
- -
-
K 1
-
One Sample t-test
t=
x
s/ n
95 %CI = x t / 2 , df (s/
n)
Assumption
-
- interval ratio scale
K 1
K
One Sample t-test t = x ; df = n 1
s/ n
-
- 7 sysBP 40
bmi 20-25 120 mmHg
: 7 sysbp
40 120 mmHg
120 130 130 140 140 140 150 150 160
. swilk sysbp
Shapiro-Wilk W test for normal data
Variable |
Obs
W
V
z
Prob>z
-------------+------------------------------------------------sysbp |
9
0.99549
0.066
-3.538 0.99980
$ sysbp
40
bmi 20-25 120 mmHg
1.
H0 : = 120
HA : 120
2. 0.05
3.
x
t=
s/ n
3.
t=
x
=
s/ n
140 120
12 . 25 / 9
= 4 . 899
95 %CI = x t / 2 , df (s/
n)
( t.05 / 2 ,9 )
95 %CI = 140 2 . 26 ( 12 . 25 /
9)
95% ci
120 mmHg
130.59-149.41 mm.Hg
%CI
H0
1
2
3
CI
= non-significant
(2) H0
= significant
(1,3) H0
%CI
H0 : = 120
120
130.59
149.41
CI
130.59-149.41 mm.Hg
95% ci
7 H0 = 120 $$ = significant
$
ttest varname , mu= #
varname = K
#
= KK
sysbp
$ 2 $
$
-Independent t-test
2
2
F-Test
-
K 2 K
K
(independent t-test pooled variance)
x x
1 2
t=
1 1
S
+
p n n
1 2
Standard error
n s2 + n s2
2 2
S = 11
n +n 2
1
2
2
p
2
(x
x
)
n
S 2i = i
i = 1 n 1
df = n + n 2
1 2
K 2 K
K
(Independent t-test unequal variance)
Standard error
x x
t= 1 2
s12 s 22
+
n n
1 2
df =
s12
n1
n (x x) 2
Si = i
i = 1 n 1
2
s 22
n2
s22
n2
n2 1
s12
n1
n1 1
df =
s12
n1
2
s12
n1
n1 1
+
+
s 22
n2
2
s22
n2
n2 1
(Assumption)
-
Assumption Wilcoxon Rank Sum Test
Mann-Whitney Test
F-Test
H 0 : 12 = 22 , H A : 12 22
0.05
2
s1 2 2
F = 2 ; s1 > s2 ; df1= n11,df2 = n2 1
s2
70.447762
F=
= 3.011
2
40.5984
10
chol 40
:
( 2 )
( 1)
idno
gr
chol
154
262
299
438
176
193
193
336
336
10
245
chol 40
( 1)
( 2 )
1.7
H0 : 1 = 2
H 0 : 1 2 = 0
HA :
1 2
H A : 1 2 0
2. 0.05
11
3.
variance
. sdtest chol, by(gr)
Variance ratio test
-----------------------------------------------------------------------------Group |
Obs
Mean
Std. Err.
Std. Dev.
[95% Conf. Interval]
---------+-------------------------------------------------------------------0 |
5
330.8
31.55852
70.56699
243.1795
418.4205
1 |
5
195.6
18.07927
40.42648
145.4039
245.7961
---------+-------------------------------------------------------------------combined |
10
263.2
28.31443
89.53807
199.1483
327.2517
-----------------------------------------------------------------------------ratio = sd(0) / sd(1)
f =
3.0470
Ho: ratio = 1
degrees of freedom =
4, 4
Ha: ratio < 1
Pr(F < f) = 0.8470
Ha: ratio != 1
2*Pr(F > f) = 0.3060
x x
1 2
t=
1 1
S
+
p n n
1 2
Standard error
2 + n s2
n
s
2 2
S2p = 1 1
n +n 2
1 2
2
(x
x
)
n
S 2i = i
i = 1 n 1
df = n + n 2
1 2
12
Manual K
. su chol if gr==1
Variable |
Obs
Mean
Std. Dev.
Min
Max
-------------+----------------------------------------------------chol |
5
195.6296
40.5984
153.9819
262.3016
. su chol if gr==0
Variable |
Obs
Mean
Std. Dev.
Min
Max
-------------+----------------------------------------------------chol |
5
330.8275
70.44776
245.3274
437.8791
t=
330.8 195.6
= 3.7
1 1
S
+
p 5 5
13
. swilk chol if gr==0
Shapiro-Wilk W test for normal data
Variable |
Obs
W
V
z
Prob>z
-------------+------------------------------------------------chol |
5
0.97679
0.274
-1.383 0.91674
. swilk chol if gr==1
Shapiro-Wilk W test for normal data
Variable |
Obs
W
V
z
Prob>z
-------------+------------------------------------------------chol |
5
0.91232
1.035
0.046 0.48164
variance F-TEST
7 sdtest varname , by(groupvar)
14
chol
gr
Ha: ratio != 1
2*Pr(F > f) = 0.3060
15
$
ttest varname1 == varname2 , unpaired [unequal]
ttest varname , by(groupvar)
16
. ttest
chol, by(gr)
H 0 : 1 = 2
Ha: diff != 0
Pr(|T| > |t|) = 0.0059
H A : 1 2
95 %CI = ( x1 x 2 ) t / 2 , df (se)
%CI
H0 : 1 = 2
0
H 0 : 1 2 = 0
51.33
219.07
CI
51.33-219.07 mm.Hg
95% ci
7 H0 = 0 $$ = significant
17
K 2
K
K paired t-test
t=
Standard error
di
2
(d
d
)
n
S 2i = i
i = 1 n 1
sd
n
df = n - 1
95 %CI = d t / 2 , df (se)
(Assumption)
-
(di)
cho1
cho2
300
240
-60
320
300
-20
330
330
330
300
-30
340
312
-28
18
: chol 40
3
cho1
cho2
300
240
-60
320
300
-20
330
330
330
300
-30
340
312
-28
chol 40
1. `
H0 : d = 0
HA :
d 0
2. 0.05
19
3.
. swilk d
Shapiro-Wilk W test for normal data
Variable |
Obs
W
V
z
Prob>z
-------------+------------------------------------------------d |
5
0.95382
0.545
-0.721 0.76445
. su d
Variable |
Obs
Mean
Std. Dev.
Min
Max
-------------+----------------------------------------------------d |
5
-27.6
21.65179
-60
0
t =
di
sd
n
27.6
21.7
5
= 2.9
$
ttest varname1 == varname2
20
Ha: mean(diff) != 0
Pr(|T| > |t|) = 0.0464
95 %CI = d t / 2 , df (se)
chol 40
7 95% CI 0.72-54.48
21
%CI
H0 : d = 0
0
.72
54.48
CI
.72-54.48
95% ci
7 H0 = 0 $$ = significant
%CI
H0 : d = 0
0
-54.48
-.72
CI
-54.48 -.72
95% ci
7 H0 = 0 $$ = significant
22