The one-sample sign test compares the number of observations greater than or less than the default value without accounting for the magnitude of the difference between each observation and the default value. The test is similar in purpose to the one-sample Wilcoxon signed-rank test, but looks specifically at the median value, and is not affected by the distribution of the data.
The test is conducted with functions in the DescTools package, the nonpar package, or the BSDA package. These functions produce a p-value for the hypothesis, as well as the median and confidence interval of the median for the data.
Appropriate data
• One-sample data
• Data are ordinal, interval, or ratio
Hypotheses
• Null hypothesis: The median of the population from which the sample was drawn is equal to the default value.
• Alternative hypothesis (two-sided): The median of the population from which the sample was drawn is not equal to the default value.
Interpretation
Reporting significant results as e.g. “Likert scores were significantly different from a default value of 3” is acceptable. As is e.g. “Median Likert scores were significantly different from a default value of 3”
Packages used in this chapter
The packages used in this chapter include:
• BSDA
• DescTools
• rcompanion
• nonpar
The following commands will install these packages if they are not already installed:
if(!require(BSDA)){install.packages("BSDA")}
if(!require(DescTools)){install.packages("DescTools")}
if(!require(rcompanion)){install.packages("rcompanion")}
if(!require(nonpar)){install.packages("nonpar")}
One-sample sign test example
For appropriate plots and summary statistics, see the One-sample Wilcoxon Signed-rank Test chapter.
Data = read.table(header=TRUE, stringsAsFactors=TRUE, text="
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
")
### Check the data frame
library(psych)
headTail(Data)
str(Data)
summary(Data)
Sign test with the DescTools package
Note that Data$Likert is the one-sample data, and mu=3 indicates the default value to compare to.
library(DescTools)
SignTest(Data$Likert,
mu = 3)
One-sample Sign-Test
S = 7, number of differences = 8, p-value = 0.07031
### Note the p-value in the output above
alternative hypothesis: true median is not equal to 3
97.9 percent confidence interval:
3 5
sample estimates:
median of the differences
4
### Median value and confidence interval
Sign test with the nonpar package
Note that Data$Likert is the one-sample data, and m=3 indicates the default value to compare to. At the time of writing, it appears that the exact=FALSE option actually produces the exact test.
library(nonpar)
signtest(Data$Likert, m=3, conf.level=0.95, exact=FALSE)
Exact Sign Test
The p-value is 0.07032
The 95 % confidence interval is [ 2 , 4 ].
Sign test with the BSDA package
Note that Data$Likert is the one-sample data, and md=3 indicates the default value to compare to.
library(BSDA)
SIGN.test(Data$Likert,
md = 3)
One-sample Sign-Test
s = 7, p-value = 0.07031
alternative hypothesis: true median is not equal to 3
### Note the p-value in the output above
95 percent confidence interval:
3.000000 4.675556
sample estimates:
median of x
4
### Median value and confidence interval
Effect size statistics
One way to assess the effect size after a one-sample sign test is to use a dominance statistic. This statistic simply looks at the proportion of observations greater than the default median value minus the proportion of observations less than the default median value. A value of 1 would indicate that all observations are greater than the default median, and a value of –1 would indicate that all observations are less than the default median. A value of 0 indicates that the number of observations greater than the default median are equal to the number that are less than the default median.
A VDA-like statistic can be calculated as Dominance / 2 + 0.5. This statistic varies from 0 to 1, with 0.5 being equivalent to a dominance value of 0.
Note that neither of these statistics take into account values tied to the default median value.
library(rcompanion)
oneSampleDominance(Data$Likert, mu=3)
n Median mu Less Equal Greater Dominance VDA
1 10 4 3 0.1 0.2 0.7 0.6 0.8
oneSampleDominance(Data$Likert, mu=3, ci=TRUE)
n Median mu Less Equal
Greater Dominance lower.ci upper.ci VDA lower.vda.ci upper.vda.ci
1 10 4 3 0.1 0.2 0.7 0.6 0.2 0.9 0.8
0.6 0.95
Manual calculations
Likert = c(3, 4, 5, 4, 4, 4, 4, 3, 2, 5)
Greater = sum(Likert > 3)
NotMedian = sum(Likert != 3)
binom.test(Greater, NotMedian)
Exact binomial test
number of successes = 7, number of trials = 8, p-value = 0.07031
MU = 3
N = length(Likert)
GreaterProp = sum(Likert > MU) / N
GreaterProp
0.7
LesserProp = sum(Likert < MU) / N
LesserProp
0.1
EqualProp = sum(Likert == MU) / N
EqualProp
0.2