pairwiseTest {pairwiseCI} | R Documentation |
Wrapper to calculate unadjusted p-values for pairwise comparisons
Description
Calculation of raw p-values for pairwise comparisons of several groups. The data can be split by additional factors. Any test function can be used, that takes two samples x,y as input and returns a list containing the p.value in an element named p.value. The output of this function might be further processed using p.adjust in order to adjust for multiple comparisons.
Usage
pairwiseTest(formula, data, by = NULL,
method = "t.test", control = NULL, ...)
Arguments
formula |
a formula specifiying the response and the factor variable: response ~ factor |
data |
a data frame, containing the variables specified in formula |
by |
optional vector of character strings, defining factors by which to split the data set. Then, pairwise comparisons are performed separately for each level of the specified factors. |
method |
character string, giving the name of the function, which shall be used to calculate local p-values. Any function, taking two vectors x, and y as first arguments and returning a list with the p.value in a list element named p.value can be specified. |
control |
optional character string, defining the name of a control group. Must be one of the levels of the factor variable defined in formula. By default control=NULL, then all pairwise comparisons between the levels of the factor variable are computed. |
... |
Arguments to be passed the function defined in method |
Details
This function splits the response variable according to the factor(s) specified in by, and within each subset according to the grouping variable specified in formula. The function specified in method is called to calculate a p.value for all pairwise comparisons of between the subsets, within each level of by. The p-values are NOT adjusted for multiple hypothesis testing.
For binomial proportions, only "Prop.test" can be specified in the argument method; For continous variables, any function can be specified, which takes x and y as first arguments, and returns a list containing a list containing the appropriate p-value in the element named p.value (as do the functions of class "htest"). See the examples for details.
Value
A named list with elements
byout |
a list, containing the output of pairwiseTestint for each level of by, i.e. a data.frame containing with columns p.value,compnames groupx, groupy |
bynames |
a character vector containing the names of the levels of the factors specified in by |
method |
a character string, name of the function used |
control |
a character string |
by |
vector of character strings, same as argument by |
... |
further arguments that were passed to FUN |
Author(s)
Frank Schaarschmidt
See Also
You can use summary.pairwiseTest
to calculate multiplicity adjusted p-values from the output of pairwiseTest.
The following methods provide multiplicity adjusted p-values for various situations:
pairwise.t.test
, pairwise.prop.test
, \link{p.adjust},
summary.glht(multcomp), simtest.ratio(mratios)
Examples
#######################################################
# The rooting example:
# Calculate confidence intervals for the
# difference of proportions between the 3 doses of IBA,
# separately for 4 combinations of "Age" and "Position".
# Note: we pool over Rep in that way. Whether this makes
# sense or not, is decision of the user.
data(rooting)
# Pairwise Chi-square tests:
aproots<-pairwiseTest(cbind(root, noroot) ~ IBA,
data=rooting, by=c("Age", "Position"), method="Prop.test")
aproots
# With Holm adjustment for multiple hypotheses testing:
summary(aproots, p.adjust.method="holm")
#########################################################
data(Oats)
apc <- pairwiseTest(yield ~ nitro, data=Oats,
by="Variety", method="wilcox.test")
apc
summary(apc)
summary(apc, p.adjust.method="holm")