24
Stata Technical Bulletin
STB-33
snp12 Stratified test for trend across ordered groups
Peter Sasieni, Imperial Cancer Research Fund, London, FAX (011)-44-171-269-3429, [email protected]
The command uptrend was introduced to Stata following the STB article by Stepniewska and Altman (1992). The command
was revised by Sasieni, Stepniewska, and Altman (1996) and an immediate version, nptri, was provided for use with ordered
categorical tables. This revision permits calculation of the stratified version of the test.
In many situations, one may wish to stratify the sample on the basis of the values of one or more nuisance variables (such
as age and sex in epidemiology). The test is then performed assuming homogeneity of association between the outcome variable
and the ordered groups within strata. The new version of nptrend called npt_s, has the ability to perform stratified tests.
The stratified test statistic is calculated by summing the observed value, the expected value, and the variance of the weighted
sum of ranks from each strata. npt_s uses the same score for a given value of the grouping (by) variable in all strata.
The output of nptrend has been modified so that even when the strata option is not used, the observed and expected
value of the weighted sum of ranks together with the its variance is displayed. Use of nodetail will suppress all but the value
of the test statistic and its p-value.
The syntax of npt_s is
npt_s varname [if exp∖ [in range], by(groupvar) [ nodetail strat a Vvarlist) ]
Examples
These data come from a study of the effects of reduction in smoking on cervical lesions (Szarewski et al. 1996).
. use stb2
(Smoking and cervical lesions)
. describe
Contains data from stb2.dta |
Smoking and cervical lesions | ||
0bs: |
82 (max= |
2021) | |
Vars: |
4 (max= |
999) |
27 Aug 1996 14:42 |
Width: |
4 (max= |
2000) |
1. quit |
byte |
Ж Og |
quit2 |
Smoking change |
2. sc3 |
byte |
%9.0g |
sc3 |
Social Class |
3. init-sm |
byte |
%9.0g |
init2 |
Initial No./day |
4. r_area |
byte |
%9.0g |
r_area |
Area: rel. to initial |
Sorted by: r_area
The main interest is in the association between the extent to which women gave up smoking and the change in the area of
their lesions over the same 6 month period.
. tab quit r_area, row
Smoking I |
Area: rel. <.25 |
to initial .25-.5 |
.5-.8 |
.8-1.2 |
>1.2 I |
Total |
————————————F- I |
0 |
2 28.57 |
1 14.29 |
4 57.14 |
0 I 0.00 I |
— 7 100.00 |
>75 I I |
0 |
0 |
1 5.26 |
12 63.16 |
6 I 31.58 I |
— 19 100.00 |
(.5,75] I |
0 |
1 7.69 |
2 15.38 |
7 53.85 |
3 I 23.08 I |
— 13 100.00 |
(.25,.5] I I |
3 20.00 |
0 |
6 40.00 |
5 33.33 |
1 I 6.67 I |
— 15 100.00 |
(0,.25] I I |
1 9.09 |
3 27.27 |
6 54.55 |
1 9.09 |
0 I 0.00 I |
— 11 100.00 |
-----------+. quit I |
7 41.18 |
3 17.65 |
3 17.65 |
4 23.53 |
0 I |
— 17 100.00 |
-----------+. Total I |
11 13.41 |
9 10.98 |
19 23.17 |
33 40.24 |
io I 12.20 I |
— 82 100.00 |