Helper function to perform Tukey post-hoc tests. It is used in gafem.

tukey_hsd(model, ..., out = "long")

Arguments

model

an object of class aov or lm.

...

other arguments passed to the function TukeyHSD(). These include:

  • which: A character vector listing terms in the fitted model for which the intervals should be calculated. Defaults to all the terms.

  • ordered: A logical value indicating if the levels of the factor should be ordered according to increasing average in the sample before taking differences. If ordered is true then the calculated differences in the means will all be positive. The significant differences will be those for which the lwr end point is positive.

out

The format of outputs. If out = "long" a 'long' format (tibble) is returned. If out = "wide", a matrix with the adjusted p-values for each term is returned.

Value

A tibble data frame containing the results of the pairwise comparisons (if out = "long") or a "list-columns" with p-values for each term (if out = "wide").

Examples

# \donttest{ library(metan) mod <- lm(PH ~ GEN + REP, data = data_g) tukey_hsd(mod)
#> # A tibble: 81 x 8 #> term group1 group2 estimate conf.low conf.high p.adj sign #> <chr> <chr> <chr> <dbl> <dbl> <dbl> <dbl> <chr> #> 1 GEN H1 H10 -0.159 -0.700 0.382 0.995 ns #> 2 GEN H1 H11 -0.0960 -0.637 0.445 1.00 ns #> 3 GEN H1 H12 0.233 -0.308 0.774 0.921 ns #> 4 GEN H1 H13 0.401 -0.140 0.942 0.303 ns #> 5 GEN H1 H2 -0.0433 -0.584 0.498 1.00 ns #> 6 GEN H1 H3 -0.154 -0.695 0.387 0.997 ns #> 7 GEN H1 H4 -0.148 -0.689 0.393 0.998 ns #> 8 GEN H1 H5 -0.103 -0.644 0.438 1.00 ns #> 9 GEN H1 H6 -0.0440 -0.585 0.497 1.00 ns #> 10 GEN H1 H7 -0.0200 -0.561 0.521 1 ns #> # ... with 71 more rows
tukey_hsd(mod, out = "wide")
#> # A tibble: 2 x 2 #> term data #> <chr> <list> #> 1 GEN <df[,12] [12 x 12]> #> 2 REP <df[,2] [2 x 2]>
# }