Generating graphs and tables following regression (nbreg)
Today, 18:40
I'm in transition from predominantly using SPPS to using Stata -- with all the learning that entails.
My biggest problem is that I can't figure out how I generate graphs and a table after running a negative binomial (nbreg) regression.
This is what I do in SPSS:
First, I run the negbin model and include this syntax to save the estimates I want:
SAVE STDPEARSONRESID STDDEVIANCERESID meanpred
This command saves:
- Predicted value of mean of response
- Standardized deviance residual, and
- Standardized Pearson residual
Second, I graph the predicted mean and deviance residual using this syntax:
GRAPH
/SCATTERPLOT(BIVAR)=MeanPredicted WITH StdDevianceResidual ... etc
[ATTACH=CONFIG]temp_6130_1477009200240_393[/ATTACH]
Third, I graph the predicted mean with a predictor variable, using this syntax:
GGRAPH
/GRAPHDATASET NAME="graphdataset" VARIABLES=example.predictor
MeanPredicted MISSING=LISTWISE REPORTMISSING=NO
/GRAPHSPEC SOURCE=INLINE.
[ATTACH=CONFIG]temp_6131_1477009266021_587[/ATTACH]
Finally, I produce a table with the count and percent of observations outside ± two standard deviations, which looks like this:
I've tried to figure out how to do this in Stata, but I've reached the point where I really would appreciate some help.
Today, 18:40
I'm in transition from predominantly using SPPS to using Stata -- with all the learning that entails.
My biggest problem is that I can't figure out how I generate graphs and a table after running a negative binomial (nbreg) regression.
This is what I do in SPSS:
First, I run the negbin model and include this syntax to save the estimates I want:
SAVE STDPEARSONRESID STDDEVIANCERESID meanpred
This command saves:
- Predicted value of mean of response
- Standardized deviance residual, and
- Standardized Pearson residual
Second, I graph the predicted mean and deviance residual using this syntax:
GRAPH
/SCATTERPLOT(BIVAR)=MeanPredicted WITH StdDevianceResidual ... etc
[ATTACH=CONFIG]temp_6130_1477009200240_393[/ATTACH]
Third, I graph the predicted mean with a predictor variable, using this syntax:
GGRAPH
/GRAPHDATASET NAME="graphdataset" VARIABLES=example.predictor
MeanPredicted MISSING=LISTWISE REPORTMISSING=NO
/GRAPHSPEC SOURCE=INLINE.
[ATTACH=CONFIG]temp_6131_1477009266021_587[/ATTACH]
Finally, I produce a table with the count and percent of observations outside ± two standard deviations, which looks like this:
PC_std.dev | N | % of Total N |
= 'Outside +- 2 Standard Deviations' | 39 | 2.30% |
= 'Within +- 2 Standard Deviations' | 1673 | 97.70% |
Total | 1712 | 100.00% |
I've tried to figure out how to do this in Stata, but I've reached the point where I really would appreciate some help.