[R] TukeyHSD and BIBD

Simon Wotherspoon Simon.Wotherspoon at utas.edu.au
Thu Jan 30 06:04:03 CET 2003


Hi,
	the function TukeyHSD gives incorrect results for balanced incomplete block
designs, as the example below shows, but I can only half fix it.  There are
two problems,
1. It uses model.tables to estimate treatment means,
2. It uses the wrong standard error

The first problem can be fixed using dummy.coef, if the lines

> TukeyHSD.aov
function (x, which = seq(along = tabs), ordered = FALSE, conf.level = 0.95,
    ...)
{
    mm <- model.tables(x, "means")
    tabs <- mm$tables[-1]
    tabs <- tabs[which]
    ...

are altered to

> TukeyHSD.aov
function (x, which = seq(along = tabs), ordered = FALSE, conf.level = 0.95,
    ...)
{
    mm <- model.tables(x, "means")
    tabs <- dummy.coef(x)		## This line changed
    tabs <- tabs[which]
    ...

it calculates the right treatment differences (provided the block term
preceeds the treatment in the model formula).

To solve the second problem, I can manually get the correct se from
summary.lm, but I can't figure out how to extract the right se from
summary.lm programmatically.

I don't think these changes would make TukeyHSD fail on other cases, but I
haven't tested so I'm not sure.  I hope these few observations can help
someone a bit more knowledgable than I fix this problem.

Simon.




---




More information about the R-help mailing list