[R] What is wrong with this contrast matrix?

(Ted Harding) Ted.Harding at manchester.ac.uk
Thu Jul 24 18:16:43 CEST 2008


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 ------------------------------



More information about the R-help mailing list