Summary and Analysis of Extension Program Evaluation in R

Salvatore S. Mangiafico

One-sample Wilcoxon Signed-rank Test

One-sample tests are not used too often, but are useful to compare a set of values to a given default value.  For example, one might ask if a set of five-point Likert scores are significantly different from a “default” or “neutral” score of 3.  Another use might be to compare a current set of values to a previously published value.


Appropriate data

•  One-sample data

•  Data are ordinal, interval, or ratio

•  Data are relatively symmetrical about their median



•  Null hypothesis:  The distribution of the data set is symmetric about the default value.

•  Alternative hypothesis (two-sided): The distribution of the data set is not symmetric about the default value.



Reporting significant results as “Likert scores were significantly different from a neutral value of 3” is acceptable.


Notes on name of test

The names used for the one-sample Wilcoxon signed-rank test and similar tests can be confusing.  Occasionally the name “signed-rank test” will be used.  “Sign test” may also be used, although properly the sign test is a different test.  Both “signed-rank test” and “sign test” are sometimes used to refer to either one-sample or two-sample tests.


The best advice is to use a name specific to the test being used.


Other notes and alternative tests

Caution should be used when using this test if data contain outliers or unsymmetrical data. 


If data are not symmetrical, the sign test can be used as an alternative.  The sign test is described in the next chapter.


Packages used in this chapter


The packages used in this chapter include:

•  psych

•  FSA



The following commands will install these packages if they are not already installed:



One-sample Wilcoxon signed-rank test example


This example will re-visit the Maggie Simpson data from the Descriptive Statistics for Likert Data chapter. 


The example answers the question, “Are Maggie’s scores significantly different from a ‘neutral’ score of 3?”


The test will be conducted with the wilcox.test function, which produces a p-value for the hypothesis, as well a pseudo-median and confidence interval.


Note that the bar plot shows that the data are relatively symmetrical in distribution, suggesting that the one-sample Wilcoxon test will be appropriate.


Input =("
  Speaker          Rater  Likert
 'Maggie Simpson'   1         3
 'Maggie Simpson'   2         4
 'Maggie Simpson'   3         5
 'Maggie Simpson'   4         4
 'Maggie Simpson'   5         4
 'Maggie Simpson'   6         4
 'Maggie Simpson'   7         4
 'Maggie Simpson'   8         3
 'Maggie Simpson'   9         2
 'Maggie Simpson'  10         5     

Data = read.table(textConnection(Input),header=TRUE)

### Create a new variable which is the likert scores as an ordered factor

Data$Likert.f = factor(Data$Likert,
                       ordered = TRUE)

###  Check the data frame





### Remove unnecessary objects


Summarize data treating Likert scores as factors

xtabs( ~ Speaker + Likert.f,
       data = Data)

Speaker          2 3 4 5
  Maggie Simpson 1 2 5 2

XT = xtabs( ~ Speaker + Likert.f,
           data = Data)

           margin = 1)

Speaker            2   3   4   5
  Maggie Simpson 0.1 0.2 0.5 0.2

Bar plot


X = xtabs(~ Likert.f,

        col="dark gray",
        xlab="Maggie's Likert",


Summarize data treating Likert scores as numeric


Summarize(Likert ~ Speaker,                                                     

         Speaker  n mean    sd min   Q1 median Q3 max percZero
1 Maggie Simpson 10  3.8 0.919   2 3.25      4  4   5        0

One-sample Wilcoxon signed-rank test

In the wilcox.test function, the mu option indicates the value of the default value to compare to.  In this example Data$Likert is the one-sample set of values on which to conduct the test.  For the meaning of other options, see ?wilcox.test.


Wilcoxon signed rank test with continuity correction

V = 32.5, p-value = 0.04007

alternative hypothesis: true location is not equal to 3

   ### Note p-value in the output above    

   ### You will get the "cannot compute exact p-value with ties" error    
   ###   You can ignore this, or use the exact=FALSE option.

95 percent confidence interval:
 3.000044 4.500083

sample estimates:


   ### Note that the output will also produce a pseudo-median value
   ###   and a confidence interval if the conf.int=TRUE option is used.

Exercises I

1. Considering Maggie Simpson’s data,

What was her median score?

What were the first and third quartiles for her scores?


Are the data reasonably symmetric about their median, or should another test be used?


According to the one-sample Wilcoxon signed-rank test, is her median score significantly different from a neutral score of 3?

Is the confidence interval output from the test useful in answering the previous question?


Overall, how would you summarize her results?


Do these results reflect what you would expect from looking at the bar plot?

2. Brian Griffin wants to assess the education level of students in his course on creative writing for adults.  He wants to know the median education level of his class, and if the education level of his class is different from the typical Bachelor’s level.


Brian used the following table to code his data.

Code   Abbreviation   Level

1      < HS           Less than high school
2        HS           High school
3        BA           Bachelor’s
4        MA           Master’s
5        PhD          Doctorate

The following are his course data.


Instructor       Student  Education
'Brian Griffin'  a        3
'Brian Griffin'  b        2
'Brian Griffin'  c        3
'Brian Griffin'  d        3
'Brian Griffin'  e        3
'Brian Griffin'  f        3
'Brian Griffin'  g        4
'Brian Griffin'  h        5
'Brian Griffin'  i        3
'Brian Griffin'  j        4
'Brian Griffin'  k        3
'Brian Griffin'  l        2

For each of the following, answer the question, and show the output from the analyses you used to answer the question.

What was the median education level?  (Be sure to report the education level, not just the numeric code!)


Are the data reasonably symmetric about their median, or should another test be used?


According to the one-sample Wilcoxon signed-rank test, is the median education level significantly different from a typical level of Bachelor’s?

Is the confidence interval output from the test useful in answering the previous question?


Plot Brian’s data in a way that helps you visualize the data.  Do the results reflect what you would expect from looking at the plot?