Dear all, I am fitting a multivariate linear model with 7 response variables and 1 explanatory variable. The following matrix P: P <- cbind( c(1,-1,0,0,0,0,0), c(2,2,2,2,2,-5,-5), c(1,0,0,-1,0,0,0), c(-2,-2,0,-2,2,2,2), c(-2,1,0,1,0,0,0), c(0,-1,0,1,0,0,0)) should consist of orthogonal elements (as can be shown using %*% on the individual columns). However, when I use linhyp=linear.hypothesis(model, "explanatory.variable", P=P) I get an error saying Error in linear.hypothesis.mlm(mult1, "logdiv", P = P) : The error SSP matrix is apparently of deficient rank = 4 < 6 Which I interpret as there are too many non-zero rows in the matrix, P. Is that correct? And how can I assess if the matrix is orthogonal (given that it is non-symmetrical, hence det(P) and other matrix operations won?t work) Many thanks for your help! Best wishes Christoph. (using R 2.7.1 on Windows XP) -- Dr. rer.nat. Christoph Scherber University of Goettingen DNPW, Agroecology Waldweg 26 D-37073 Goettingen Germany phone +49 (0)551 39 8807 fax +49 (0)551 39 8806 Homepage http://www.gwdg.de/~cscherb1
On 24-Jul-08 15:30:57, Christoph Scherber wrote:> Dear all, > I am fitting a multivariate linear model with 7 response variables and > 1 explanatory variable. > > The following matrix P: > > P <- cbind( > c(1,-1,0,0,0,0,0), > c(2,2,2,2,2,-5,-5), > c(1,0,0,-1,0,0,0), > c(-2,-2,0,-2,2,2,2), > c(-2,1,0,1,0,0,0), > c(0,-1,0,1,0,0,0)) > > should consist of orthogonal elements (as can be shown using %*% > on the individual columns). > However, when I use > > linhyp=linear.hypothesis(model, "explanatory.variable", P=P) > > I get an error saying > > Error in linear.hypothesis.mlm(mult1, "logdiv", P = P) : > The error SSP matrix is apparently of deficient rank = 4 < 6 > > Which I interpret as there are too many non-zero rows in the matrix, P. > > Is that correct? And how can I assess if the matrix is orthogonal > (given that it is non-symmetrical, > hence det(P) and other matrix operations won?t work)The matrix has rank 4 (not 6 as I suppose you intended): svd(P)$d # [1] 9.123340e+00 3.280954e+00 3.000000e+00 1.732051e+00 # [5] 2.754966e-16 1.315742e-16 The last two eigenvalues are effectively 0. Also, as I see it the columns of P are not all orthognal to each other by pairs: for(i in (1:5)){for(j in ((i+1):6)) print(c(i,j,sum(P[,i]*P[,j])))} # [1] 1 2 0 # [1] 1 3 1 # [1] 1 4 0 # [1] 1 5 -3 # [1] 1 6 1 # [1] 2 3 0 # [1] 2 4 -28 # [1] 2 5 0 # [1] 2 6 0 # [1] 3 4 0 # [1] 3 5 -3 # [1] 3 6 -1 # [1] 4 5 0 # [1] 4 6 0 # [1] 5 6 0 Am I using the right P? P # [,1] [,2] [,3] [,4] [,5] [,6] # [1,] 1 2 1 -2 -2 0 # [2,] -1 2 0 -2 1 -1 # [3,] 0 2 0 0 0 0 # [4,] 0 2 -1 -2 1 1 # [5,] 0 2 0 2 0 0 # [6,] 0 -5 0 2 0 0 # [7,] 0 -5 0 2 0 0> Many thanks for your help! > > Best wishes > Christoph.-------------------------------------------------------------------- E-Mail: (Ted Harding) <Ted.Harding at manchester.ac.uk> Fax-to-email: +44 (0)870 094 0861 Date: 24-Jul-08 Time: 17:16:41 ------------------------------ XFMail ------------------------------
Dear Ted, Thanks for your help; is there any straightforward way to construct an orthogonal contrast matrix by hand? Of course contrasts(as.factor(letters[1:6])) would also do the job, but user-defined contrasts would make more sense. Ideally, I would like to have a function that "tests" for me if my contrast matrix is orthogonal or not. Is there some built-in function in R for that? Best wishes Christoph.> On 24-Jul-08 15:30:57, Christoph Scherber wrote: >> Dear all, >> I am fitting a multivariate linear model with 7 response variables and >> 1 explanatory variable. >> >> The following matrix P: >> >> P <- cbind( >> c(1,-1,0,0,0,0,0), >> c(2,2,2,2,2,-5,-5), >> c(1,0,0,-1,0,0,0), >> c(-2,-2,0,-2,2,2,2), >> c(-2,1,0,1,0,0,0), >> c(0,-1,0,1,0,0,0)) >> >> should consist of orthogonal elements (as can be shown using %*% >> on the individual columns). >> However, when I use >> >> linhyp=linear.hypothesis(model, "explanatory.variable", P=P) >> >> I get an error saying >> >> Error in linear.hypothesis.mlm(mult1, "logdiv", P = P) : >> The error SSP matrix is apparently of deficient rank = 4 < 6 >> >> Which I interpret as there are too many non-zero rows in the matrix, P. >> >> Is that correct? And how can I assess if the matrix is orthogonal >> (given that it is non-symmetrical, >> hence det(P) and other matrix operations won?t work) > > The matrix has rank 4 (not 6 as I suppose you intended): > > svd(P)$d > # [1] 9.123340e+00 3.280954e+00 3.000000e+00 1.732051e+00 > # [5] 2.754966e-16 1.315742e-16 > > The last two eigenvalues are effectively 0. > > Also, as I see it the columns of P are not all orthognal to each > other by pairs: > > for(i in (1:5)){for(j in ((i+1):6)) print(c(i,j,sum(P[,i]*P[,j])))} > # [1] 1 2 0 > # [1] 1 3 1 > # [1] 1 4 0 > # [1] 1 5 -3 > # [1] 1 6 1 > # [1] 2 3 0 > # [1] 2 4 -28 > # [1] 2 5 0 > # [1] 2 6 0 > # [1] 3 4 0 > # [1] 3 5 -3 > # [1] 3 6 -1 > # [1] 4 5 0 > # [1] 4 6 0 > # [1] 5 6 0 > > Am I using the right P? > > P > # [,1] [,2] [,3] [,4] [,5] [,6] > # [1,] 1 2 1 -2 -2 0 > # [2,] -1 2 0 -2 1 -1 > # [3,] 0 2 0 0 0 0 > # [4,] 0 2 -1 -2 1 1 > # [5,] 0 2 0 2 0 0 > # [6,] 0 -5 0 2 0 0 > # [7,] 0 -5 0 2 0 0 > > >> Many thanks for your help! >> >> Best wishes >> Christoph. > > -------------------------------------------------------------------- > E-Mail: (Ted Harding) <Ted.Harding at manchester.ac.uk> > Fax-to-email: +44 (0)870 094 0861 > Date: 24-Jul-08 Time: 17:16:41 > ------------------------------ XFMail ------------------------------ > > . >
Reasonably Related Threads
- Multivariate LM: calculating F-values after calling linear.hypothesis
- A question on orthogonal basis vectors
- Possible soundness issue with available_externally (split from "RFC: Add guard intrinsics")
- Possible soundness issue with available_externally (split from "RFC: Add guard intrinsics")
- Possible soundness issue with available_externally (split from "RFC: Add guard intrinsics")