Tuesday, May 27, 2014

Wilcoxon Signed-Rank Test in 8 Steps as a Paired t-Test Alternative

This is one of the following seven articles on Paired (2-Sample Dependent) t-Tests in Excel

Paired t-Test in 4 Steps in Excel 2010 and Excel 2013

Excel Normality Testing of Paired t-Test Data

Paired t-Test Excel Calculations, Formulas, and Tools

Paired t-Test – Effect Size in Excel 2010, and Excel 2013

Paired t-Test – Test Power With G-Power Utility

Wilcoxon Signed-Rank Test in 8 Steps As a Paired t-Test Alternative

Sign Test in Excel As A Paired t-Test Alternative

 

Wilcoxon Signed-Rank

Test in 8 Steps in Excel as

a Paired t-Test Alternative

The Wilcoxon Signed-Rank Test is an alternative to the paired t-Test when sample size is small (number of pairs = n < 30) and normality cannot be verified for the difference sample data or the population from which the difference sample was taken.

The Wilcoxon Signed-Rank Test calculates the difference between each data point in the difference sample and the Constant from the t-Test’s Null Hypothesis (0 in this case). The absolute values of each difference and ranked and then assigned the sign (positive or negative) that the difference originally had. These signed ranks are summed up to create the Test Statistic W.

Test Statistic W will be approximately normally distributed if the required assumptions are met for this test. The Test Statistic’s z Score can then be calculated and compared with the Critical z value. The decision whether or not to reject the test’s Null Hypothesis is made based on the results of this comparison.

The Null Hypothesis for this test states that the median difference equals the Constant, i.e. H0: Population Median Difference = Constant. This is very similar to the Null Hypothesis of the one-sample t-Test which states that the population median difference is equal to the Constant. The population is the set of differences from all possible before-and-after data pairs.

The Wilcoxon Signed-Rank Test is performed by implementing the following steps:

1) Calculate the difference between each difference data point and the Constant that the sample is being compared to, which is the Constant of 0 from the Null Hypothesis.

2) Record the sign (positive or negative) of each difference.

3) Sort the absolute values of difference data in ascending order.

4) Assign ranks to this data.

5) Attach the sign of each difference to its rank.

6) Sum up all of these signed ranks. This sum is the Test Statistic W.

7) Calculate the standard deviation, σw, for these signed ranks.

8) The Test Statistic W will be approximately normally distributed if the required assumptions for this test are met. Calculate the z Score for this variable W.

9) Compare the z Score of W with the Critical z Value for the given alpha and number of tails in the test. If the z Score is further from the standardized mean of zero than the Critical z Value, the Null Hypothesis can be rejected. The Null Hypothesis states that the population’s median is equal to the Constant from the Null Hypothesis.

Performing the Wilcoxon Signed Rank Test on the data is the example in this section is done as follows:ep 1) Calculate the Difference Between Each Sample Data Point and the Constant to Which the Sample Is Being Compared.

The original Null Hypothesis from the paired t-Test stated that the mean difference between all before-and-after data pairs in the entire population is equal to 0. The Null Hypothesis for this test was as follows:

H0: x_bardiff = Constant =0

The x_bardiff sample is created as follows:

paired t-test, t-test, t test, nonparametric testing, wilcoxon, excel, excel 2010, excel 2013, statistics,non-parametric,parametric,paired t test,signed rank,signed-rank
(Click Image To See Larger Version)

The Wilcoxon Signed-Rank Test calculates the difference between each data point in the difference sample and the Constant from the t-Test’s Null Hypothesis (0 in this case). That final difference sample is created as follows:

paired t-test, t-test, t test, nonparametric testing, wilcoxon, excel, excel 2010, excel 2013, statistics,non-parametric,parametric,paired t test,signed rank,signed-rank
(Click Image To See Larger Version)

 

Step 2) Create the Null and Alternative Hypotheses.

The one-sample t-Test attempts to determine whether the mean difference between all possible pairs of before-and-after data is equal to 0.

The Wilcoxon Signed-Rank Test attempts to determine whether the median difference between all possible pairs of before-and-after data is equal to 0. The Null Hypothesis for this would be stated as follows:

H0: Median_Difference = Constant = 0

The Alternate Hypothesis is always in inequality and states that the two items being compared are different. This hypothesis test is trying to determine whether there has been a reduction in clerical errors, i.e., the After measurements are smaller than the Before measurements. If there has been a reduction in clerical errors, the median difference will be less than 0.

The Alternative Hypothesis for this Wilcoxon Signed-Rank Test will therefore be stated as follows:

H1: Median_Difference < Constant = 0

H1: Median_Difference < 0

 

Step 3) Evaluate Whether the Test’s Required Conditions Have Been Met

The Wilcoxon Signed-Rank Test has the following requirements:

a) Data are ratio or interval but not categorical (nominal or ordinal). This is the case here.

b) Sample size (the number of data pairs) is at least 10. This is the case here.

c) Data of the Difference sample are distributed about a median with reasonable symmetry. Test Statistic W will not be normally distributed unless this assumption is met.

The following Excel-generated histogram shows that the difference data are distributed symmetrically about their median of -4. The symmetry about the median of -4 is not perfect but, given the small sample size, is reasonable enough to proceed with this test:

paired t-test, t-test, t test, nonparametric testing, wilcoxon, excel, excel 2010, excel 2013, statistics, non-parametric, parametric, paired t test, signed rank, signed-rank(Click Image To See Larger Version)

This histogram and the sample’s median were generated in Excel as follows:

paired t-test, t-test, t test, nonparametric testing, wilcoxon, excel, excel 2010, excel 2013, statistics, non-parametric, parametric, paired t test, signed rank, signed-rank(Click Image To See Larger Version)

 

Step 4 – Record the Sign of Each Difference

Place a “+1” and “-1” next to each non-zero difference. This can be automatically generated with an If-Then-Else statement as follows:

paired t-test, t-test, t test, nonparametric testing, wilcoxon, excel, excel 2010, excel 2013, statistics, non-parametric, parametric, paired t test, signed rank, signed-rank(Click Image To See Larger Version)

Placing a plus sign (+) next to a number automatically requires a custom number format available from the Format Cell dialogue box. One custom format that will work is the following: “+”#:”-“# . This is demonstrated in following Excel screen shot:

paired t-test, t-test, t test, nonparametric testing, wilcoxon, excel, excel 2010, excel 2013, statistics, non-parametric, parametric, paired t test, signed rank, signed-rank(Click Image To See Larger Version)

 

Step 5 – Sort the Absolute Values of the Differences While Retaining the Sign Associated to Each Difference

Sort both columns based upon column of difference absolute values.

paired t-test, t-test, t test, nonparametric testing, wilcoxon, excel, excel 2010, excel 2013, statistics, non-parametric, parametric, paired t test, signed rank, signed-rank
(Click Image To See Larger Version)

 

Step 6 –Rank the Absolute Values, Attach the Signs, and Sum up the Signed Ranks to Create Test Statistic W

The absolute values are ranked in ascending order starting with a rank of 1. Absolute values that are tied area assigned the average rank of the tied values. For example, the first three absolute values are 2. Each of these three absolute values would be assigned a rank of 2, which is equal to the average rank of all three, i.e., (1 + 2 + 3) / 3 = 2.

Test Statistic W is equal to the sum of all signed ranks.

paired t-test, t-test, t test, nonparametric testing, wilcoxon, excel, excel 2010, excel 2013, statistics, non-parametric, parametric, paired t test, signed rank, signed-rank(Click Image To See Larger Version)

 

A Quick and Easy Way To Create the Rankings

Rankings can be quickly and automatically created using the RANK.AVG() formula as is done in the following image. Cell H19 contains the following formula:

=IF(ISNUMBER(G619),RANK.AVG(G619,$G$619:$G$688,1),””)

This formula creates a ranking for the value in cell G619 as part of the data group in G619 to G688. This correctly assigns ranks to tied values.

paired t-test, t-test, t test, nonparametric testing, wilcoxon, excel, excel 2010, excel 2013, statistics, non-parametric, parametric, paired t test, signed rank, signed-rank

 

Step 7 – Calculate the z Score of W

The distribution of Test Statistic W can be approximated by the normal distribution if all of the required assumptions for this test are met. The difference data consists of more than 10 points of ratio data that are reasonably symmetrical about their median. The assumptions are met for this Wilcoxon Signed-Rank Test.

The standard deviation of W, σW, is calculated as follows:

σW = SQRT[ n(n + 1)(2n + 1)/6 ] = 42.25

z Score = ( W – Constant – 0.5) / σW

z Score = ( -83 – 0 – 0.5) / 42.25 = -1.98

The constant is the Constant from the Null Hypothesis for this test, which is the following:

H0: Median_Difference = Constant = 0

The z Score must include a 0.5 correction for continuity because W assumes whole integer values (except in the event of a tie of ranks).

 

Step 8 – Reject or Fail to Reject the Null Hypothesis Based Upon a Comparison Between the z Score and the Critical z Value

Given that α = 0.05 and this is a two-tailed test, the Critical z Value is calculated as follows:

Z Criticalα=0.05,One-Tailed, Left_Tail = NORM.S.INV(α) = NORM.S.INV(0.05)

Z Criticalα=0.05, One-Tailed, Left_Tail = -1.64485

The Null Hypothesis is rejected if the z Score is further from the standardized mean of zero than the Critical z Values. This is the case here since the z Score (-1.98) is further from the standardized mean of zero than the Critical z Values (-1.64485). this information is shown in the Excel-generated graph as follows:

paired t-test, t-test, t test, nonparametric testing, wilcoxon, excel, excel 2010, excel 2013, statistics, non-parametric, parametric, paired t test, signed rank, signed-rank(Click Image To See Larger Version)

The Wilcoxon Signed-Rank Test detects that the median difference between the before-and-after data is significant at an alpha level of 0.05.

The results of this Wilcoxon Signed-Rank Test were very similar to the results of the original paired t-Test in which the Null Hypothesis was rejected because the t Value (-2.159) was further from the standardized mean of zero than the Critical t Value (-1.76).

The results of the original t-Test are shown as follows:

paired t-test, t-test, t test, nonparametric testing, wilcoxon, excel, excel 2010, excel 2013, statistics, non-parametric, parametric, paired t test, signed rank, signed-rank(Click Image To See Larger Version)

The Paired t-Test detects that the mean difference between the before-and-after data is significant at an alpha level of 0.05.

 

Excel Master Series Blog Directory

Statistical Topics and Articles In Each Topic

 

No comments:

Post a Comment