Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.

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

From |
Richard Williams <richardwilliams.ndu@gmail.com> |

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

Subject |
Re: st: collecting interaction terms after estimation |

Date |
Sat, 05 Nov 2011 14:10:28 -0500 |

At 12:34 PM 11/5/2011, Maria Ana Vitorino wrote:

Dear Richard, Thanks for your suggestions. I'm actually using asclogit and it seems that factor variables and time series operators are not allowed... Ana

On Nov 5, 2011, at 2:20 PM, Richard Williams wrote:At 11:48 AM 11/5/2011, Maria Ana Vitorino wrote:Dear statalist users, Suppose I have the following model in which I regress people's decision to buy or not to buy something on people's characteristics interacted with distance. (the Xs refer to interactions between distance to the store and other people's characteristics). logit choice dist dist2 ageXdist sexXdist incXdistIf you have Stata 11 or 12, you are making this too hard. Use factor variable notation instead. clonevar xdist = dist logit choice i.sex xdist age inc c.xdist#c.xdist c.age#c.xdist i.sex#c.xdist c.inc#c.xdist Follow that up with replace xdist = 10 if !missing(xdist) predict p1, p Change the last line to predict p1, p if e(sample) if you only want to use the same cases that were used in the estimation. Then, drop xdist clonevar xdist = dist [repeat process with remaining models; call predictions p2, p3, or whatever) Note that you run the logistic regressions using the original values of distance. You then set distance = 10 and do your predictions. By using the factor variable notation, Stata will understand how the value of distance affects both the squared term and the interaction terms. Also note that in your original example you did not have the main effects of sex, age, income or inc. I have added them, but if for some reason you really really really don't want them you should drop the main effects from the model. If you are condemned to using Stata 10 or earlier, you will need to tweak the approach so that you run the regression, and then recompute all the terms setting distance to 10 and then doing the prediction.And I would like to obtain predicted probabilities for each person when distance is set to 10. This would be easy enough if I only had this model specification. But I have several possible models (and may keep adding and changing the current ones). This is what I have so far: local chars "sex age inc" foreach varname in `chars'{ gen distX`varname' = dist*`varname' } gen dist2= dist*dist *model 1 logit choice dist dist2 ageXdist sexXdist incXdist *model 2 logit choice dist dist2 sexXdist incXdist *model 3 logit choice dist ageXdist incXdist My question is then: Is it possible to write code general enough that would calculate predicted probabilities for when distance is set to 10 for *any* of the above models? Any insights are appreciated. Thanks, Ana * * 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/------------------------------------------- Richard Williams, Notre Dame Dept of Sociology OFFICE: (574)631-6668, (574)631-6463 HOME: (574)289-5227 EMAIL: Richard.A.Williams.5@ND.Edu WWW: http://www.nd.edu/~rwilliam * * 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/

------------------------------------------- Richard Williams, Notre Dame Dept of Sociology OFFICE: (574)631-6668, (574)631-6463 HOME: (574)289-5227 EMAIL: Richard.A.Williams.5@ND.Edu WWW: http://www.nd.edu/~rwilliam * * 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: collecting interaction terms after estimation***From:*Maria Ana Vitorino <vitorino@wharton.upenn.edu>

**Re: st: collecting interaction terms after estimation***From:*Richard Williams <richardwilliams.ndu@gmail.com>

**Re: st: collecting interaction terms after estimation***From:*Maria Ana Vitorino <vitorino@wharton.upenn.edu>

- Prev by Date:
**st: spatial weight matrix in stata** - Next by Date:
**st: How do I generate dummy variable for a nuclear family?** - Previous by thread:
**Re: st: collecting interaction terms after estimation** - Next by thread:
**st: collecting interaction terms after estimation** - Index(es):