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]
Re: st: -intgph nbreg- drops interaction variables
From
Nick Cox <[email protected]>
To
[email protected]
Subject
Re: st: -intgph nbreg- drops interaction variables
Date
Tue, 15 Mar 2011 00:28:34 +0000
Thanks. I did not understand that from the original post.
In either case, a direct test of -poisson- and -nbreg- with and
without the aegis of -intgph- would establish what is biting.
Nick
On Mon, Mar 14, 2011 at 9:58 PM, Joerg Luedicke
<[email protected]> wrote:
> On Mon, Mar 14, 2011 at 1:05 PM, Nick Cox <[email protected]> wrote:
>
>>
>> As many other threads show, Stata often drops (meaning, omits) variables from models. This is deliberate and indeed a feature. The fix is not to try to force them back in. The fix is to find a better model for your data (or, for some purposes, better data for your model).
>>
>> Nick
>> [email protected]
>>
>
> Nick, I think OP does not have a problem with the model itself but
> with the user written command -intgph-.
>
> I had a look at the respective ado-file and I believe that this could
> be some bug in the program. Unlike the other allowed models for that
> program, nbreg provides 2 variables in the e(b) matrix as "_cons", one
> is the constant and the other is the overdispersion parameter. I have
> the feeling that -intgph- is not accounting for the fact that there
> are these 2 extra columns instead of only 1, like it is in case of the
> other models. Look at this code from line 210 of -intgph- (it says
> Version 1.0.2, I downloaded it today):
>
> capture `cmd' `varlist' `if' `in' `weight' , `cmdopts'
> if _rc == 0 {
> // regenerate the varlist in case not all vars are used in model
> tempname cmat
> matrix `cmat' = e(b)
> local evlist : colnames `cmat'
> local evlist " `evlist' "
> local varlist : subinstr local evlist " _cons " "" // drop _cons
> local varlist `e(depvar)' `varlist'
> local depvar `e(depvar)'
>
> This part of the program is producing a varlist from the model
> specified under `cmd'. The line that is commented on (" // drop
> _cons") is dropping "_cons" but I guess this should be done twice. The
> part that produces OPs error message comes from lines 241 and 243
> further down because the interaction term cannot be found due to the
> added "_cons". However, if I exchange the above code with the
> following (only 2 lines added):
>
> capture `cmd' `varlist' `if' `in' `weight' , `cmdopts'
> if _rc == 0 {
> // regenerate the varlist in case not all vars are used in model
> tempname cmat
> matrix `cmat' = e(b)
> local evlist : colnames `cmat'
> local evlist " `evlist' "
> local varlist : subinstr local evlist " _cons " "" // drop _cons
> local varlist " `varlist' "
> <---------- line added
> local varlist : subinstr local varlist "_cons " "" // drop _cons
> <---------- line added
> local varlist `e(depvar)' `varlist'
> local depvar `e(depvar)'
>
> the program seems to work fine. At least, it runs without error
> message, spits out the correct results from the regression model, and
> produces this graph. However, additional checks may be needed and I
> guess the best would be if somebody contacted the authors about this.
>
> J.
>
> *
> * For searches and help try:
> * http://www.stata.com/help.cgi?search
> * http://www.stata.com/support/statalist/faq
> * http://www.ats.ucla.edu/stat/stata/
>
*
* For searches and help try:
* http://www.stata.com/help.cgi?search
* http://www.stata.com/support/statalist/faq
* http://www.ats.ucla.edu/stat/stata/