[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

From |
Venable <venablito@gmail.com> |

To |
statalist@hsphsun2.harvard.edu |

Subject |
Re: st: Efficient, foolproof calculation of matrix quadratic form with block-diagonal middle matrix? (Mata) |

Date |
Fri, 25 Sep 2009 12:06:54 -0400 |

Thanks very much for your quick and informative response. Just so I can be sure: what you are doing is along the lines of the sum of N terms approach in my post, correct? On Fri, Sep 25, 2009 at 11:21 AM, Austin Nichols <austinnichols@gmail.com> wrote: > Venable <venablito@gmail.com>: > See e.g. > http://www.stata.com/statalist/archive/2009-05/msg00841.html > and compare to the relevant code in > http://repec.org/bocode/o/overid.ado > --search for: > // Kronecker product with esigma > middle = invsym(sigma) # pw > > On Fri, Sep 25, 2009 at 10:24 AM, Venable <venablito@gmail.com> wrote: >> Dear Statalisters, >> >> I am using Mata to calcuate a quadratic form, the middle matrix of >> which is block-diagonal, with all square and identical blocks. This is >> most compactly expressed in Mata as: >> >> A=X'*(I(N)#Om_Inv_Block)*X >> >> X is (NxT) x K and is made up of N cross-sectional units, each of >> which has T observations (so, a balanced panel of N with T >> observations for each unit. You can think of X as X1 \ X2 \ ... \ XN, >> with each Xn being K by T. Om_Inv_Block is TxT. >> >> This is extremely simple to code, but Mata needs to create the NTxNT >> matrix I(N)#Om_Inv_Block and with N and / or T large, this becomes a >> very, very large matrix which occasionally causes Mata to crash. >> (Interestingly, when Mata does not crash it doesn't take long at all >> to calculate.) >> >> I was wondering if there were a way for Mata to recognize the special >> structure of the block-diagonal matrix and get around the need to >> create this very large middle matrix explicitly. >> >> Alternatively, I know that I could do the sum of the N terms >> Xn'*Om_Inv_Block*Xn but I am worried that I would somehow mess this >> up. So, another solution, I suppose, would be some idiot-proof way to >> do this sum. >> >> I apologize in advance if this is obvious, has been discussed before, >> or is in the Mata manuals somewhere. I searched the Statalist using >> terms "block diagonal" and "quadatic form" (individually and together) >> and did not find a solution. >> >> Many thanks. > * > * For searches and help try: > * http://www.stata.com/help.cgi?search > * http://www.stata.com/support/statalist/faq > * http://www.ats.ucla.edu/stat/stata/ > * * For searches and help try: * http://www.stata.com/help.cgi?search * http://www.stata.com/support/statalist/faq * http://www.ats.ucla.edu/stat/stata/

**Follow-Ups**:**Re: st: Efficient, foolproof calculation of matrix quadratic form with block-diagonal middle matrix? (Mata)***From:*Austin Nichols <austinnichols@gmail.com>

**References**:**st: Efficient, foolproof calculation of matrix quadratic form with block-diagonal middle matrix? (Mata)***From:*Venable <venablito@gmail.com>

**Re: st: Efficient, foolproof calculation of matrix quadratic form with block-diagonal middle matrix? (Mata)***From:*Austin Nichols <austinnichols@gmail.com>

- Prev by Date:
**Re: st: mata optimize with d2debug** - Next by Date:
**Re: st: mata optimize with d2debug** - Previous by thread:
- Next by thread:
- Index(es):

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