[Rd] Type III Sums of Squares?
Kaspar Pflugshaupt
pflugshaupt@geobot.umnw.ethz.ch
Tue, 09 May 2000 11:44:07 +0100
Hello,
I'd like to propose an extension to the function summary.aov.
In Splus (2000, I don't know about other versions), summary.aov allows a
parameter ssType to be set to 1 or 3 (defaults to 1) to choose the type of
Sums of Squares.
I know I can get Type III SS in R with drop1(model), but including the
functionality into summary.aov would, in my opinion,
- yield a more usable table (for example, the residual Df are missing in the
drop1 table)
- put it into the obvious place to look for it
- increase S-Plus compatibility (by a minor degree, I'll admit)
- not break anything else (I might be wrong here)
Not knowing how to add it to the summary.aov function, I wrote a function to
extract the SS from drop1 output and paste them into a summary.aov table
(see below), but that's of course an ugly solution. I feel that there has to
be a simpler and more efficient way, such as reusing just the required parts
of drop1 inside summary.aov. But since I cannot give the matter enough time
to do it correctly, someone with more insight into the source code would
have to do it.
If including the functionality via an additional parameter doesn't require a
whole rebuild of summary.aov, I'd like to put it as a minor item on the
wish-list for some next version of R.
Cheers (and thanks for a great piece of software)
Kaspar Pflugshaupt
"summmary.aov.t3" <-
function (aov.obj)
{
# ugly hack, relies on names in output
# tables of drop1 and summary.aov
s <- summary(aov.obj)
d <- drop1(aov.obj, test = "F")
n <- nrow(d)
s[[1]]$"Sum Sq"[1:(n - 1)] <- d$Sum[2:n]
s[[1]]$"Mean Sq" <- s[[1]]$"Sum Sq"/s[[1]]$Df
s[[1]]$"F value"[1:(n - 1)] <- d$F[2:n]
s[[1]]$"Pr(>F)"[1:(n - 1)] <- d$Pr[2:n]
names(s[[1]])[names(s[[1]]) == "Sum Sq"] <- "Sum Sq (Type III)"
s
}
--
Kaspar Pflugshaupt
Geobotanisches Institut
Zuerichbergstr. 38
CH-8044 Zuerich
Tel. ++41 1 632 43 19
Fax ++41 1 632 12 15
mailto:pflugshaupt@geobot.umnw.ethz.ch
privat:pflugshaupt@mails.ch
http://www.geobot.umnw.ethz.ch
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-devel mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !) To: r-devel-request@stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._