Testing against Ordered Alternatives (Spearman Test)
Testing against Ordered Alternatives (Spearman Test)
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"),...)
Arguments
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 "x". Ignored with a warning if "x" is a list.
alternative: the alternative hypothesis. Defaults to "two.sided".
formula: a formula of the form response ~ group where response gives the data values and group a vector or factor of the corresponding groups.
data: an optional matrix or data frame (or similar: see model.frame) containing the variables in the formula formula. By default the variables are taken from environment(formula).
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 NAs. Defaults to getOption("na.action").
Returns
A list with class "htest" containing the following components:
method: a character string indicating what type of test was performed.
data.name: a character string giving the name(s) of the data.
statistic: the estimated quantile of the test statistic.
p.value: the p-value for the test.
parameter: the parameters of the test statistic, if any.
alternative: a character string describing the alternative hypothesis.
estimates: the estimates, if any.
null.value: the estimate under the null hypothesis, if any.
Details
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 Rij with the increasing order number 1≤i≤k of the treatment levels (Kloke and McKean 2015). More precisely, Rij 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 E1=(n1+1)/2. The following expected mid-value ranks are Ej=nj−1+(nj+1)/2 for 2≤j≤k. The corresponding number of tied values for the ith group is ni. # The sum of squared residuals is D2=∑i=1k∑j=1ni(Rij−Ei)2. Consequently, Spearman's rank correlation coefficient can be calculated as:
rS=(N3−N)−C6D2,
with
C=1/2−c=1∑r(tc3−tc)+1/2−i=1∑k(ni3−ni)
and tc the number of ties of the cth 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 rS≤0
is rejected and the alternative rS>0 is accepted if
rS(1−rS)(n−2)>tv,1−α,
with v=n−2 degree of freedom.
Note
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).