[R] Multivariate LM: calculating F-values after calling linear.hypothesis

From: Dr. Christoph Scherber <Christoph.Scherber_at_agr.uni-goettingen.de>
Date: Sat, 07 Jun 2008 22:38:54 +0200 (CEST)


Dear R users,

I am analyzing several response variables (all scaled to [0;1]) using a multivariate linear model.

After fitting the model, I set up a hypothesis matrix to test specific contrasts for these response variables; for example: "a always increases significantly more than b when regressed against x".

What I am stuck with now is how to calculate the correct F-values (and against how many d.f. to test them) after calling linear.hypothesis from the car package:

(assuming there are 80 observations)

##

mult=lm(cbind(a,b,c,d,e,f,g)~x)

summary(mult)
library(car)

P <- cbind(

c(-1,1,0,0,0,0,0),
c(-3,-3,6,6,-3,-3,0),
c(0,0,2,0,-1,-1,0),
c(0,0,-1,0,1,0,0))

P

 [,1] [,2] [,3]

[1,] -1 -3 0
[2,] 1 -3 0
[3,] 0 6 2
[4,] 0 6 0
[5,] 0 -3 -1
[6,] 0 -3 -1
[7,] 0 0 0

summary(mult)

linhyp=linear.hypothesis(mult, "x", P=P)

linhyp

 Response transformation matrix:

     [,1] [,2] [,3] [,4]
[1,] -1 -3 0 0
[2,] 1 -3 0 0
[3,] 0 6 2 -1
[4,] 0 6 0 0
[5,] 0 -3 -1 1
[6,] 0 -3 -1 0
[7,] 0 0 0 0

Sum of squares and products for the hypothesis:

            [,1] [,2] [,3] [,4]
[1,] 0.06744438 -2.065499 -0.5790014 0.3233393
[2,] -2.06549912 63.256374 17.7320486 -9.9023380
[3,] -0.57900143 17.732049 4.9706540 -2.7758268
[4,] 0.32333928 -9.902338 -2.7758268 1.5501410

Sum of squares and products for error:

           [,1] [,2] [,3] [,4]
[1,] 4.4957632 1.084781 2.196134 -0.7621832
[2,] 1.0847809 173.494183 20.425963 -7.7303319
[3,] 2.1961336 20.425963 8.584237 -3.8182268
[4,] -0.7621832 -7.730332 -3.818227 2.3045286

1-pf(diag(linhyp2$SSPH)/diag(linhyp2$SSPE),1,79) 1-pt(sqrt(diag(linhyp2$SSPH)/diag(linhyp2$SSPE)),79)

##

The last two lines of code are what I am stuck with; I thought using diag() on the SSPH and SSPE matrices should give me the sums of squares for hypothesis and error; so division should yield the F values?

I would be most grateful for any help!

Best wishes
Christoph

--
Dr. Christoph Scherber
University of Goettingen
DNPW, Agroecology
Waldweg 26
D-37073 Goettingen, Germany
www.gwdg.de/~cscherb1

______________________________________________
R-help_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
Received on Sat 07 Jun 2008 - 20:42:59 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Sun 08 Jun 2008 - 01:30:38 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive