Statalist


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

Re: st: re: interaction of column matrix


From   "Abdel Rahmen El Lahga" <rahmen.lahga@gmail.com>
To   statalist@hsphsun2.harvard.edu
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 <kitbaum@mac.com>:
> 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/



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