Stata The Stata listserver
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

RE: RE: st: kronecker product - matsize


From   "David M. Drukker, StataCorp" <ddrukker@stata.com>
To   statalist@hsphsun2.harvard.edu
Subject   RE: RE: st: kronecker product - matsize
Date   Tue, 01 Feb 2005 09:01:17 -0600

Martin Halla <Martin.Halla@jku.at> wrote that - matrix glsaccum- only solves
part of the problem.  Martin needs to compute


matrix B = inv((z*inv(z'z)*z'x)'*(inv(sigma)#In)*x) *	///
		(z*inv(z'z)*z'x)'*(inv(sigma) # In)*y

which is difficult since z is N by p, x is N by k and y is N by 1.

Martin used -matrix accum- to compute

ZZ=z'z
ZX=z'x

yielding

	matrix B = inv((z*inv(ZZ)*ZX)'*(inv(sigma)#In)*x) *	///
		(z*inv(ZZ)*ZX)'*(inv(sigma) # In)*y

Defining 

	W = (z*inv(ZZ)*ZX) 

cause the problem to become

	B = inv(W'*(inv(sigma)#In)x)*W'(inv(sigma)#In)*y

which could computed using -matrix glsaccum-, if we had the variables that
make up the matrix W.

To obtain W, Martin can let each column of inv(ZZ)*ZX be vector that we will
call h.  Martin can then transpose h, so it is now a row vector, make the
row names of h equal to names of the variables in z and then use -matrix
score- to compute a new variable.  After doing this for each column of
inv(ZZ)*ZX, he will have created the variables in W

With the W variables in hand, Martin now needs to compute

	W'(inv(sigma)#In)x
and

	W'(inv(sigma)#In)y

which can be computed using -matrix glsaccum-.  (To get W'(inv(sigma)#In)x
from -matrix glsaccum- include the W and the x variables in the varlist and
then grab the upper-right block of the resulting matrix.)

	-David
	 ddrukker@stata.com

*
*   For searches and help try:
*   http://www.stata.com/support/faqs/res/findit.html
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/



© Copyright 1996–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index