[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

From |
"Abdel Rahmen El Lahga" <[email protected]> |

To |
[email protected] |

Subject |
Re: st: re: interaction of column matrix |

Date |
Fri, 19 Oct 2007 13:21:00 +0200 |

Kit Baum wrote > I've never heard of a 'horizontal direct product' but in a 2x2 > example it seems to be the first and last rows of a conventional > Kronecker product... the term "horizontal direct product" is used in Gauss manual ( and R i think) and denoted by the operator " *~ " and is different from the kronecker product in Gauss denoted by " .*. " You are right when tou say that "it appears that whatever this construction might be it > could be generated from a Kronecker" but the question is how to automate such task in Mata. You know that with matrix A(k,l), B(m,n) ; A#B =C(k*m,l*n) but here we want a new matrix C(k,l*n) asumming that k=m. Hence my motivation to write my hdp() function AbdelRahmen 2007/10/19, Kit Baum <[email protected]>: > Abdel wrote > > I've written this mata function as a solution to my own question > yesterday. > horizontal direct product (hdp). > --------begin code------------ > version 9.2 > local mydir "." > mata: > mata clear > real matrix hdp(real matrix A, real matrix B) > { > assert(rows(A)==rows(B)) > real scalar n > real matrix C > n=rows(A) > C=J(n,1,.) > for (i=1; i<=cols(A); i++) { > C=C,(A[.,i]:*B) > } > C=C[.,2..cols(C)] > return(C) > } > > > I've never heard of a 'horizontal direct product' but in a 2x2 > example it seems to be the first and last rows of a conventional > Kronecker product: > > : a > 1 2 > +---------+ > 1 | 1 2 | > 2 | 3 4 | > +---------+ > > : b > 1 2 > +---------+ > 1 | 5 6 | > 2 | 0 1 | > +---------+ > > : c > 1 2 3 4 > +---------------------+ > 1 | 5 6 10 12 | > 2 | 0 3 0 4 | > +---------------------+ > > : a#b > 1 2 3 4 > +---------------------+ > 1 | 5 6 10 12 | > 2 | 0 1 0 2 | > 3 | 15 18 20 24 | > 4 | 0 3 0 4 | > +---------------------+ > > > For a 3x3 example, it is the 1st, 5th and 9th rows of the Kronecker > product. Thus it appears that whatever this construction might be it > could be generated from a Kronecker. > > > > > Kit Baum, Boston College Economics and DIW Berlin > http://ideas.repec.org/e/pba1.html > An Introduction to Modern Econometrics Using Stata: > http://www.stata-press.com/books/imeus.html > > > * > * 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/ > -- AbdelRahmen El Lahga * * 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/

**References**:**st: re: interaction of column matrix***From:*Kit Baum <[email protected]>

- Prev by Date:
**st: specifying linear mixed-effects covariance structure** - Next by Date:
**Re: st: SAS SAS7BDAT file into Stata9** - Previous by thread:
**st: re: interaction of column matrix** - Next by thread:
**Re: Re: st: re: interaction of column matrix** - Index(es):

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