On Wed, 24 Jan 2007, nadaud(a)centre-cired.fr wrote:
I am currently working on 3-goods demand systems and I need to
use matrix operations to compute price and income elasticities.
However I find it difficult to define the matrix of three
different ols models named say m1, m2, m3.
More precisely, I would to define the matrix :
Z = {m1.$coeff;m2.$coeff;m3.$coeff}
but this does not work because this is not allowed with matrices
(chap 16) but only scalars.
Probably the easiest way to do this is using "~", the matrix
concatenation operator. For example:
m1 <- ols 4 0 1 2 3
m2 <- ols 5 0 1 2 3
m3 <- ols 6 0 1 2 3
matrix B = m1.$coeff
B = B ~ m2.$coeff
B = B ~ m3.$coeff
print B
(I should perhaps mention: It seems that
matrix B = m1.$coeff ~ m2.$coeff ~ m3.$coeff
ought to work, but it does not. There's a problem with repetition
of "~" that I'll have to look into that. The first version works
OK though.)
Allin Cottrell