[R] using contrasts on matrix regressions (using gmodels, perhaps)

Ranjan Maitra maitra at iastate.edu
Thu Jul 26 01:30:36 CEST 2007


Hi, 

I want to test for a contrast from a regression where I am regressing the columns of a matrix. In short, the following.

X <- matrix(rnorm(50),10,5)
Y <- matrix(rnorm(50),10,5)
lm(Y~X)  

Call:
lm(formula = Y ~ X)

Coefficients:
             [,1]     [,2]     [,3]     [,4]     [,5]   
(Intercept)   0.3350  -0.1989  -0.1932   0.7528   0.0727
X1            0.2007  -0.8505   0.0520   0.1501   0.3248
X2            0.3212   0.7008  -0.0963  -0.2584   0.6711
X3            0.3781  -0.7321   0.1907  -0.1721   0.3073
X4           -0.1778   0.2822  -0.0644  -0.2649  -0.4140
X5           -0.1079  -0.0475   0.6047  -0.8369  -0.5928


I want to test for c'b = 0 where c is (lets say) the contrast (0, 0, 1, 0, -1). Is it possible to do so, in one shot, using gmodels or something else?

Many thanks and best wishes,
Ranjan



More information about the R-help mailing list