You are on page 1of 2

SAMRIDH VIKHAS S | 20MIY0001 | MAT3011[ELA] | DA – 2

Objective:
To perform “Sign Test for Single Sample” using R Programming

Null Hypothesis[H0]:
The Median of the Sample is equal to 5

Alternative Hypothesis[H1]:
The Median of the sample is not equal to 5

Level of Significance = 5%

Code:
x = c(7,4,6,5,8,7,6,5,3,5,6,4,5,7,6,7,5,6,4,5,6,7,8,4,6,5)
med = 5
signs = sign(x-med)
positive = sum(signs==1)
negative = sum(signs==-1)
n = length(x)
k = min(positive,negative)
p = 2 * pbinom(k-1,n,0.5)
p

Output:
[1] 0.0005335212

Conclusion:
Since calculated p-value < 0.05, Do not Reject Null Hypothesis (H0). Therefore, the Median of the given
sample is equal to 5.
SAMRIDH VIKHAS S | 20MIY0001 | MAT3011[ELA] | DA – 2
Objective:
To perform “Paired Sign Test” using R Programming

Null Hypothesis[H0]:
There is no significant difference between the 2 samples

Alternative Hypothesis[H1]:
There is significant difference between the 2 samples

Level of Significance = 5%

Code:
a = c(80,85,90,75,88,92,79,83,87,81,86,84,78,82,89)

b = c(75,78,80,72,76,79,74,77,81,73,70,75,79,82,76)

signs = sign(a-b)

positive = sum(signs>0)

negative = sum(signs<0)

p = binom.test(min(positive,negative),n=positive+negative,alternative="two.sided")

Output:
Exact binomial test
data: min(positive, negative) and positive + negative
number of successes = 1, number of trials = 14, p-value = 0.001831
alternative hypothesis: true probability of success is not equal to 0.5
95 percent confidence interval:
0.001806781 0.338684490
sample estimates:
probability of success
0.07142857

Conclusion:
Since calculated p-value < 0.05, Do not Reject Null Hypothesis (H0). Therefore, There is no significant
difference between the 2 samples.

You might also like