Dear Statalist members,
I'm trying to plot the number of predicted events per month over time for different age groups, based on a negative binomial regression model. My general coding procedure, after setting the time and id-variables with -xtset- is as follows:
I've previously calculated and plotted similar linear (-xtreg-) and poisson (-xtpoisson-) regression models, which both estimate the expected number of events to be around ~5 per month. Since, from my understanding, the main difference between poisson and negative binomial models is that the latter better accounts for overdispersion (which my data suffers from), I wouldn't expect the plotted trendlines between the two to differ much. The incidence rate ratios also seem to match quite closely between the two models. In this case, however, while the poisson predicted number of events hover around 5-6 per month when plotted, the negative binomial model seems to hover around just 1 event/month. Further, the trendline is almost flat for the negative binomial plot while the poisson trendlines seem to increase much more meaningfully, despite very similar incidence rate ratios in the regression tables.
I can't tell if my code for plotting the negative binomial model is just wrong (the approach is a copy of my -xtpoisson- plotting code), or if it's my understanding of negative binomial regression models that is lacking. Can someone please help me shed some light on this?
As a side question, I can't seem to produce margins for my -xtnbreg- model if I rely on random effects instead of fixed effects. I've since read suggestions that fixed/random effects for -xtnbreg- does not quite operate the way I would expect for -xtpoisson-. From my own experience, the fixed effects negative binomial regression model suddenly doesn't drop time-invariant predictors. How can this happen and what's the difference when using fixed/random effects in -xtnbreg-?
I've tried to make my question somewhat general, but please let me know if you need me to provide further details or clarify the question further.
Thanks in advance!
I'm trying to plot the number of predicted events per month over time for different age groups, based on a negative binomial regression model. My general coding procedure, after setting the time and id-variables with -xtset- is as follows:
:
xtnbreg count c.month##agegroups, fe irr margins i.agegroups, at(month=(1(1)36) predict(nu0) marginsplot
I can't tell if my code for plotting the negative binomial model is just wrong (the approach is a copy of my -xtpoisson- plotting code), or if it's my understanding of negative binomial regression models that is lacking. Can someone please help me shed some light on this?
As a side question, I can't seem to produce margins for my -xtnbreg- model if I rely on random effects instead of fixed effects. I've since read suggestions that fixed/random effects for -xtnbreg- does not quite operate the way I would expect for -xtpoisson-. From my own experience, the fixed effects negative binomial regression model suddenly doesn't drop time-invariant predictors. How can this happen and what's the difference when using fixed/random effects in -xtnbreg-?
I've tried to make my question somewhat general, but please let me know if you need me to provide further details or clarify the question further.
Thanks in advance!