Notice: On March 31, it was **announced** that Statalist is moving from an email list to a **forum**. The old list will shut down on April 23, and its replacement, **statalist.org** is already up and running.

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

From |
Maria Ana Vitorino <vitorino@wharton.upenn.edu> |

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

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

Date |
Sat, 5 Nov 2011 13:34:12 -0400 |

Dear Richard, Thanks for your suggestions.

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 factorvariable notation instead.clonevar xdist = distlogit choice i.sex xdist age inc c.xdist#c.xdist c.age#c.xdisti.sex#c.xdist c.inc#c.xdistFollow 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 theestimation.Then, drop xdist clonevar xdist = dist[repeat process with remaining models; call predictions p2, p3, orwhatever)Note that you run the logistic regressions using the original valuesof distance. You then set distance = 10 and do your predictions. Byusing the factor variable notation, Stata will understand how thevalue of distance affects both the squared term and the interactionterms.Also note that in your original example you did not have the maineffects of sex, age, income or inc. I have added them, but if forsome reason you really really really don't want them you should dropthe main effects from the model.If you are condemned to using Stata 10 or earlier, you will need totweak the approach so that you run the regression, and thenrecompute all the terms setting distance to 10 and then doing theprediction.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 thatwould calculate predicted probabilities for when distance is set to10for *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/

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

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

- Prev by Date:
**Re: st: collecting interaction terms after estimation** - Next by Date:
**st: using a loop to run multiple regression models** - Previous by thread:
**Re: st: collecting interaction terms after estimation** - Next by thread:
**Re: st: collecting interaction terms after estimation** - Index(es):