permutationTestMeans(data, treatment, data2, B = 999,
alternative = "two.sided",
ratio = F,
paired = F, group = NULL,
combine = NULL, combineGroup = F,
combinationFunction = combinePValues.Fisher,
seed = .Random.seed, diffMeans = T,
label, statisticNames)
data.
If
data is a data frame and the name of
treatment is a column
in
data, then
treatment is extracted from the data frame.
This must have two unique values, which determine two samples to
be compared.
One of
treatment or
data2 (but not both) must be used.
data. Observations in
data are taken
to be one sample, and those in
data2 are taken to be the other. If
data2 is a matrix or data frame, it must have the same number of
columns, and column names, if any, as
data.
One of
treatment or
data2 (but not both) must be used.
B=999, p-values are multiples of 1/1000.
"two.sided",
"greater", or
"less" (may be abbreviated),
indicating the type
of hypotheses test to perform. This may be a vector with length equal
to the number of variables in
data.
FALSE (the default) then resample the
difference in means between the two samples; if
TRUE
then resample the ratio.
TRUE then observations are paired, and observations
within each pair are randomly permuted. This is equivalent
to supplying
group as a vector with a different value for each pair
of observations. If
paired is supplied then argument
group
is ignored.
data, for
stratified sampling or multiple-sample problems.
Random permutations are drawn separately for each group
(determined by unique values of this vector).
If
data is a data frame, this may be a variable in the data frame,
or expression involving such variables.
data is a data frame and the name of
group is a column
in
data, then
group is extracted from the data frame.
T, combine p-values for individual groups.
See return component
"group$combineGroup-p-values" below.
set.seed.
TRUE (the default) then the statistic calculated
is the difference in means between the two groups determined by
the
treatment argument. If
FALSE the statistic is the sum
of the first group. The p-values are the same either way.
permutationTestMeans
which inherits from
resamp. This has components
call,
observed,
replicates,
estimate,
B,
n,
dim.obs,
p-value,
parent.frame,
label (if supplied),
defaultLabel,
combined-p-value (only if p-values are combined),
group (only if sampling by
group),
seed.start, and
seed.end.
See help for
resamp.object for a description of most components.
Components particularly relevant are:
p, containing the difference in means
for the two samples determined by the
treatment vector, for the
original data.
B by
p, containing the differences
in means between the two samples in each permutation samples.
p rows and columns
"alternative" and
"p-value",
where
p is the number of variables (excluding
treatment and
group).
combine.
K rows and
p columns
(where
K is the number of groups).
p columns.
combineGroup=T: vector of length
p;
p-values for each variable obtained by a nonparametric combination
across the individual-group p-values for that variable.
This is more heavily influenced by the results in small groups
or results from groups with small standard deviations than is
the
"p-value" column in
estimate. This calculation is currently
slow.
permutationTestMeans
causes creation of the dataset
.Random.seed if it does
not already exist, otherwise its value is updated.
If
diffMeans=FALSE, then the
observed and
replicates
return components contain the sum of the first sample
(observations with
treatment==treatment[1])
rather than the difference between samples.
This does not affect p-values.
If
treatment and/or
group are extracted from
data, those
columns are deleted. Numerical or logical subscripts in
combine should refer to remaining columns of
data,
and the length of
alternative should match the number of remaining columns.
Pesarin, F. (2001),
Multivariate Permutation Tests with Applications to
Biostatistics: Nonparametric Combination Methodology,
Wiley, Chichester, UK.
(Describes nonparametric combination methodology.)
We wish to thank Dr. Luigi Salmaso for help designing and testing
this function.
More details on many arguments, see .
Combination of p-values for multivariate statistics, or across groups in the case of : , , , .
Print, summarize, plot: , , , ,
Description of a "permutationTestMeans" object, extract parts: , , , .
Modify a "permutationTestMeans" object: .
For an annotated list of functions in the package, including other high-level resampling functions, see: .
set.seed(0)
x <- matrix(rnorm(15*3), 15)
treatment <- rep(1:2, length=15)
result <- permutationTestMeans(x, treatment = treatment, seed=1)
result
summary(result)
plot(result)
# two combinations
update(result, combine = list(1:3, 1:2))
# three groups
update(result, group = rep(c("a","b","c"), each=5), combineGroup = T)
# Example using two sets of data instead of treatment vector
y <- x + rnorm(length(x))
permutationTestMeans(x, data2=y)
# Paired permutation test
permutationTestMeans(x, data2=y, paired = T)