The IMSL_SIGNTEST function performs a sign test.
This routine requires an IDL Advanced Math and Stats license. For more information, contact your sales or technical support representative.
The IMSL_SIGNTEST function tests hypotheses about the proportion p of a population that lies below a value q, where p corresponds to keyword Percentage and q corresponds to keyword 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, IMSL_SIGNTEST tallies the number of values above q in N_Pos_Dev. The binomial probability of N_Pos_Dev or more values above q is then computed using the proportion p and the sample size N_ELEMENTS (x) (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:
- The Xi’s form a random sample; i.e., they are independent and identically distributed.
- 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.
x =[92, 139, -6, 10, 81, -11, 45, -25, -4, $
22, 2, 41, 13, 8, 33, 45, -33, -45, -12]
PRINT, 'Probability = ', IMSL_SIGNTEST(x)
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.
x =[92, 139, -6, 10, 81, -11, 45, -25, -4, $
22, 2, 41, 13, 8, 33, 45, -33, -45, -12]
probability = IMSL_SIGNTEST(x, Percentage = 0.75, $
Percentile = 0, N_Pos_Dev = np, N_Zero_Dev = nz)
PM, probability, Title = 'Probability'
PM, np, Title = 'Number of Positive Deviations'
PM, nz, Title = 'Number of Ties'
Probability
0.922543
Number of Positive Deviations
12
Number of Ties
0
Syntax
Result = IMSL_SIGNTEST(x [, /DOUBLE] [, N_POS_DEV=value] [, N_ZERO_DEV=value] [, PERCENTAGE=value] [, PERCENTILE=value])
Return Value
Binomial probability of N_Pos_Dev or more positive differences in N_ELEMENTS(x) – N_Zero_Dev trials. Call this value probability. If no option is chosen, the null hypothesis is that the median equals 0.0.
Arguments
X
One-dimensional array containing the input data.
Keywords
BETA
Named variable into which the constant used to ensure that the estimated covariance matrix has unbiased expectation (for a given mean vector) for a multivariate normal density is stored.
COV_EST
Two-dimensional array of size n_variables by n_variables containing the estimate of the covariance matrix. Keywords Mean_Est and Cov_Est must be used together.
DOUBLE (optional)
If present and nonzero, double precision is used.
N_POS_DEV (optional)
Number of positive differences x(j – 1) – Percentile, for j = 1, 2, ..., N_ELEMENTS(x).
N_ZERO_DEV (optional)
Number of zero differences (ties) x(j – 1) – Percentile, for j = 1, 2, ..., N_ELEMENTS(x).
PERCENTAGE (optional)
Scalar value in the range (0,1). Keyword Percentage is the 100 x Percentage percentile of the population. Default: 0.5
PERCENTILE (optional)
Hypothesized percentile of the population from which x was drawn. Default: Percentile = 0.0
Version History