[R] summary of aov fit on a contrast basis
John Fox
jfox at mcmaster.ca
Tue Oct 23 14:43:47 CEST 2001
Dear Jarek,
There are probably other ways to do this, but one way is to assign the
contrasts to the factor; using the data in your data frame x:
> attach(x)
>
> con <- matrix(c(2, 2, -1, -1, -1, -1,
+ 0, 0, 3, -1, -1, -1,
+ 1, -1, 0, 0, 0, 0,
+ 0, 0, 0, -2, 1, 1,
+ 0, 0, 0, 0, 1, -1),
+ 6, 5)
>
> con
[,1] [,2] [,3] [,4] [,5]
[1,] 2 0 1 0 0
[2,] 2 0 -1 0 0
[3,] -1 3 0 0 0
[4,] -1 -1 0 -2 0
[5,] -1 -1 0 1 1
[6,] -1 -1 0 1 -1
>
> contrasts(G) <- con
>
> summary(lm(X ~ G))
Call:
lm(formula = X ~ G)
Residuals:
Min 1Q Median 3Q Max
-1.000e+00 -1.000e+00 -5.551e-17 1.000e+00 1.000e+00
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 4.000e+00 2.357e-01 16.971 9.40e-10
G1 1.401e-16 1.667e-01 8.41e-16 1.000000
G2 2.000e+00 1.667e-01 12.000 4.84e-08
G3 -2.000e+00 4.082e-01 -4.899 0.000367
G4 2.318e-33 2.357e-01 9.83e-33 1.000000
G5 1.813e-16 4.082e-01 4.44e-16 1.000000
Residual standard error: 1 on 12 degrees of freedom
Multiple R-Squared: 0.9333, Adjusted R-squared: 0.9056
F-statistic: 33.6 on 5 and 12 DF, p-value: 1.179e-006
I used lm rather than aov to get the one-df t-tests for each contrast
coefficient; these are simply sqrt(F) from your approach. Note that the
contrast matrix is given by columns.
Is that what you wanted?
John
At 10:47 AM 10/23/2001 +0200, J.Sobieszek at elka.pw.edu.pl wrote:
>Hello,
>
>In a book (David W. Stockburger, "Multivariate Statistics: Concepts,
>Models, and Applications", chapter 12 "Contrasts, Special and
>Otherwise", available online at http://www.psychstat.smsu.edu/multibook)
>I've found some examples of doing analysis of variance on a contrast
>basis.
>
>I attach my solution (in R, the book uses SPSS) to this problem.
>
>Am I computing the same thing, and is there a simpler way of doing that?
>
>I would greatly appreciate any comments.
>
>Thanks,
>
>Jarek
-----------------------------------------------------
John Fox
Department of Sociology
McMaster University
Hamilton, Ontario, Canada L8S 4M4
email: jfox at mcmaster.ca
phone: 905-525-9140x23604
web: www.socsci.mcmaster.ca/jfox
-----------------------------------------------------
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help 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-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
More information about the R-help
mailing list