spearmanTest | R Documentation |
Performs a Spearman type test for testing against ordered alternatives.
spearmanTest(x, ...)
## Default S3 method:
spearmanTest(x, g, alternative = c("two.sided", "greater", "less"), ...)
## S3 method for class 'formula'
spearmanTest(
formula,
data,
subset,
na.action,
alternative = c("two.sided", "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 |
A one factorial design for dose finding comprises an ordered factor,
.e. treatment with increasing treatment levels.
The basic idea is to correlate the ranks R_{ij}
with the increasing
order number 1 \le i \le k
of the treatment levels (Kloke and McKean 2015).
More precisely, R_{ij}
is correlated with the expected mid-value ranks
under the assumption of strictly increasing median responses.
Let the expected mid-value rank of the first group denote E_1 = \left(n_1 + 1\right)/2
.
The following expected mid-value ranks are
E_j = n_{j-1} + \left(n_j + 1 \right)/2
for 2 \le j \le k
.
The corresponding number of tied values for the i
th group is n_i
. #
The sum of squared residuals is
D^2 = \sum_{i=1}^k \sum_{j=1}^{n_i} \left(R_{ij} - E_i \right)^2
.
Consequently, Spearman's rank correlation coefficient can be calculated as:
r_\mathrm{S} = \frac{6 D^2}
{\left(N^3 - N\right)- C},
with
C = 1/2 - \sum_{c=1}^r \left(t_c^3 - t_c\right) +
1/2 - \sum_{i=1}^k \left(n_i^3 - n_i \right)
and t_c
the number of ties of the c
th group of ties.
Spearman's rank correlation coefficient can be tested for
significance with a t
-test.
For a one-tailed test the null hypothesis of r_\mathrm{S} \le 0
is rejected and the alternative r_\mathrm{S} > 0
is accepted if
r_\mathrm{S} \sqrt{\frac{\left(n-2\right)}{\left(1 - r_\mathrm{S}\right)}} > t_{v,1-\alpha},
with v = n - 2
degree of freedom.
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.
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
).
Kloke, J., McKean, J. W. (2015) Nonparametric statistical methods using R. Boca Raton, FL: Chapman & Hall/CRC.
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.