[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: Big set of 1x1 matrices into scalar - how to do fast? |

Date |
Fri, 19 Jun 2009 18:54:30 +0200 |

<> 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/

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

**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>

- Prev by Date:
**st: Big set of 1x1 matrices into scalar - how to do fast?** - Next by Date:
**st: how to select all the numerical variable** - Previous by thread:
**st: Big set of 1x1 matrices into scalar - how to do fast?** - Next by thread:
**st: RE: AW: Big set of 1x1 matrices into scalar - how to do fast?** - Index(es):

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