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

From |
"Martin Weiss" <martin.weiss1@gmx.de> |

To |
<statalist@hsphsun2.harvard.edu> |

Subject |
st: AW: RE: AW: Big set of 1x1 matrices into scalar - how to do fast? |

Date |
Mon, 22 Jun 2009 11:46:12 +0200 |

<> I did this in the old matrix language, but you should seriously look into Mata: http://www.stata.com/meeting/fnasug08/baum_StataMata.beamer.FNASUG08.pdf HTH Martin -----Ursprüngliche Nachricht----- Von: owner-statalist@hsphsun2.harvard.edu [mailto:owner-statalist@hsphsun2.harvard.edu] Im Auftrag von Schnepf S.V. Gesendet: Montag, 22. Juni 2009 11:43 An: statalist@hsphsun2.harvard.edu Betreff: st: RE: AW: Big set of 1x1 matrices into scalar - how to do fast? Many thanks Martin. Stata matsize limitation does not let me run your proposal since I have too many observations. If svmat could be used in the way, that the value of the 1x1 matrix could be written into row `I' of an existing variable instead of creating for each matrix a new variable, then the problem could be overcome. But I do not find a code for doing so, that does not use egen or sum - and both of those are just too time consuming. Many thanks again for your help! Sylke -----Original Message----- From: owner-statalist@hsphsun2.harvard.edu [mailto:owner-statalist@hsphsun2.harvard.edu] On Behalf Of Martin Weiss Sent: 19 June 2009 17:55 To: statalist@hsphsun2.harvard.edu Subject: st: AW: Big set of 1x1 matrices into scalar - how to do fast? <> Why no tdo this in one fell swoop? ************* clear* /*fake matrices */ matrix input b = /* */ (1,8,7,6,8,1,32,4,3,2) matrix input Xi1 = /* */ (3\3\3\3\3\3\3\3\3\3) matrix input Xi2 = /* */ (9\3\1\3\3\2\3\3\3\4) matrix input Xi3 = /* */ (9\3\4\3\10\2\3\3\3\0) /*construct one big matrix */ forv i=1/3{ mat Xi=(nullmat(Xi),Xi`i') } /*multiply in one fell swoop */ mat c=b*Xi matrix d=c' svmat d list, noo ************* HTH Martin -----Ursprüngliche Nachricht----- Von: owner-statalist@hsphsun2.harvard.edu [mailto:owner-statalist@hsphsun2.harvard.edu] Im Auftrag von Schnepf S.V. Gesendet: Freitag, 19. Juni 2009 18:32 An: statalist@hsphsun2.harvard.edu Betreff: st: Big set of 1x1 matrices into scalar - how to do fast? Dear Statalist users, forvalues i = 1(1)3641 { mat c`i'= b*Xi`i'' capture drop c quietly gen c= el(c`i',1,1) quietly sum c quietly replace result=r(mean) in `i' drop c } For a large set of individuals (here 3641), I have to multiply two vectors, with b and Xi`I' being a 1x10 vector. As a result I receive for each individual a 1x1 matrix, just containing 1 value. I now would like to produce one single scalar variable, that for each `I' row contains the number of c`I'. I have found a way how to do that, given above. But my simple solution is incredibly slow. Could you help? Many thanks Sylke V. Schnepf Ps. Many thanks for the help on the program for programming a weighted regression, very helpful. * * 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/ * * 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: re: Program for OLS regression coefficients using weights***From:*Kit Baum <baum@bc.edu>

**st: Big set of 1x1 matrices into scalar - how to do fast?***From:*"Schnepf S.V." <S.V.Schnepf@soton.ac.uk>

**st: AW: Big set of 1x1 matrices into scalar - how to do fast?***From:*"Martin Weiss" <martin.weiss1@gmx.de>

**st: RE: AW: Big set of 1x1 matrices into scalar - how to do fast?***From:*"Schnepf S.V." <S.V.Schnepf@soton.ac.uk>

- Prev by Date:
**st: RE: AW: Big set of 1x1 matrices into scalar - how to do fast?** - Next by Date:
**Re: AW: st: AW: beta coefficients for interaction terms** - Previous by thread:
**st: RE: AW: Big set of 1x1 matrices into scalar - how to do fast?** - Next by thread:
**Re: st: AW: RE: AW: Big set of 1x1 matrices into scalar - how to do fast?** - Index(es):

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