IMSL C Stat Library
sign_test
Performs a sign test.
Synopsis
#include <imsls.h>
float imsls_f_sign_test (int n_observations, float x[], ..., 0)
The type double function is imsls_d_sign_test.
Required Arguments
int n_observations (Input)
Number of observations.
float x[] (Input)
Array of length n_observations containing the input data.
Return Value
Binomial probability of n_positive_deviations or more positive differences in n_observations  n_zero_deviation trials. Call this value probability. If no option is chosen, the null hypothesis is that the median equals 0.0.
Synopsis with Optional Arguments
#include <imsls.h>
float imsls_f_sign_test (int n_observations, float x[],
IMSLS_PERCENTAGE, float percentage,
IMSLS_PERCENTILE, float percentile,
IMSLS_N_POSITIVE_DEVIATIONS, int *n_positive_deviations,
IMSLS_N_ZERO_DEVIATIONS, int *n_zero_deviations,
0)
Optional Arguments
IMSLS_PERCENTAGE, float percentage (Input)
Value in the range (0, 1). Argument percentile is the 100 × percentage percentile of the population.
Default: percentage = 0.5
IMSLS_PERCENTILE, float percentile (Input)
Hypothesized percentile of the population from which x was drawn.
Default: percentile = 0.0
IMSLS_N_POSITIVE_DEVIATIONS, int *n_positive_deviations (Output)
Number of positive differences x[j  1]  percentile for j = 1, 2, n_observations.
IMSLS_N_ZERO_DEVIATIONS, int *n_zero_deviations (Output)
Number of zero differences (ties) x[j  1]  percentile for j = 1, 2, n_observations.
Description
Function imsls_f_sign_test tests hypotheses about the proportion p of a population that lies below a value q, where p corresponds to argument percentage and q corresponds to argument percentile. In continuous distributions, this can be a test that q is the 100 p-th percentile of the population from which x was obtained. To carry out testing, imsls_f_sign_test tallies the number of values above q in n_positive_deviations. The binomial probability of n_positive_deviations or more values above q is then computed using the proportion p and the sample size n_observations (adjusted for the missing observations and ties).
Hypothesis testing is performed as follows for the usual null and alternative hypotheses:
*H0: Pr(x  q p (the p-th quantile is at least q)
H1: Pr(x  q) < p
Reject H0 if probability is less than or equal to the significance level
*H0: Pr(x  q p (the p-th quantile is at least q)
H1: Pr(x  q) > p
Reject H0 if probability is greater than or equal to 1 minus the significance level
*H0: Pr (x = q= p (the p-th quantile is q)
H1: Pr((x  q) < p) or Pr((x  q) > p)
Reject H0 if probability is less than or equal to half the significance level or greater than or equal to 1 minus half the significance level
The assumptions are as follows:
1. They are independent and identically distributed.
2. Measurement scale is at least ordinal; i.e., an ordering less than, greater than, and equal to exists in the observations.
Many uses for the sign test are possible with various values of p and q. For example, to perform a matched sample test that the difference of the medians of y and z is 0.0, let p = 0.5, q = 0.0, and xi = yi  zi in matched observations y and z. To test that the median difference is c, let q = c.
Examples
Example 1
This example tests the hypothesis that at least 50 percent of a population is negative. Because 0.18 < 0.95, the null hypothesis at the 5-percent level of significance is not rejected.
 
#include <imsls.h>
 
int main ()
{
int n_observations = 19;
float probability;
float x[19] = {92.0, 139.0, -6.0, 10.0, 81.0, -11.0, 45.0,
-25.0, -4.0, 22.0, 2.0, 41.0, 13.0, 8.0, 33.0,
45.0, -33.0, -45.0, -12.0};
 
probability = imsls_f_sign_test(n_observations, x, 0);
printf("probability = %10.6f\n", probability);
}
Output
 
probability = 0.179642
Example 2
This example tests the null hypothesis that at least 75 percent of a population is negative. Because 0.923 < 0.95, the null hypothesis at the 5-percent level of significance is rejected.
 
#include <imsls.h>
#include <stdio.h>
 
int main ()
{
int n_observations = 19;
int n_positive_deviations, n_zero_deviations;
float probability;
float percentage = 0.75;
float percentile = 0.0;
 
float x[19] = {
92.0, 139.0, -6.0, 10.0, 81.0, -11.0, 45.0, -25.0, -4.0, 22.0,
2.0, 41.0, 13.0, 8.0, 33.0, 45.0, -33.0, -45.0, -12.0
};
 
probability = imsls_f_sign_test(n_observations, x,
IMSLS_PERCENTAGE, percentage,
IMSLS_PERCENTILE, percentile,
IMSLS_N_POSITIVE_DEVIATIONS, &n_positive_deviations,
IMSLS_N_ZERO_DEVIATIONS, &n_zero_deviations,
0);
 
printf("probability = %10.6f.\n", probability);
printf("Number of positive deviations is %d.\n",
n_positive_deviations);
printf("Number of ties is %d.\n", n_zero_deviations);
}
Output
 
probability = 0.922543.
Number of positive deviations is 12.
Number of ties is 0.