26
Stata Technical Bulletin
STB-33
-----------+. Total I |
22 29.33 |
37 49.33 |
-----------+— |
— 7ε 100.00 |
. npt_s init |
if quit”= |
0, by(quit) | ||
quit |
score |
obs |
sum of ranks | |
1.0 |
1.0 |
19 |
793. ε | |
2.0 |
2.0 |
13 |
743.0 | |
3.0 |
3.0 |
ιε |
ε79.ε | |
4.0 |
4.0 |
11 |
244. ε | |
ε.o |
ε.o |
17 |
487. ε | |
Obs |
Exp |
Var | ||
7437.ε |
8322.0 |
79872 | ||
z =-3. |
.14, chi- |
squared(l) = |
9.83 |
P>∣z∣ = 0.0017
• npt_s r-area if quit"=0, by(quit) strata(sc3)
sc3 |
Obs |
Exp |
Var | |
1 |
804.6 |
651.0 |
1953 | |
2 |
1964.6 |
2183.0 |
6573.6665 | |
3 |
311.0 |
390.0 |
1043.3334 | |
— Total |
2780.0 |
— 3224.0 |
9569.9999 | |
z |
= -4.84, |
chi-squared(l) = |
20.60 | |
P>∣z∣ |
= 0.0000 | |||
npt_s |
r_area if |
quif=0, by(quit) |
strata(sc3 init) | |
sc3 |
init-sm |
Obs |
Exp |
Var |
1 10 |
195.0 |
234.0 |
316 | |
1 20 |
53.5 |
76.0 |
100 | |
1 30 |
6.0 |
6.0 |
0 | |
2 10 |
189.5 |
190.0 |
41.666668 | |
2 20 |
601.5 |
682.5 |
1181.25 | |
2 30 |
54.0 |
60.0 |
13.333333 | |
3 10 |
5.0 |
6.0 |
1 | |
3 20 |
100.0 |
121.0 |
161.33333 | |
3 30 |
41.0 |
52.0 |
60 | |
— Total |
— 1245.5 |
— 1427.5 |
1874.5833 | |
z |
= -4.20, |
chi-squared(l) = |
17.67 |
P>∣z∣ = 0.0000
The second example uses Stata’s automobile dataset.
. use ∕usr∕local∕stata∕auto
(1978 Automobile Data)
Fuel consumption increases with repair record.
npt_s mpg, |
by(rep78) | ||
rep78 |
score |
obs |
sum of ranks |
1.0 |
1.0 |
2 |
72.5 |
2.0 |
2.0 |
8 |
220.5 |
3.0 |
3.0 |
30 |
905.0 |
4.0 |
4.0 |
18 |
688.5 |
5.0 |
5.0 |
11 |
528.5 |
Obs |
Exp Var | ||
8625.0 |
8225.0 26821.666 | ||
z = 2 |
.44, chi- |
squared(l) |
= 5.97 |
P>∣z∣ = 0.0146
This association is virtually all explained by the fact that foreign cars had better repair records and more efficient fuel consumption.