Transcription of Syntax - Stata
1 Negative binomial regressionSyntaxMenuDescriptionOptions for nbregOptions for gnbregRemarks and examplesStored resultsMethods and formulasReferencesAlso seeSyntaxNegative binomial regression modelnbregdepvar[indepvars] [if] [in] [weight] [,nbregoptions]Generalized negative binomial modelgnbregdepvar[indepvars] [if] [in] [weight] [,gnbregoptions]nbregoptionsDescriptionM odelnoconstantsuppress constant termdispersion(mean)parameterization of dispersion; the defaultdispersion(constant)constant dispersion for all observationsexposure(varnamee)include ln(varnamee) in model with coefficient constrained to 1offset(varnameo)includevarnameoin model with coefficient constrained to 1constraints(constraints)apply specified linear constraintscollinearkeep collinear variablesSE/Robustvce(vcetype)vcetypemay beoim,robust,clusterclustvar,opg,bootstr ap,orjackknifeReportinglevel(#)set confidence level; default islevel(95)nolrtestsuppress likelihood-ratio testirrreport incidence-rate ratiosnocnsreportdo not display constraintsdisplayoptionscontrol column formats, row spacing, line width, display of omittedvariables and base and empty cells, and factor-variable labelingMaximizationmaximizeoptionscontr ol the maximization process; seldom usedcoeflegenddisplay legend instead of statistics12 nbreg Negative binomial regressiongnbregoptionsDescriptionModeln oconstantsuppress constant termlnalpha(varlist)dispersion model variablesexposure(varnamee)include ln(varnamee) in model with coefficient constrained to 1offset(varnameo)includevarnameoin model with coefficient constrained to 1constraints(constraints)apply specified linear constraintscollinearkeep collinear variablesSE/Robustvce(vcetype)vcetypemay beoim,robust,clusterclustvar,opg,bootstr ap,orjackknifeReportinglevel(#)set confidence level.
2 Default islevel(95)irrreport incidence-rate ratiosnocnsreportdo not display constraintsdisplayoptionscontrol column formats, row spacing, line width, display of omittedvariables and base and empty cells, and factor-variable labelingMaximizationmaximizeoptionscontr ol the maximization process; seldom usedcoeflegenddisplay legend instead of statisticsindepvarsandvarlistmay contain factor variables; see[U] Factor ,indepvars,varnamee, andvarnameomay contain time-series operators (nbregonly); see[U] ,by(nbregonly),fp(nbregonly),jackknife,m fp(nbregonly),mi estimate,nestreg(nbregonly),rolling,stat sby,stepwise, andsvyare allowed; see[U] Prefix ( bootstrap )andvce(jackknife)are not allowed with themi estimateprefix; see [MI]mi are not allowed with thebootstrapprefix; see [R] ()and weights are not allowed with thesvyprefix; see [SVY] ,iweights, andpweights are allowed; see[U] not appear in the dialog [U] 20 Estimation and postestimation commandsfor more capabilities of estimation >Count outcomes>Negative binomial regressiongnbregStatistics>Count outcomes>Generalized negative binomial regressionDescriptionnbregfits a negative binomial regression model ofdepvaronindepvars, wheredepvaris anonnegative count variable.
3 In this model, the count variable is believed to be generated by a Poisson-like process, except that the variation is greater than that of a true Poisson. This extra variation isreferred to as overdispersion. See [R]poissonbefore reading this Negative binomial regression 3gnbregfits a generalization of the negative binomial mean-dispersion model; the shape parameter may also be you have panel data, see [XT]xtnbregand [ME] for nbreg Model noconstant; see [R]estimation (mean|constant)specifies the parameterization of the (mean),the default, yields a model with dispersion equal to 1+ exp(xj +offsetj); that is, the dispersionis a function of the expected mean:exp(xj +offsetj).dispersion(constant)has dispersionequal to 1+ ; that is, it is a constant for all (varnamee),offset(varnameo),constraints( constraints),collinear; see [R]esti-mation options. SE/Robust vce(vcetype)specifies the type of standard error reported, which includes types that are derived fromasymptotic theory (oim,opg), that are robust to some kinds of misspecification (robust), thatallow for intragroup correlation (clusterclustvar), and that use bootstrap or jackknife methods( bootstrap ,jackknife); see [R]vceoption.
4 Reporting level(#); see [R]estimation fitting the Poisson model. Without this option, a comparison Poisson model isfit, and the likelihood is used in a likelihood-ratio test of the null hypothesis that the dispersionparameter is estimated coefficients transformed to incidence-rate ratios, that is,e irather than errors and confidence intervals are similarly transformed. This option affects how resultsare displayed, not how they are estimated or be specified at estimation or whenreplaying previously estimated ; see [R]estimation :noomitted,vsquish,noemptycells,baseleve ls,allbaselevels,nofvla-bel,fvwrap(#),fv wrapon(style),cformat(%fmt),pformat(%fmt ),sformat(%fmt), andnolstretch; see [R]estimation options. Maximization maximizeoptions:difficult,technique(algo rithmspec),iterate(#),[no]log,trace,grad ient,showstep,hessian,showtolerance,tole rance(#),ltolerance(#),nrtolerance(#),no nrtolerance, andfrom(initspecs); see [R]maximize.
5 These options areseldom the optimization type totechnique(bhhh)resets the defaultvcetypetovce(opg).The following option is available withnbregbut is not shown in the dialog box:coeflegend; see [R]estimation nbreg Negative binomial regressionOptions for gnbreg Model noconstant; see [R]estimation (varlist)allows you to specify a linear equation for ln . Specifyinglnalpha(male old)means that ln = 0+ 1male+ 2old, where 0, 1, and 2are parameters to be estimatedalong with the other model coefficients. If this option is not specified,gnbregandnbregwillproduce the same results because the shape parameter will be parameterized as a (varnamee),offset(varnameo),constraints( constraints),collinear; see [R]esti-mation options. SE/Robust vce(vcetype)specifies the type of standard error reported, which includes types that are derived fromasymptotic theory (oim,opg), that are robust to some kinds of misspecification (robust), thatallow for intragroup correlation (clusterclustvar), and that use bootstrap or jackknife methods( bootstrap ,jackknife); see [R]vceoption.
6 Reporting level(#); see [R]estimation estimated coefficients transformed to incidence-rate ratios, that is,e irather than errors and confidence intervals are similarly transformed. This option affects how resultsare displayed, not how they are estimated or be specified at estimation or whenreplaying previously estimated ; see [R]estimation :noomitted,vsquish,noemptycells,baseleve ls,allbaselevels,nofvla-bel,fvwrap(#),fv wrapon(style),cformat(%fmt),pformat(%fmt ),sformat(%fmt), andnolstretch; see [R]estimation options. Maximization maximizeoptions:difficult,technique(algo rithmspec),iterate(#),[no]log,trace,grad ient,showstep,hessian,showtolerance,tole rance(#),ltolerance(#),nrtolerance(#),no nrtolerance, andfrom(initspecs); see [R]maximize. These options areseldom the optimization type totechnique(bhhh)resets the defaultvcetypetovce(opg).The following option is available withgnbregbut is not shown in the dialog box:coeflegend; see [R]estimation and are presented under the following headings:Introduction to negative binomial regressionnbreggnbregnbreg Negative binomial regression 5 Introduction to negative binomial regressionNegative binomial regression models the number of occurrences (counts) of an event when theevent has extra-Poisson variation, that is, when it has overdispersion.
7 The Poisson regression modelisyj Poisson( j)where j= exp(xj +offsetj)for observed countsyjwith covariatesxjfor thejth observation. One derivation of the negativebinomial mean-dispersion model is that individual units follow a Poisson regression model, but thereis an omitted variable j, such thate jfollows a gamma distribution with mean 1 and variance :yj Poisson( j)where j= exp(xj +offsetj+ j)ande j Gamma(1/ , )With this parameterization, a Gamma(a,b)distribution will have expectationaband refer to as the overdispersion parameter. The larger is, the greater the Poisson model corresponds to = as ln .gnbregallows ln to bemodeled as ln j=zj , a linear combination of fit two different parameterizations of the negative binomial model. The default, describedabove and also given by thedispersion(mean)option, has dispersion for thejth observation equalto1 + exp(xj +offsetj). This is seen by noting that the above implies that j Gamma(1/ , j)and thusVar(yj) =E{Var(yj| j)}+Var{E(yj| j)}=E( j) +Var( j)= j(1 + j)The alternative parameterization, given by thedispersion(constant)option, has dispersion equalto 1+ ; that is, it is constant for all observations.
8 This is so because the constant-dispersion modelassumes instead that j Gamma( j/ , )and thus Var(yj) = j(1 + ). The Poisson model corresponds to = detailed derivations of both models, see Cameron and Trivedi (2013, 80 89). In particular,note that the mean-dispersion model is known as theNB2model in their terminology, whereas theconstant-dispersion model is referred to as Long and Freese (2014) and Cameron and Trivedi (2010, chap. 17) for a discussion of thenegative binomial regression model with Stata examples and for a discussion of other regressionmodels for count (2011) provides an extensive review of the negative binomial model and its variations, usingStata nbreg Negative binomial regressionnbregIt is not uncommon to posit a Poisson regression model and observe a lack of model fit. Thefollowing data appeared in Rodr guez (1993):. use list, sepby(cohort)cohort age_mos deaths 168 48 63 89 1, 102 3, 81 8, 40 14, 197 48 62 1, 81 2, 97 4, 103 13, 39 19, 195 55 58 1, 85 2, 87 4, 70 9, 10 5, generate logexp = ln(exposure).
9 Poisson deaths , offset(logexp)Iteration 0: log likelihood = 1: log likelihood = 2: log likelihood = 3: log likelihood = regression Number of obs = 21LR chi2(2) = > chi2 = likelihood = Pseudo R2 = Std. Err. z P>|z| [95% Conf. Interval] .0573319 .0589726 ..0411345 (offset)nbreg Negative binomial regression 7. estat gofDeviance goodness-of-fit = > chi2(18) = goodness-of-fit = > chi2(18) = extreme significance of the goodness-of-fit 2indicates that the Poisson regression model isinappropriate, suggesting to us that we should try a negative binomial model:. nbreg deaths , offset(logexp) nologNegative binomial regression Number of obs = 21LR chi2(2) = = mean Prob > chi2 = likelihood = Pseudo R2 = Std.
10 Err. z P>|z| [95% Conf. Interval] .7237203 .7236651 ..511856 (offset) .2583615 .0876171 .4679475 test of alpha=0: chibar2(01) = Prob>=chibar2 = original Poisson model is a special case of the negative binomial it corresponds to = , however, estimates indirectly, estimating instead ln . In our model, ln = , meaningthat = (nbregundoes the transformation for us at the bottom of the output).To test =0 (equivalent to ln = ),nbregperforms a likelihood-ratio test. The staggering 2value of 4,056 asserts that the probability that we would observe these data conditional on =0is virtually zero, that is, conditional on the process being Poisson. The data are not Poisson. It is notaccidental that this 2value is close to the goodness-of-fit statistic from the Poisson regression noteThe usual Gaussian test of =0 is omitted because this test occurs on the boundary, invalidatingthe usual theory associated with such tests.