Bookmark and Share

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]

st: Getting r303 error using constrained nbreg


From   "Matthew Dobra" <[email protected]>
To   <[email protected]>
Subject   st: Getting r303 error using constrained nbreg
Date   Mon, 05 Aug 2013 10:31:35 -0400

Hi Statalisters,

I'm using Stata13 and getting this error with nbreg:


(note: constraint number 1 caused error r(303)) 


I'm not sure why I am getting this error, and IIRC I think I remember my code working just fine on Stata12, though I can't check because I no longer have that computer. Moreover, in spite of the error, Stata seems to still do the constrained nbreg.  I'm generally confused and any help would be appreciated.

Essentially, I'm trying to estimate a pseudo R2 a la Cameron and Windmeijer (1996).  If I understand their paper correctly, the steps are to estimate the nbreg, then estimate a constant only nbreg with the constraint that the delta from the constant only nbreg is the same as the delta from the main nbreg.   Then a bunch of stuff after that, but my only issue is with the constrained constant only nbreg.

The troublesome lines of code look like this:

local indepvars "var1 var2 var3"
nbreg depvar`indepvars', robust disp(constant)
local dv=e(depvar)
local xxx=ln(e(delta))
constraint define 1 [lndelta]_cons=`xxx'
nbreg `dv', robust disp(constant) constraint(1)

The last line gives the error.  However, when I look at the output in the results window, it appears as though it still takes into account the constraint.  Sorry about the spacing, but it sure looks like despite the error it still did exactly what I asked it to do.

. nbreg `dv', dispersion(constant) constraint(1)


Fitting Poisson model:
(note: constraint number 1 caused error r(303))


Iteration 0:   log likelihood = -13616.498  
Iteration 1:   log likelihood = -13616.498  


Fitting constant-only model:


Iteration 0:   log likelihood = -3247.7983  
Iteration 1:   log likelihood =  -3213.037  
Iteration 2:   log likelihood = -3212.9406  
Iteration 3:   log likelihood = -3212.9406  


Fitting full model:


Iteration 0:   log likelihood = -3212.9406  
Iteration 1:   log likelihood = -3212.9406  


Negative binomial regression                      Number of obs   =        758
Dispersion     = constant                         Wald chi2(0)    =          .
Log likelihood = -3212.9406                       Prob > chi2     =          .


 ( 1)  [lndelta]_cons = 3.351031
--------------------------------------------------------------------------------
depvar |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
---------------+----------------------------------------------------------------
         _cons |   3.020687   .0343135    88.03   0.000     2.953433     3.08794
---------------+----------------------------------------------------------------
      /lndelta |   3.351031  (constrained)
---------------+----------------------------------------------------------------
         delta |   28.53215  (constrained)
--------------------------------------------------------------------------------



And 3.351031 is the number that it should be.  So I'm confused, since it is giving me an error yet it appears to be doing exactly what I'm asking it to do?

FWIW I've messed around with a number of things on my own here, including eliminating the robust option, changing the dispersion away from constant (and correspondingly the deltas to alphas), and doing it interactively rather than via dofile.  None of those changes the results.  


My best guess is that the error is encountered because nbreg estimates both a poisson and an nbreg (to test whether the nbreg is a better fit than the poisson) and it's actually encountering the error when trying to force the delta constraint into the poisson, which doesn't have that parameter.  In which case I think I can just ignore the error altogether since I don't care testing the nbreg vs. the poisson.


Any advice, suggestions, or even better yet answers would be awesome!!! Thanks in advance!



*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/faqs/resources/statalist-faq/
*   http://www.ats.ucla.edu/stat/stata/


© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index