Test the hypothesis of zero median.

Generate the sample data.

The sampling distribution of `x`

is symmetric
with zero median.

Test the null hypothesis that `x`

comes
from a distribution with a median different from zero median.

p =
0.1078
h =
0
stats =
zval: NaN
sign: 17

At the default 5% significance level, the result `h`

=
0 indicates that `signtest`

fails to reject to the
null hypothesis of zero median. `signtest`

calculates
the *p*-value using the exact method, hence it
does not calculate `zval`

and returns it as a `NaN`

.

Test the hypothesis of zero median for the
difference between paired samples.

Generate the sample data.

The sampling distribution of the difference between `before`

and `after`

is
symmetric with zero median.

Test the null hypothesis that the difference of `before`

and `after`

has
zero median.

At the default 5% significance level, the value `h`

=
0 indicates that `signtest`

fails to reject to the
null hypothesis of zero median in the difference.

Test the hypothesis of zero median for the
difference between two paired samples using the exact and approximate
methods.

Generate the sample data.

ans =
8.4521 7.8047
11.6869 11.4094
4.2009 5.1133
9.1664 12.1655
8.0020 10.0300
5.3285 6.0153
6.6300 5.1235
8.0499 8.6737
18.0763 19.2164
14.7665 15.3380
5.2726 8.4187
15.7798 16.2093
8.8583 8.5575
7.2735 7.4783
8.8347 7.8894

Test the hypothesis that `x`

– `y`

has
zero median.

p =
0.3018
h =
0
stats =
zval: NaN
sign: 5

At the default 5% significance level, the value `h`

=
0 indicates that the test fails to reject the null hypothesis of zero
median in the difference.

Repeat the test using the approximate method.

p =
0.3017
h =
0
stats =
zval: -1.0328
sign: 5

The approximate *p*-value, which `signtest`

obtains
using the z-statistic, is really close to the exact *p*-value.

Perform a left-sided sign test for large samples.

Navigate to a folder containing sample data.

Load the sample data.

Test the null hypothesis that the median of the grade
differences before and after the tutoring program is 0 against the
alternate that it is less than 0.

p =
0.0013
h =
1
stats =
zval: -3.0110
sign: 37

Because the sample size is large (greater than 100), `signtest`

uses
an approximate method to calculate the *p*-value
and also returns the value of the *z*-statistic.
The test rejects the null hypothesis that there is no difference between
the grade medians at the 5% significance level.

Test the hypothesis that the population median
is different from a specified value.

Load the sample data.

The data set has 15 observations for variables `gpa`

and `lsat`

.

Test the hypothesis that the median `lsat`

score
is higher than 570.

p =
0.0176
h =
1
stats =
zval: NaN
sign: 12

Both the *p*-value, 0.0176, and `h`

=
1 indicate that at the 5% significance level the test concludes in
favor of the alternate hypothesis.