|
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]
st: re: interaction of column matrix
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/