The UNIVARIATE Procedure

Tests for Location

PROC UNIVARIATE provides three tests for location: Student’s t test, the sign test, and the Wilcoxon signed rank test. All three tests produce a test statistic for the null hypothesis that the mean or median is equal to a given value mu 0 against the two-sided alternative that the mean or median is not equal to mu 0. By default, PROC UNIVARIATE sets the value of mu 0 to zero. You can use the MU0= option in the PROC UNIVARIATE statement to specify the value of mu 0. Student’s t test is appropriate when the data are from an approximately normal population; otherwise, use nonparametric tests such as the sign test or the signed rank test. For large sample situations, the t test is asymptotically equivalent to a z test. If you use the WEIGHT statement, PROC UNIVARIATE computes only one weighted test for location, the t test. You must use the default value for the VARDEF= option in the PROC statement (VARDEF=DF). See Example 3.12.

You can also use these tests to compare means or medians of paired data. Data are said to be paired when subjects or units are matched in pairs according to one or more variables, such as pairs of subjects with the same age and gender. Paired data also occur when each subject or unit is measured at two times or under two conditions. To compare the means or medians of the two times, create an analysis variable that is the difference between the two measures. The test that the mean or the median difference of the variables equals zero is equivalent to the test that the means or medians of the two original variables are equal. Note that you can also carry out these tests by using the PAIRED statement in the TTEST procedure; see Chapter 128, The TTEST Procedure (SAS/STAT User's Guide). Also see Example 3.13.

Student’s t Test

PROC UNIVARIATE calculates the t statistic as

t equals StartFraction x overbar minus mu 0 Over s slash StartRoot n EndRoot EndFraction

where x overbar is the sample mean, n is the number of nonmissing values for a variable, and s is the sample standard deviation. The null hypothesis is that the population mean equals mu 0. When the data values are approximately normally distributed, the probability under the null hypothesis of a t statistic that is as extreme, or more extreme, than the observed value (the p-value) is obtained from the t distribution with n minus 1 degrees of freedom. For large n, the t statistic is asymptotically equivalent to a z test. When you use the WEIGHT statement and the default value of VARDEF=, which is DF, the t statistic is calculated as

t Subscript w Baseline equals StartFraction x overbar Subscript w Baseline minus mu 0 Over s Subscript w Baseline slash StartRoot sigma-summation Underscript i equals 1 Overscript n Endscripts w Subscript i Baseline EndRoot EndFraction

where x overbar Subscript w is the weighted mean, s Subscript w is the weighted standard deviation, and w Subscript i is the weight for ith observation. The t Subscript w statistic is treated as having a Student’s t distribution with n minus 1 degrees of freedom. If you specify the EXCLNPWGT option in the PROC statement, n is the number of nonmissing observations when the value of the WEIGHT variable is positive. By default, n is the number of nonmissing observations for the WEIGHT variable.

Sign Test

PROC UNIVARIATE calculates the sign test statistic as

upper M equals left parenthesis n Superscript plus Baseline minus n Superscript minus Baseline right parenthesis slash 2

where n Superscript plus is the number of x Subscript i values that are greater than mu 0 and n Superscript minus is the number of x Subscript i values that are less than mu 0. Values that are equal to mu 0 are discarded. Under the null hypothesis that the population median is mu 0, the p-value for the observed test statistic upper M Subscript normal o normal b normal s is computed as

normal upper P normal r left parenthesis StartAbsoluteValue upper M EndAbsoluteValue greater than or equals StartAbsoluteValue upper M Subscript normal o normal b normal s Baseline EndAbsoluteValue right parenthesis equals 0.5 Superscript left parenthesis n Super Subscript t Superscript minus 1 right parenthesis Baseline sigma summation Underscript i equals 0 Overscript min left parenthesis n Superscript plus Baseline comma n Superscript minus Baseline right parenthesis Endscripts StartBinomialOrMatrix n Subscript t Baseline Choose i EndBinomialOrMatrix

where n Subscript t Baseline equals left parenthesis n Superscript plus Baseline plus n Superscript minus Baseline right parenthesis is the number of x Subscript i values that are not equal to mu 0.

Note: If n Superscript plus and n Superscript minus are equal, the p-value is 1.

Wilcoxon Signed Rank Test

The signed rank statistic S is computed as

upper S equals sigma-summation Underscript i colon x Subscript i Baseline greater-than mu 0 Endscripts r Subscript i Superscript plus Baseline minus StartFraction n Subscript t Baseline left-parenthesis n Subscript t Baseline plus 1 right-parenthesis Over 4 EndFraction

where r Subscript i Superscript plus is the rank of StartAbsoluteValue x Subscript i Baseline minus mu 0 EndAbsoluteValue after discarding values of x Subscript i Baseline equals mu 0, and n Subscript t is the number of x Subscript i values not equal to mu 0. Average ranks are used for tied values.

If n Subscript t Baseline less-than-or-equal-to 20, the significance of S is computed from the exact distribution of S, where the distribution is a convolution of scaled binomial distributions. When n Subscript t Baseline greater-than 20, the significance of S is computed by treating

upper S StartRoot StartFraction n Subscript t Baseline minus 1 Over n Subscript t Baseline upper V minus upper S squared EndFraction EndRoot

as a Student’s t variate with n Subscript t Baseline minus 1 degrees of freedom. V is computed as

upper V equals one-twenty-fourth n Subscript t Baseline left-parenthesis n Subscript t Baseline plus 1 right-parenthesis left-parenthesis 2 n Subscript t Baseline plus 1 right-parenthesis minus one-forty-eighth sigma-summation t Subscript i Baseline left-parenthesis t Subscript i Baseline plus 1 right-parenthesis left-parenthesis t Subscript i Baseline minus 1 right-parenthesis

where the sum is over groups tied in absolute value and where t Subscript i is the number of values in the ith group (Iman 1974; Conover 1980). The null hypothesis tested is that the mean (or median) is mu 0, assuming that the distribution is symmetric. Refer to Lehmann and D’Abrera (1975).

Last updated: April 10, 2023