Class SignTest
- All Implemented Interfaces:
Serializable,Cloneable
Class SignTest tests hypotheses about the proportion
p of a population that lies below a value q, where p
corresponds to percentage and q corresponds to
percentile in the setPercentage and
setPercentile methods, respectively. 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, SignTest
tallies the number of values above q in the number of positive
differences \(x[j-1]- {\rm percentile}\) for
\(j=1, 2, \ldots, {\rm x.length}\). The binomial
probability of the number of values above q in the number of positive
differences \(x[j-1]- {\rm percentile}\) for
\(j=1,2,\ldots,\ldots, {\rm x.length}\) or more
values above q is then computed using the proportion p and the
sample size in x (adjusted for the missing
observations and ties).
Hypothesis testing is performed as follows for the usual null and alternative hypotheses:
- \(H_0: Pr(x \leq q) \geq p\) (the p-th
quantile is at least q)
\(H_1: Pr(x \leq q) \lt p\)
Reject \(H_0\) if probability is less than or equal to the significance level - \(H_0: Pr(x \leq q) \leq p\) (the p-th quantile
is at least q)
\(H_1: Pr(x \leq q) \gt p\)
Reject \(H_0\) if probability is greater than or equal to 1 minus the significance level - \(H_0: Pr (x = q) = p\) (the p-th quantile is
q)
\(H_1: Pr((x \leq q) \lt p)\) or \(Pr((x \le q) \gt p)\)
Reject \(H_0\) 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:
- 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 \(x_i = y_i - z_i\) in matched observations y and z. To test that the median difference is c, let q = c.
- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionfinal doublecompute()Performs a sign test.intReturns the number of positive differences.intReturns the number of zero differences.voidsetPercentage(double percentage) Sets the percentage percentile of the population.voidsetPercentile(double percentile) Sets the hypothesized percentile of the population.
-
Constructor Details
-
SignTest
public SignTest(double[] x) Constructor forSignTest.- Parameters:
x- Adoublearray containing the data.
-
-
Method Details
-
compute
public final double compute()Performs a sign test.- Returns:
- A
doublescalar containing the Binomial probability ofgetNumPositiveDevor more positive differences inx.length- number of zero differences trials. Call this value probability. If using default values, the null hypothesis is that the median equals 0.0.
-
getNumPositiveDev
public int getNumPositiveDev()Returns the number of positive differences. Note that thecomputemethod must be invoked first before invoking this method. Otherwise, the return value is0.- Returns:
- An
intscalar containing the number of positive differencesx[j-1]-percentilefor j = 1, 2, ...,x.length.
-
getNumZeroDev
public int getNumZeroDev()Returns the number of zero differences. Note that thecomputemethod must be invoked first before invoking this method. Otherwise, the return value is0.- Returns:
- An
intscalar containing the number of zero differences (ties)x[j-1]-percentilefor j = 1, 2, ...,x.length.
-
setPercentile
public void setPercentile(double percentile) Sets the hypothesized percentile of the population.- Parameters:
percentile- Adoublescalar containing the hypothesized percentile of the population from whichxwas drawn. Default:percentile= 0.0
-
setPercentage
public void setPercentage(double percentage) Sets the percentage percentile of the population.- Parameters:
percentage- Adoublescalar containing the value in the range (0, 1).percentileis the 100 *percentagepercentile of the population. Default:percentage= 0.5.
-