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]
Re: st: graphing predicted counts after zinb
From
Maarten Buis <[email protected]>
To
[email protected]
Subject
Re: st: graphing predicted counts after zinb
Date
Sun, 5 Feb 2012 18:53:54 +0100
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 <[email protected]> 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/