Notice: On March 31, it was **announced** that Statalist is moving from an email list to a **forum**. The old list will shut down on April 23, and its replacement, **statalist.org** is already up and running.

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

From |
Amanda Fu <mandy.fu1@gmail.com> |

To |
statalist@hsphsun2.harvard.edu |

Subject |
Re: st:weave two matrices row by row |

Date |
Mon, 27 Dec 2010 15:19:41 -0500 |

Dear Mr. Chakravarty, Thank you for the reply! It is really smart to use matrix multiplier to deal with this. I appreciate it. Amanda On Sun, Dec 26, 2010 at 9:43 PM, Tirthankar Chakravarty <tirthankar.chakravarty@gmail.com> wrote: > Matrix multiplication is probably the most memory-efficient and > generalisable way of doing this: > ************************************* > clear* > mata > mA = runiform(10, 8) > mB = runiform(10, 8) > mD = (designmatrix(range(1, 19, 2))'\J(1, 10, 0))*mA + > designmatrix(range(2, 20, 2))'*mB > mD > end > ************************************* > T > > On Sun, Dec 26, 2010 at 4:34 PM, Amanda Fu <mandy.fu1@gmail.com> wrote: >> >> Hi All, >> >> I was wondered if there is any way to weave two matrix row by row. >> Say, I have matrix A [10,8] and B[10,8]. I want to create a new matrix >> C looks like as: >> >> matrix C [20,8]: >> --------------------------------- >> row 1 : row 1 of A >> row 2: row 1 of B >> row 3: row 2 of A >> row 4: row 2 of B >> .......... >> row 19: row 10 of A >> row 20: row 10 of B >> --------------------------------- >> Right now I think I could do the following: >> >> (1) matrix define C as a 20*8 matrix. >> (2) use -mkmat- to change A and B into 8 variables respectively >> A1,A2,..A8,B1,..,B8. >> (3) Then define each row using the variables from (2). >> >> But when actually conducting the above way,I find it requires to be >> very careful and much more work than I expected. This is why I think >> it would be better that I ask the expert here to see how an expert >> will deal with this. >> >> Thanks for your time! >> >> Sincerely, >> Amanda >> * >> * 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/ > > > > -- > To every ω-consistent recursive class κ of formulae there correspond > recursive class signs r, such that neither v Gen r nor Neg(v Gen r) > belongs to Flg(κ) (where v is the free variable of r). > > * > * 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/

**References**:**st:weave two matrices row by row***From:*Amanda Fu <mandy.fu1@gmail.com>

**Re: st:weave two matrices row by row***From:*Tirthankar Chakravarty <tirthankar.chakravarty@gmail.com>

- Prev by Date:
**Re: st: Propensity score matching with latent outcome?** - Next by Date:
**Re: st: diagnose stata memory usage** - Previous by thread:
**Re: st:weave two matrices row by row** - Next by thread:
**st: diagnose stata memory usage** - Index(es):