*! version 1.2.0 3 April 2013
help r2c

Title

Computes several goodness of fit measures for count data models

Syntax

r2c [, NODp NOOffsetadj DEVonly ESTDisp GNBCons]

Description

r2c generates r-squared fit statistics based on deviance, likelihood ratio, Pearson deviance, squared correlation, and predicted value
sums of squares. Cameron and Windmeijer (1996) recommend the use of the deviance-based R2 (which produces identical results to the
user-written devr2 command for glm; findit devr2). r2c also produces an adjusted deviance-based r-squared
metric based on Heinzl and Mittlböck (2003). The negative binomial adjustment is based on an overdispersed Poisson model.
The r2c command is specific to count data models but covers most built-in count data commands. At current, r2c works only with
the built-in commands poisson, tpoisson, zip, nbreg, tnbreg, gnbreg, zinb, and glm (with
glm, r2c works only for count-based variance functions family(poisson) and family(nbinomial) and assumes the default
link(log)).

r2c adjusts fit statistics automatically for sample weights (see [R] weight) as well as offset or exposure variables (see
estimation options). r2c also adjusts estimates for the svy and mi prefixes.

Important note for mi estimate models: When using the mi prefix, all mi imputed variables must have spaces between them and all other characters
in order for the r2c mi syntax parser to properly identify and compute all versions of a multiply imputed variable. Thus, for r2c to
appropriately adjust the computed fit statistics for mi, all imputed variables in the model or other options must be separated from
all commas, operators, and parentheses by at least one space. For example, an imputed predictor in a zero-inflated model in the inflate(varlist) equation
must specifiy their syntax as inflate( predictor ) and not as inflate(predictor).

Options

nodp suppresses computation and display of the deviance-based R2 measure comparing the fitted negative binomial model with a
Poisson model specification. The DP R2 is a ratio of the deviance of the full negative binomial model being fitted from a saturated
Poisson model over the deviance of the constant-only Poisson from a saturated Poisson. The DP R2 then allows for a direct comparison between
negative binomial and Poisson models (see Cameron and Windmeijer, 1996; for details). As Cameron and Windmeijer note, a large DP R2 would
be expected in cases where there is a substantial alpha (NB2; dispersion(mean)) or delta (NB1; dispersion(constant)) value, as
large alpha/delta values represent substantial overdispersion. It is worth noting that the DP R2 baseline Poisson model is adjusted for
truncation with tnbreg and zero-inflation with zinb.

nooffsetadj overrides the default constant-only model adjustment for the inclusion of an offset or exposure variable. Overriding
the offset adjustment is useful to discern the extent to which offsets are useful or informative adjustments in a count model.
Note that nooffsetadj suppresses all offsets or exposures - including offsets in the inflate(varlist) portion of zero-inflated
models.

devonly overrides the default computation and display of the Pearson deviance, correlation, and explained variance R2s.

estdisp overrides the default constraint holding the overdispersion parameter (i.e., alpha for NB2 or delta for NB1) constant across
full and constant-only negative Binomial models and re-estimates the lnalpha or lndelta equation from the data. The estdisp option only
affects computation of the deviance R2, DP R2, as well as the McFadden's likelihood ratio R2. Also note that the McFadden's likelihood ratio R2
will only match the pseudo-R2 output generated by nbreg, tnbreg, and gnbreg when using the estdisp option.

gnbcons fits a estimates a constant-only lnalpha(varlist) equation from the data in the contant-only model for a gnbreg-based
r2c computation. The default is to hold the lnalpha(varlist) equation constant across full and constant-only models. The gnbcons option
effectively makes the constant-only model comparison to a traditional nbreg instead of a full gnbreg and can be useful to discern how well
the lnalpha(varlist) equation improves fit beyond a nbreg. To re-estimate the full lnalpha(varlist) equation for the constant-only
model with gnbreg, use the estdisp option instead.

Saved results

r2c adds the following results to e():

Scalars

e(dev_r2) Deviance-based R2

e(dev_r2a) Bias-adjusted deviance-based R2

e(McF) McFadden's likelihood ratio R2

e(pear_r2) Pearson deviance-based R2

e(corr_r2) Squared correlation between observed and predicted values

e(exp_r2) Ratio of sums of squared differences of predicted values (i.e., explained SS) over observed values (i.e., total SS)

e(modeldev) Deviance based on full model

e(constdev) Deviance based on constant only model

e(modelpear) Pearson deviance based on full model

e(constpear) Pearson deviance based on constant only model

e(expvar) Predicted value variance

e(dp_r2) Ratio of the deviance for a fitted negative binomial model over the deviance for a constant-only Poisson model

e(modeldp) DP deviance based on full model compared to saturated Poisson

e(constdp) DP deviance based on constant only model compared to saturated Poisson

Introductory examples

To illustrate how r2c works click on colored text below:

. webuse auto

* r2c following traditional Poisson regression.

. poisson price mpg rep78 headroom

. r2c

* r2c following negative binomial (NB1 or constant dispersion method)

. nbreg price mpg rep78 headroom, dispersion(constant)

. r2c, devonly

References

Cameron, A. C. & Windmeijer, F. A. G. (1996). R-squared measures for count data regression models with applications to health-care
utilization. Journal of Business & Economic Statistics, 14(2), 209-220.

Heinzl, H. & Mittlböck, M. (2003). Pseudo R-squared measures for Poisson regression models with over- or under-dispersion.
Computational Statistics & Data Analysis, 44(1-2), 253-271.

Author

Joseph N. Luchman

Senior Research Associate

Fors Marsh Group LLC

Arlington, VA

jluchman@forsmarshgroup.com

Also see

[R] poisson,
[R] zip,
[R] tpoisson,
[R] nbreg,
[R] gnbreg,
[R] tnbreg,
[R] zinb,
[R] glm,
[R] svy,
[R] mi.