- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
I am testing the significance of the median in my sample using the one sample Wilcoxons signed rank test through proc univariate. However, the ouput presents an S statistic and for reporting purposes I would like to report the commonly used Z statistic. Is there any easy way of getting the Z statistic in SAS or would it be easier using another program like Stata?
Thanks in advance.
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Hi @kwil,
If your sample does neither contain two equal values ("ties") nor zeros, I would calculate the z statistic as follows (using x as the variable name) -- otherwise it would be more complicated:
proc univariate data=have noprint;
var x;
output out=stats signrank=S n=n;
run;
data want;
set stats;
z=S/sqrt(n*(n+1)*(2*n+1)/24);
run;
This is based on
- https://www.stata.com/manuals13/rsignrank.pdf
- PROC UNIVARIATE documentation, details section "Wilcoxon Signed Rank Test"
Note that SAS does not use the z statistic, but a tn-1 distributed statistic for the p-value computation, which is why the p-value based on the former (0.0327) differs slightly from the p-value in your output (0.0310).
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
You can use PROC NPAR1WAY in SAS.
Paige Miller
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Another way would be to use the CDFquantile('normal') function, plugging in the p value to get the Z value.
The only issue here is that S really is not normally distributed. For small n, an exact p value is computed. For large n (n>20), there is a function of S that is t distributed (see the Details\Tests for Location part of the UNIVARIATE documentation). I don't see any reference to a Z score for the Signed Rank statistic in the SAS documentation or in my copy of Hollander and Wolfe, which also uses an approximate t distribution.
SteveDenham.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Hi @kwil,
If your sample does neither contain two equal values ("ties") nor zeros, I would calculate the z statistic as follows (using x as the variable name) -- otherwise it would be more complicated:
proc univariate data=have noprint;
var x;
output out=stats signrank=S n=n;
run;
data want;
set stats;
z=S/sqrt(n*(n+1)*(2*n+1)/24);
run;
This is based on
- https://www.stata.com/manuals13/rsignrank.pdf
- PROC UNIVARIATE documentation, details section "Wilcoxon Signed Rank Test"
Note that SAS does not use the z statistic, but a tn-1 distributed statistic for the p-value computation, which is why the p-value based on the former (0.0327) differs slightly from the p-value in your output (0.0310).
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content