Examples for 'multcomp::summary.glht'


Methods for General Linear Hypotheses

Aliases: summary.glht confint.glht coef.glht vcov.glht plot.glht plot.confint.glht univariate adjusted Ftest Chisqtest adjusted_calpha univariate_calpha

Keywords: htest

### ** Examples


  ### set up a two-way ANOVA 
  amod <- aov(breaks ~ wool + tension, data = warpbreaks)

  ### set up all-pair comparisons for factor `tension'
  wht <- glht(amod, linfct = mcp(tension = "Tukey"))

  ### 95% simultaneous confidence intervals
  plot(print(confint(wht)))
	 Simultaneous Confidence Intervals

Multiple Comparisons of Means: Tukey Contrasts


Fit: aov(formula = breaks ~ wool + tension, data = warpbreaks)

Quantile = 2.4153
95% family-wise confidence level
 

Linear Hypotheses:
           Estimate lwr      upr     
M - L == 0 -10.0000 -19.3529  -0.6471
H - L == 0 -14.7222 -24.0751  -5.3694
H - M == 0  -4.7222 -14.0751   4.6306
plot of chunk example-multcomp-summary.glht-1
  ### the same (for balanced designs only)
  TukeyHSD(amod, "tension")
  Tukey multiple comparisons of means
    95% family-wise confidence level

Fit: aov(formula = breaks ~ wool + tension, data = warpbreaks)

$tension
          diff       lwr        upr     p adj
M-L -10.000000 -19.35342 -0.6465793 0.0336262
H-L -14.722222 -24.07564 -5.3688015 0.0011218
H-M  -4.722222 -14.07564  4.6311985 0.4474210
  ### corresponding adjusted p values
  summary(wht)
	 Simultaneous Tests for General Linear Hypotheses

Multiple Comparisons of Means: Tukey Contrasts


Fit: aov(formula = breaks ~ wool + tension, data = warpbreaks)

Linear Hypotheses:
           Estimate Std. Error t value Pr(>|t|)   
M - L == 0  -10.000      3.872  -2.582  0.03371 * 
H - L == 0  -14.722      3.872  -3.802  0.00113 **
H - M == 0   -4.722      3.872  -1.219  0.44741   
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
(Adjusted p values reported -- single-step method)
  ### all means for levels of `tension'
  amod <- aov(breaks ~ tension, data = warpbreaks)
  glht(amod, linfct = matrix(c(1, 0, 0,
                               1, 1, 0,
                               1, 0, 1), byrow = TRUE, ncol = 3))
	 General Linear Hypotheses

Linear Hypotheses:
       Estimate
1 == 0    36.39
2 == 0    26.39
3 == 0    21.67
  ### confidence bands for a simple linear model, `cars' data
  plot(cars, xlab = "Speed (mph)", ylab = "Stopping distance (ft)",
       las = 1)

  ### fit linear model and add regression line to plot
  lmod <- lm(dist ~ speed, data = cars)
  abline(lmod)

  ### a grid of speeds
  speeds <- seq(from = min(cars$speed), to = max(cars$speed),
                length = 10)

  ### linear hypotheses: 10 selected points on the regression line != 0
  K <- cbind(1, speeds)

  ### set up linear hypotheses
  cht <- glht(lmod, linfct = K)

  ### confidence intervals, i.e., confidence bands, and add them plot
  cci <- confint(cht)
  lines(speeds, cci$confint[,"lwr"], col = "blue")
  lines(speeds, cci$confint[,"upr"], col = "blue")
plot of chunk example-multcomp-summary.glht-1
  ### simultaneous p values for parameters in a Cox model
  if (require("survival") && require("MASS")) {
      data("leuk", package = "MASS")
      leuk.cox <- coxph(Surv(time) ~ ag + log(wbc), data = leuk)

      ### set up linear hypotheses
      lht <- glht(leuk.cox, linfct = diag(length(coef(leuk.cox))))

      ### adjusted p values
      print(summary(lht))
  }
	 Simultaneous Tests for General Linear Hypotheses

Fit: coxph(formula = Surv(time) ~ ag + log(wbc), data = leuk)

Linear Hypotheses:
       Estimate Std. Error z value Pr(>|z|)  
1 == 0  -1.0691     0.4293  -2.490   0.0253 *
2 == 0   0.3677     0.1360   2.703   0.0137 *
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
(Adjusted p values reported -- single-step method)

[Package multcomp version 1.4-19 Index]