shanTest | R Documentation |
Performs the Shan-Young-Kang test for testing against ordered alternatives.
shanTest(x, ...)
## Default S3 method:
shanTest(x, g, alternative = c("greater", "less"), ...)
## S3 method for class 'formula'
shanTest(
formula,
data,
subset,
na.action,
alternative = c("greater", "less"),
...
)
x |
a numeric vector of data values, or a list of numeric data vectors. |
... |
further arguments to be passed to or from methods. |
g |
a vector or factor object giving the group for the
corresponding elements of |
alternative |
the alternative hypothesis.
Defaults to |
formula |
a formula of the form |
data |
an optional matrix or data frame (or similar: see
|
subset |
an optional vector specifying a subset of observations to be used. |
na.action |
a function which indicates what should happen when
the data contain |
The null hypothesis, H_0: \theta_1 = \theta_2 = \ldots = \theta_k
is tested against a simple order hypothesis,
H_\mathrm{A}: \theta_1 \le \theta_2 \le \ldots \le
\theta_k,~\theta_1 < \theta_k
.
Let R_{ij}
be the rank of X_{ij}
,
where X_{ij}
is jointly ranked
from \left\{1, 2, \ldots, N \right\}, ~~ N = \sum_{i=1}^k n_i
,
the the test statistic is
S = \sum_{i = 1}^{k-1} \sum_{j = i + 1}^k D_{ij},
with
D_{ij} = \sum_{l = 1}^{n_i} \sum_{m=1}^{n_j} \left(R_{jm} - R_{il} \right)~ \mathrm{I}\left(X_{jm} > X_{il} \right),
where
\mathrm{I}(u) = \left\{
\begin{array}{c}
1, \qquad \forall~ u > 0 \\
0, \qquad \forall~ u \le 0
\end{array}
\right.
.
The test statistic is asymptotically normal distributed:
z = \frac{S - \mu_{\mathrm{S}}}{\sqrt{s^2_{\mathrm{S}}}}
The p-values are estimated from the standard normal distribution.
A list with class "htest"
containing the following components:
a character string indicating what type of test was performed.
a character string giving the name(s) of the data.
the estimated quantile of the test statistic.
the p-value for the test.
the parameters of the test statistic, if any.
a character string describing the alternative hypothesis.
the estimates, if any.
the estimate under the null hypothesis, if any.
The variance estimation (see Theorem 2.1, Shan et al. 2014)
can become negative for certain combinations of N,~n_i,~k
\qquad (1 \le i \le k)
. In these cases the function will return
a warning and the returned p-value will be NaN
.
Factor labels for g
must be assigned in such a way,
that they can be increasingly ordered from zero-dose
control to the highest dose level, e.g. integers
{0, 1, 2, ..., k} or letters {a, b, c, ...}.
Otherwise the function may not select the correct values
for intended zero-dose control.
It is safer, to i) label the factor levels as given above,
and to ii) sort the data according to increasing dose-levels
prior to call the function (see order
, factor
).
Shan, G., Young, D., Kang, L. (2014) A New Powerful Nonparametric Rank Test for Ordered Alternative Problem. PLOS ONE 9, e112924. https://doi.org/10.1371/journal.pone.0112924
kruskalTest
and shirleyWilliamsTest
of the package PMCMRplus,
kruskal.test
of the library stats.
## Example from Sachs (1997, p. 402)
x <- c(106, 114, 116, 127, 145,
110, 125, 143, 148, 151,
136, 139, 149, 160, 174)
g <- gl(3,5)
levels(g) <- c("A", "B", "C")
## Chacko's test
chackoTest(x, g)
## Cuzick's test
cuzickTest(x, g)
## Johnson-Mehrotra test
johnsonTest(x, g)
## Jonckheere-Terpstra test
jonckheereTest(x, g)
## Le's test
leTest(x, g)
## Spearman type test
spearmanTest(x, g)
## Murakami's BWS trend test
bwsTrendTest(x, g)
## Fligner-Wolfe test
flignerWolfeTest(x, g)
## Shan-Young-Kang test
shanTest(x, g)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.