glht-support: Support for 'multcomp::glht'

Description Usage Arguments Details Value Details Note Examples

Description

These functions and methods provide an interface between emmeans and the multcomp::glht function for simultaneous inference provided by the multcomp package.

Usage

1
2
3
4
5
6
emm(...)

as.glht(object, ...)

## S3 method for class 'emmGrid'
as.glht(object, ...)

Arguments

...

In emm, the specs, by, and contr arguments you would normally supply to emmeans. Only specs is required. Otherwise, arguments that are passed to other methods.

object

An object of class emmGrid or emm_list

Details

emm is meant to be called only from "glht" as its second (linfct) argument. It works similarly to multcomp::mcp, except with specs (and optionally by and contr arguments) provided as in a call to emmeans.

Value

emm returns an object of an intermediate class for which there is a multcomp::glht method.

as.glht returns an object of class glht or glht_list according to whether object is of class emmGrid or emm_list. See Details below for more on glht_lists.

Details

A glht_list object is simply a list of glht objects. It is created as needed – for example, when there is a by variable. Appropriate convenience methods coef, confint, plot, summary, and vcov are provided, which simply apply the corresponding glht methods to each member.

Note

The multivariate-t routines used by glht require that all estimates in the family have the same integer degrees of freedom. In cases where that is not true, a message is displayed that shows what df is used. The user may override this via the df argument.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
if(require(multcomp)) { # --- multcomp must be installed

warp.lm <- lm(breaks ~ wool*tension, data = warpbreaks)

# Using 'emm'
summary(glht(warp.lm, emm(pairwise ~ tension | wool)))

# Same, but using an existing 'emmeans' result
warp.emm <- emmeans(warp.lm, ~ tension | wool)
summary(as.glht(pairs(warp.emm)))

# Same contrasts, but treat as one family
summary(as.glht(pairs(warp.emm), by = NULL))

} # --- was tested only if multcomp is installed

Example output

Loading required package: multcomp
Loading required package: mvtnorm
Loading required package: survival
Loading required package: TH.data
Loading required package: MASS

Attaching package: 'TH.data'

The following object is masked from 'package:MASS':

    geyser


Attaching package: 'multcomp'

The following object is masked from 'package:emmeans':

    cld


	 Simultaneous Tests for General Linear Hypotheses

Linear Hypotheses:
              Estimate Std. Error t value Pr(>|t|)   
L - M, A == 0  20.5556     5.1573   3.986  0.00130 **
L - H, A == 0  20.0000     5.1573   3.878  0.00182 **
M - H, A == 0  -0.5556     5.1573  -0.108  0.99996   
L - M, B == 0  -0.5556     5.1573  -0.108  0.99996   
L - H, B == 0   9.4444     5.1573   1.831  0.30798   
M - H, B == 0  10.0000     5.1573   1.939  0.25534   
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
(Adjusted p values reported -- single-step method)

emmeans documentation built on Dec. 1, 2019, 1:15 a.m.