/
TukeyC.aov.R
60 lines (44 loc) · 1.51 KB
/
TukeyC.aov.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
##
## S3 method to 'aov' object
##
TukeyC.aov <- function(x,
which=NULL,
sig.level=.05,
round=2,
dispersion=c('mm', 's', 'se'), ...)
{
if(is.null(which))
which <- names(x$model)[2]
mt <- model.tables(x,
"means") # summary tables for model fits
if(is.null(mt$n))
stop("No factors in the fitted model!")
tabs <- mt$tables[-1][which] # specified group means
r <- mt$n[names(tabs)][[which]] # groups and its number of replicates
bal <- ifelse(length(r) == 1,
TRUE,
FALSE) # is (or not) balanced
MSE <- sum(resid(x)^2) / x$df.residual
nms <- names(tabs[[which]])
ord <- order(as.vector(tabs[[which]]),
decreasing=TRUE)
m.inf <- m.inf.1a(x,
which,
dispersion)
rownames(m.inf) <- nms
m.inf <- m.inf[order(m.inf[,1],
decreasing=TRUE),]
dfr <- x$df.residual # residual degrees of freedom
out <- make.TukeyC.test(r=r,
MSE=MSE,
m.inf=m.inf,
ord=ord,
sig.level=sig.level,
dfr=dfr,
bal=bal,
mt=mt,
round)
class(out) <- c('TukeyC',
'list')
return(out)
}