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

st: Re: Re: RE: matrix algebra


From   "Alfonso Miranda" <[email protected]>
To   <[email protected]>
Subject   st: Re: Re: RE: matrix algebra
Date   Tue, 1 Oct 2002 21:06:43 +0100

Dear statalisters,

Regarding my last post on matrix algebra I find that Nick's idea would work
with a small n. But if n is huge (as it is my case) the command

matrix Y = J(`n',`n',0)

will retun code 908 (matzise too small). Any other ideas?

Thank you,

Alfonso.

> ----- Original Message -----
> From: "Nick Cox" <[email protected]>
> To: <[email protected]>
> Sent: Wednesday, October 02, 2002 7:38 PM
> Subject: st: RE: matrix algebra
>
>
> > Alfonso Miranda
> > >
> > > I need to calculate a matrix product that has the following form
> > >
> > > B = G'YG
> > >
> > > where G is a n x k matrix and Y is a n x n diagonal matrix.
> > > My problem is:
> > >
> > > (a) G should be formed with information for some variables,
> > > say, a1 a2 a3. I
> > > have n observations for each variable.
> > >
> > > (a) I have the information of the diagonal of Y in variable
> > > called e. So I
> > > need to use e to create matrix Y.
> > >
> > > (b) n is very large (more than 20,000 observations) so it
> > > is imposible to
> > > create a nxn diagonal matrix  with elements in the diagonal
> > > entries in e.
> > >
> > > I guess I need to use something like:
> > >
> > > matrix glsaccum B = a1 a2 a3, glsmat(Y)
> > >
> > > But first I must define Y. Can anyone help me in this one?
> >
> > One way to do it
> >
> > . local n = _N
> > . matrix Y = J(`n',`n',0)
> > . forval i = 1 / `n' {
> > . matrix Y[`i',`i'] = myvar[`i']
> > . }
> >
> > Nick
> > [email protected]
> > *
> > *   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/
>
> *
> *   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/

*
*   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–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index