[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: mata: interaction of column matrix |

Date |
Fri, 19 Oct 2007 11:15:16 +0200 |

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) } mata mosave hdp() , dir(`mydir') replace end --end code--------- Note that this code is note effecient but it works. if you have tow matrix x and y and you want to create z the hdp of x and y just type z=hdp(x,y) Sincerely AbdelRahmen 2007/10/18, Abdel Rahmen El Lahga <[email protected]>: > under mata (stata 9.2) I have the following matrices X=a,b,c and Y=d,e. > I would like to create a new matrix Z=(a:*d, a:*e, b:*d, b:*e, c:*d, > c:*e) which is an interaction betwenn X and Y's columns. > Note that in my old Gauss code this task is easy to ny typing > Z=X*~Y > Any help? > -- > 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/ > -- 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: mata: interaction of column matrix***From:*"Abdel Rahmen El Lahga" <[email protected]>

- Prev by Date:
**Re: st: missing t statistics** - Next by Date:
**RE: st: missing t statistics** - Previous by thread:
**st: mata: interaction of column matrix** - Next by thread:
**st: &Agr;&Pgr;: -mean- over id, save to a new dta, then variance matrix** - Index(es):

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