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

From |
Maarten buis <maartenbuis@yahoo.co.uk> |

To |
statalist@hsphsun2.harvard.edu |

Subject |
Re: st: calculating the confidence intervals for the difference in predicted values |

Date |
Mon, 19 Oct 2009 02:10:19 -0700 (PDT) |

--- On Mon, 19/10/09, stata user wrote: > The context for this exercise is that, for example, we want > to study the housing price difference in two regions. I > first run a regression to determine how the housing > charateristics (X) would affect a house price (Y), based on > region A's data. Then I make an out-of-sample prediction of > house price in region B. And make a in-sample prediction > of house price in region A. The the difference btw the two > predictions would be the difference in housing prices between > region A and region B, if both of the housing prices depend > on the same set of housing characteristics. I would set this up by estimating these comparisons in a single model using interaction effects, and than use -predictnl- to compute the differences and ratios: *----------------------- begin example ----------------------- sysuse auto, clear gen forXrep78 = foreign*rep78 glm price foreign forXrep78 rep78, link(log) predictnl diff = exp(xb()) - exp(_b[_cons] + _b[rep78]) /// , ci(lb_d ub_d) predictnl ratio = exp(xb()) / exp(_b[_cons] + _b[rep78]) /// , ci(lb_r ub_r) sort foreign rep78 list rep78 lb_d diff ub_d if foreign == 1, sepby(rep78) list rep78 lb_r ratio ub_r if foreign == 1, sepby(rep78) *------------------------ end example ------------------------- (For more on examples I sent to the Statalist see: http://www.maartenbuis.nl/example_faq ) Here I use -glm- with the log link to avoid the problem that when you log transform the dependent variable, calculate predictions, and back transform those prediction again in the original unit, you won't get the expected price given the covariates as the log transformation is a non-linear transformation (in fact you will get the conditional geometric mean price, rather than the conditional arithmetic mean price). Hope this helps, Maarten -------------------------- Maarten L. Buis Institut fuer Soziologie Universitaet Tuebingen Wilhelmstrasse 36 72074 Tuebingen Germany http://www.maartenbuis.nl -------------------------- Send instant messages to your online friends http://uk.messenger.yahoo.com * * 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**:**Re: st: calculating the confidence intervals for the difference in predicted values***From:*stata user <sf.stata.user@gmail.com>

- Prev by Date:
**Re: st: SV: RE: Venn diagram** - Next by Date:
**Re: st: RE: automatic coding so that legends assume the label variables** - Previous by thread:
**Re: st: calculating the confidence intervals for the difference in predicted values** - Index(es):

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