The two-sample sign test assesses the number of observations in one group that are greater than paired observations in the other group without accounting for the magnitude of the difference. The test is similar in purpose to the two-sample Wilcoxon signed-rank test, but looks specifically at the median value of differences (if the values are numeric), and is not affected by the distribution of the data.

The *SIGN.test* function in the *BSDA* package
requires the data to be separated into two variables, each of which is ordered
so that the first observation of each are paired, and so on. Information on
options for the function can be viewed with *?SIGN.test*. The *SignTest*
function in the *DescTools* package is similar.

For appropriate plots and summary statistics, see the *Two-sample
Paired Signed-rank Test* chapter.

##### Appropriate data

• Two-sample paired data. That is, one-way data with two groups only, where the observations are paired between groups.

• Dependent variable is ordinal, interval, or ratio.

• Independent variable is a factor with two levels. That is, two groups.

##### Hypotheses

• Null hypothesis: For numeric data, the median of the paired differences in the population from which the sample was drawn is equal to zero.

• Alternative hypothesis (two-sided): For numeric data, the median of the paired differences in the population from which the sample was drawn is not equal to zero.

##### Interpretation

Significant results can be reported as “There was a significant difference in values between group A and group B.”

### Packages used in this chapter

The packages used in this chapter include:

• psych

• BSDA

• DescTools

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

if(!require(psych)){install.packages("psych")}

if(!require(BSDA)){install.packages("BSDA")}

if(!require(DescTools)){install.packages("DescTools")}

### Sign test for paired two-sample data example

Input =("

Speaker Time Student Likert

Pooh 1 a 1

Pooh 1 b 4

Pooh 1 c 3

Pooh 1 d 3

Pooh 1 e 3

Pooh 1 f 3

Pooh 1 g 4

Pooh 1 h 3

Pooh 1 i 3

Pooh 1 j 3

Pooh 2 a 4

Pooh 2 b 5

Pooh 2 c 4

Pooh 2 d 5

Pooh 2 e 4

Pooh 2 f 5

Pooh 2 g 3

Pooh 2 h 4

Pooh 2 i 3

Pooh 2 j 4

")

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

### Check the data frame

library(psych)

headTail(Data)

str(Data)

summary(Data)

### Remove unnecessary objects

rm(Input)

#### Two-sample sign test with BSDA package

Time.1 = Data$Likert [Data$Time == 1]

Time.2 = Data$Likert [Data$Time == 2]

library(BSDA)

SIGN.test(x = Time.1,

y = Time.2,

alternative = "two.sided",

conf.level = 0.95)

Dependent-samples Sign-Test

S = 1, p-value = 0.03906

### p-value reported above

95 percent confidence interval:

-2.0000000 -0.3244444

sample estimates:

median of x-y

-1

### median of differences and confidence interval
of differences

#### Two-sample sign test with DescTools package

Time.1 = Data$Likert [Data$Time == 1]

Time.2 = Data$Likert [Data$Time == 2]

library(DescTools)

SignTest(x = Time.1,

y = Time.2)

Dependent-samples Sign-Test

S = 1, number of differences = 9, p-value = 0.03906

### p-value reported above

alternative hypothesis: true median difference is not equal to 0

97.9 percent confidence interval:

-2 0

sample estimates:

median of the differences

-1

### median of differences and confidence interval
of differences