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

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

From |
Jennifer Owens <jennowensucd@yahoo.com> |

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

Subject |
Re: st: graphing predicted counts after zinb |

Date |
Sun, 5 Feb 2012 12:42:26 -0800 (PST) |

Thanks Maarten, I will give it a try. ~Jennifer ----- Original Message ----- From: Maarten Buis <maartenlbuis@gmail.com> To: statalist@hsphsun2.harvard.edu Cc: Sent: Sunday, February 5, 2012 12:53 PM Subject: Re: st: graphing predicted counts after zinb This may contain a number of tips you may find helpful: http://www.maartenbuis.nl/publications/inter_quadr.html anyhow the basic trick is to add the quadratic term as c.x.##c.x1. Hope this helps, Maarten On Sun, Feb 5, 2012 at 5:17 PM, Jennifer Owens <jennowensucd@yahoo.com> wrote: > I ran the following in STATA: > > zinb y x1 x2 x3 x4 x5 x6. . . , inflate(x4 x5 x6) vuong probit > > x1 is a continuous variable that has been centered > x2 is x1 squared > > I thought that there might be an interaction effect between x1 and x3 so I centered x3 and re-ran the above syntax with the interaction term (x1*x3). The interaction was significant so now I am trying to find a way to visually represent the interaction by graphing (1) the predicted counts for each level of x1 while holding x3 at its 25th percentile and the rest of the variables at their means and (2) the predicted counts for each level of x1 while holding x3 at its 95th percentile and the rest of the variables at their means. > > I am envisioning a graph with the predicted counts on the y-axis, each level of x1 on the x-axis, and two lines--one for x3 at its 25th percentile (i.e., 25.4) and one for x3 at its 95th percentile (e.g., 72.2). > > I thought I might be able to accomplish this by running 2 "margins" command and then graphing the results but I am running into a lot of problems. > > I tried the following: > margins x1, at(x3=25.4 x2=x1*x1) atmeans > margins x1, at(x3=72.2 x2=x1*x1) atmeans > > The first error that I got said, "'x1*x1' found where number expected." I did not think it made sense to use > the mean for the squared term (like I did for every other variable) when > calculating the expected counts for each level of x1 since > the two variables are obviously related, but I could not figure-out how > to make the margins command leave x2 alone while > setting everything else at its mean--I was hoping that > "x1*x1" would accomplish this but I guess that's not a > valid command. The error message makes it sound like > the margins command will only let you set variables at specific > values. > > > When I take out the "x2=x1*x1" from the > equation, I get the following error: > "x1: factor variables may not contain noninteger values." I think this error has to > do with x1 being centered (I have it centered to avoid > collinearity issues with its squared term). I guess the margins command will only calculate the predicted count for each level of an IV if it > only includes whole numbers. > > Now I'm thinking that the margins command is probably not the best way to accomplish creating this graph and that I'll have to go another way but I'm not sure what to try next. If anyone is familiar with graphing predicted counts after zinb, your advice would be very appreciated. > > Thanks! > > * > * 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/ -- -------------------------- Maarten L. Buis Institut fuer Soziologie Universitaet Tuebingen Wilhelmstrasse 36 72074 Tuebingen Germany http://www.maartenbuis.nl -------------------------- * * 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: graphing predicted counts after zinb***From:*Jennifer Owens <jennowensucd@yahoo.com>

**Re: st: graphing predicted counts after zinb***From:*Maarten Buis <maartenlbuis@gmail.com>

- Prev by Date:
**Re: st: SAS vs STATA : why is xtlogit SO slow ?** - Next by Date:
**Re: st: SimpleSlopes in Multilevel Models** - Previous by thread:
**Re: st: graphing predicted counts after zinb** - Next by thread:
**re:RE: st: Solution for Autocorrelation in Lag orders for VAR** - Index(es):