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

st: RE: matrix algebra

From   "Jiang, Tao" <>
To   "''" <>
Subject   st: RE: matrix algebra
Date   Wed, 2 Oct 2002 15:21:52 -0400

I think you can do the following to avoid using glsaccum and large number of

Suppose m is a very big positive number, such that m+e will be all positive,

then do:
gen double _a1=a1*sqrt(m+e)
gen double _a2=a2*sqrt(m+e)
gen double _a3=a3*sqrt(m+e)
mat accum A = _a1 _a2 _a3, nocons
mat accum B = a1 a2 a3, nocons
mat C=A-m*B

will be the one you need.

-----Original Message-----
From: Alfonso Miranda []
Sent: Tuesday, October 01, 2002 2:25 PM
Subject: st: matrix algebra

Dear statalisters,

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?

Many Thanks

Alfonso Miranda.

*   For searches and help try:
*   For searches and help try:

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