## S3 method for class 'matrix':
glht(model, linfct,
alternative = c("two.sided", "less", "greater"),
rhs = 0, ...)
## S3 method for class 'character':
glht(model, linfct, ...)
## S3 method for class 'expression':
glht(model, linfct, ...)
## S3 method for class 'mcp':
glht(model, linfct, ...)
mcp(...)modelparm in all
glht methods. For function mcp,
multiple comparisons are defined by
matrices ormodel with parameter estimates coef(model). The null hypothesis is specified by a linear function $K alternative equal to "two.sided" refers to
a null hypothesis $H_0: K \beta = m$, whereas
"less" corresponds to $H_0: K \beta \ge m$ and
"greater" refers to
$H_0: K \beta \le m$. The right hand side vector $m$ can be defined
via the rhs argument.
The generic method glht dispatches on its second argument
(linfct). There are three ways, and thus methods,
to specify linear functions to be tested:
1) The matrix of coefficients $K$ can be specified directly
via the linfct argument. In this case,
the number of columns of this matrix needs to correspond to the number of
parameters estimated by model. It is assumed that
appropriate coef and vcov methods are available
for model (modelparm deals with some exceptions).
2) A symbolic description,
either a character or expression vector passed to glht
via its linfct argument, can be used to define
the null hypothesis. A symbolic description must be interpretable as a valid
R expression consisting of both the left and right hand side
of a linear hypothesis.
Only the names of coef(beta) must be used as variable
names. The alternative is given by
the direction under the null hypothesis (= or ==
refer to "two.sided", <=< code=""> means
"greater" and >= indicates
"less"). Numeric vectors of length one
are valid values for the right hand side.
3) Multiple comparisons of means are defined by objects
of class mcp as returned by the mcp function.
For each factor, which is included in model
as independent variable,
a contrast matrix or a symbolic description of the contrasts
can be specified as arguments to mcp. A symbolic
description may be a character or expression
where the factor levels
are only used as variables names. In addition,
the type argument to the contrast generating function
contrMat may serve as a symbolic description of
contrasts as well.=<>
glht extracts the number of degrees of freedom
for models of class lm (via modelparm) and the
exact multivariate $t$ distribution is evaluated. For all other
models, results rely on the normal approximation. Alternatively, the
degrees of freedom to be used for the evaluation of multivariate
$t$ distributions can be given by the additional df argument to
modelparm specified via ....
glht methods return a specification of the null hypothesis
$H_0: K \beta = m$. The value of the linear function
$K coef method and
the corresponding covariance matrix is available from the
vcov method. Various simultaneous and univariate tests and
confidence intervals are available from summary.glht
and confint.glht methods, respectively.glht with print, summary,
confint, coef and vcov
methods being available.
### test of H_0: all regression coefficients are zero ### (ignore intercept)
### define coefficients of linear function directly K <- diag(length(coef(lmod)))[-1,] rownames(K) <- names(coef(lmod))[-1] K
### set up general linear hypothesis glht(lmod, linfct = K)
### alternatively, use a symbolic description ### instead of a matrix glht(lmod, linfct = c("Agriculture = 0", "Examination = 0", "Education = 0", "Catholic = 0", "Infant.Mortality = 0"))
### multiple comparison procedures ### set up a one-way ANOVA amod <- aov(breaks ~ tension, data = warpbreaks)
### set up all-pair comparisons for factor `tension' ### using a symbolic description (`type' argument ### to `contrMat()') glht(amod, linfct = mcp(tension = "Tukey"))
### alternatively, describe differences symbolically glht(amod, linfct = mcp(tension = c("M - L = 0", "H - L = 0", "H - M = 0")))
### alternatively, define contrast matrix directly contr <- rbind("M - L" = c(-1, 1, 0), "H - L" = c(-1, 0, 1), "H - M" = c(0, -1, 1)) glht(amod, linfct = mcp(tension = contr))
### alternatively, define linear function for coef(amod)
### instead of contrasts for `tension'
### (take model contrasts and intercept into account)
glht(amod, linfct = cbind(0, contr %*% contr.treatment(3)))