Description Usage Arguments Details Value Author(s) See Also Examples
This function provides linear-hypothesis testing and multiple comparisons for group means of curve parameters based on the multcomp package.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | ## S4 method for signature 'MOPMX'
opm_mcp(object, model, linfct = 1L,
m.type = "glm", rhs = 0, alternative = "two.sided", glht.args = list(),
ops = "+", output = "mcp", sep = opm_opt("comb.value.join"), ...)
## S4 method for signature 'OPMS'
opm_mcp(object, model, linfct = 1L,
m.type = "glm", rhs = 0, alternative = "two.sided", glht.args = list(),
ops = "+", output = "mcp", sep = opm_opt("comb.value.join"), ...)
## S4 method for signature 'data.frame'
opm_mcp(object, model, linfct = 1L,
m.type = c("glm", "lm", "aov"), rhs = 0, alternative = "two.sided",
glht.args = list(), ops = "+",
output = c("mcp", "data", "model", "linfct", "contrast"),
sep = opm_opt("comb.value.join"), split.at = param_names("split.at"))
|
object |
Either an |
model |
A model formula, or a character vector or a
list containing the names of factors to be included in
the model for fitting. In order to join two or more
metadata-variables into one factor use pseudo-function
If If the |
linfct |
A specification of the linear hypotheses to
be tested analogously to
After the conversions, if any, this argument is passed
to If the |
m.type |
Character scalar indicating which of the following model types to use in model fitting: glm, aov or lm. See the eponymous functions in the stats package for details. |
rhs |
Numeric vector passed to |
alternative |
Character scalar also passed to that
function (but only if |
glht.args |
List of additional arguments for the
multiple comparison procedure passed to |
ops |
Character vector. |
output |
Character scalar determining the main output mode. See below under ‘Value’. |
split.at |
Character vector. See
|
sep |
Character scalar (comprising a single
character) passed to |
... |
Optional arguments passed to
|
This function internally reshapes the data in
object
into a ‘flat’ data frame the
structure of which is described under ‘value’. In
the default output
mode, glht
from the
multcomp package is applied to this data frame.
This causes (general linear) models and, by indicating a
contrast type, user-defined simultaneous multiple testing
procedures to be inferred.
Since either the user or this function itself makes use
of mcp
, we refer to the ‘Details’ section
of the glht
function. The mcp
function must
be used with care when defining parameters of interest in
two-way ANOVA or ANCOVA models. The
definition of treatment differences might be
problem-specific. An automated determination of the
parameters of interest would be impossible and thus only
comparisons for the main effects (ignoring covariates and
interactions) would be generated and a warning issued.
The kind of object returned by this function are
determined by the output
argument:
The default. An object of class glht
as
the result of the multiple comparison of means. Methods
for print
, summary
, confint
,
coef
and vcov
are available for this class.
See glht
in the multcomp package for
details.
Reshaped (‘flattened’) data
frame of the class OPM_MCP_OUT
. It contains
one column for the measured values, one factorial
variable determining the well, one factorial variable for
the curve parameter (see param_names
) and
additional factorial variables selected by model
as factors. The column names are converted to syntactical
names. Such a data frame might be of use for
model-building approaches not covered by this function.
The model
argument after the
conversions conducted by opm_mcp
, if any.
The linfct
argument after the
conversions conducted by opm_mcp
, if any.
A list of contrast matrices as specified
by model
and linfct
. As these matrices
would be guaranteed to fit to object
, they could
serve as template matrices to be further specified by the
user. Note that this only works if linfct
either
is an object of class mcp
or convertible to such
an object, and if its values are character scalars that
can be passed as type
argument to contrMat
from the multcomp package.
Lea A.I. Vaas, Markus Goeker
multcomp::glht multcomp::contrMat stats::lm stats::formula
Other multcomp-functions: annotated
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 | # helper function for plotting with better suitable margins
plot_with_margin <- function(x, mar, ...) {
old.mar <- par(mar = mar)
on.exit(par(old.mar)) # tidy up
plot(x, ...)
}
do.plot <- FALSE # change this to see the plots
## OPMS method
# return the intermediary data frame, do not conduct statistical tests
head(x <- opm_mcp(vaas_4, model = list("Species", "Strain"),
output = "data"))
stopifnot(is.data.frame(x), dim(x) == c(384, 5))
# watch the converted 'model' argument
(x <- opm_mcp(vaas_4, model = list("Species", "Strain"),
output = "model"))
stopifnot(inherits(x, "formula")) # left side is set automatically
# watch the converted 'linfct' argument
(x <- opm_mcp(vaas_4, model = list("Species", "Strain"),
linfct = c(Dunnett = 1), output = "linfct"))
stopifnot(inherits(x, "mcp"))
# create a template contrast matrix
(x <- opm_mcp(vaas_4, model = list("Species", "Strain"),
linfct = c(Dunnett = 1), output = "contrast"))
stopifnot(is.list(x), sapply(x, inherits, "contrMat"),
names(x) == "Species") # the selection is as specified by 'linfct'
# comparison using specified model comparing 'Species' pooled over
# complete plates
(x <- opm_mcp(vaas_4, model = list("Species"), m.type = "lm",
linfct = c(Dunnett = 1))) # refers to 'Species'
stopifnot(inherits(x, "glht"), length(coef(x)) == 1)
if (do.plot)
plot_with_margin(x, c(3, 20, 3, 2), main = "Species")
# comparison of only A01 - A04 against each other, Tukey style
# note that the left side of the model is set automatically
(x <- opm_mcp(vaas_4[, , 1:4],
model = ~ Well + Species, m.type = "lm",
linfct = c(Tukey = 1))) # the number refers to 'Well'
stopifnot(inherits(x, "glht"), length(coef(x)) == 6)
if (do.plot)
plot_with_margin(x, c(3, 18, 3, 2), main = "Tukey, A01 - A04")
# Dunnett-type comparison of selected wells
(x <- opm_mcp(vaas_4[, , 1:4], model = ~ Well,
m.type = "lm", linfct = c(Dunnett = 1)))
stopifnot(inherits(x, "glht"), length(coef(x)) == 3)
if (do.plot)
plot_with_margin(x, c(3, 20, 3, 2), main = "Dunnett, A01 vs. A02 - A04")
# by default 'Dunnett' uses first level as reference
# Dunnett-type comparison with selected control-group
(x <- opm_mcp(vaas_4[, , 1:5], output = "mcp", model = ~ Well,
linfct = c(`Dunnett.A05 (D-Cellobiose)` = 1)))
if (do.plot)
plot_with_margin(x, c(3, 20, 3, 2), main = "Dunnett, vs. A05")
# manually defined contrast matrix
(contr <- opm_mcp(vaas_4[, , 1:4], linfct = c(Tukey = 1),
model = ~ Well, output = "contrast")) # create template, Tukey style
contr <- contr$Well[c(1:3, 6), ] # select comparisons of interest
(x <- opm_mcp(vaas_4[, , 1:4],
model = ~ Well, m.type = "lm", linfct = contr)) # run tests
if (do.plot)
plot_with_margin(x, c(3, 20, 3, 2), main = "My own contrasts")
# joining of selected metadata using pseudofunction J
(x <- opm_mcp(vaas_4[, , 1:4], model = ~ J(Well + Species),
linfct = c(Dunnett = 1), full = FALSE)) # use short well names
if (do.plot)
plot_with_margin(x, c(3, 22, 3, 2), main = "Dunnett, Well/Species joined")
# comparing wells pairwise regarding the tested species
(x <- opm_mcp(vaas_4[, , 1:4], model = ~ J(Well + Species),
linfct = c(Pairs.Well = 1), full = FALSE)) # use short well names
if (do.plot)
plot_with_margin(x, c(3, 22, 3, 2),
main = "Wells compared between species")
# i.e. 'Pairs.Well' means 'Pairs' type of comparison for each 'Well'
# separately within a joined factor (the first one in 'model', hence
# 'c(Pairs.Well = 1)', with '1' referring to the elements of 'model').
# pairwise comparison of Species regarding the tested strains
xx <- c(vaas_4, vaas_4) # temporary test data
(x <- opm_mcp(xx[, , 1:4], model = ~ J(Strain + Species),
linfct = c(Pairs.Species = 1), full = FALSE)) # use short well names
if (do.plot)
plot_with_margin(x, c(3, 22, 3, 2),
main = "Strains compared within species")
# i.e. 'Pairs.Species' means 'Pairs' type of comparison for each 'Species'
# separately within a joined factor (the first one in 'model', hence
# 'c(Pairs.Species = 1)', with '1' referring to the elements of 'model').
## one could check the number of calculated tests as follows:
#if (nrow(confint(result)$confint) > 20L)
# warning("number of performed comparisons exceeds 20")
## data-frame method (usually unnecessary to directly apply it)
x <- extract(vaas_4, as.labels = list("Species", "Strain"), subset = "A",
dataframe = TRUE)
# without the tests, returning the converted data frame
head(y <- opm_mcp(x, output = "data", model = list("Species", "Strain")))
stopifnot(is.data.frame(y), dim(y) == c(384, 5)) # same result as above
# now with conducting the tests
(y <- opm_mcp(x, model = "Species", m.type = "lm",
linfct = c(Dunnett = 1)))
stopifnot(inherits(y, "glht"), length(coef(y)) == 1)
if (do.plot)
plot_with_margin(y, c(3, 20, 3, 2), main = "Species (from data frame)")
# testing for subsets of object
(y <- opm_mcp(subset(x, x$Species == "Escherichia coli"),
linfct = c(Dunnett = 1), model = "Strain", m.type = "lm"))
stopifnot(inherits(y, "glht"), length(coef(y)) == 1)
if (do.plot)
plot_with_margin(y, c(3, 15, 3, 2), main = "Dunnett (from data frame)")
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.