[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: Program for OLS regression coefficients using weights |

Date |
Thu, 18 Jun 2009 17:44:08 +0200 |

<> The Mata suggestion grew more out of Sylke`s concern over -matsize- which I thought could be circumvented via Mata... HTH Martin -----Ursprüngliche Nachricht----- Von: owner-statalist@hsphsun2.harvard.edu [mailto:owner-statalist@hsphsun2.harvard.edu] Im Auftrag von Kit Baum Gesendet: Donnerstag, 18. Juni 2009 17:32 An: statalist@hsphsun2.harvard.edu Betreff: st: re: Program for OLS regression coefficients using weights <> Sylke said I would need to write a programme that gives me the b coefficients of an OLS regression, using weights. This is an easy task if no weights are used with b being (X'X)-1(X'Y): mat accum xprimex = x mat vecaccum yprimex = y x *Transpose mat xprimey =yprimex' mat b = inv(xprimex)*(xprimey) mat list b However, I would like to estimate b=(X'DX)-1 X'DY, hence applying design weights. D is now a diagonal weight matrix. Martin suggested Mata. No need for Mata here, though, if you're just trying to apply a diagonal matrix of weights stored in a variable: sysuse auto,clear replace foreign = 2*foreign replace foreign = 10 if foreign==0 reg price weight turn [iw=foreign^2] g wprice = foreign*price g wweight = foreign*weight g wturn = foreign*turn reg wprice wweight wturn foreign, nocons Kit Kit Baum | Boston College Economics & DIW Berlin | http://ideas.repec.org/e/pba1.html An Introduction to Stata Programming | http://www.stata-press.com/books/isp.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/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>

- Prev by Date:
**st: RE: re: Re: Suppressing the Constant in the First Stage with ivreg2** - Next by Date:
**RE: st: growth curve model with weights** - Previous by thread:
**st: re: Program for OLS regression coefficients using weights** - Next by thread:
**st: Big set of 1x1 matrices into scalar - how to do fast?** - Index(es):

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