Bookmark and Share

Notice: On March 31, it was announced that Statalist is moving from an email list to a forum. The old list will shut down on April 23, and its replacement, statalist.org is already up and running.


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: st: Introducing constraints to biprobit model


From   Huybregts <lievenhu@gmail.com>
To   statalist@hsphsun2.harvard.edu
Subject   Re: st: Introducing constraints to biprobit model
Date   Tue, 28 Aug 2012 13:50:41 +0200

Nick, you're quite right, it' s the first time I post here, thought it would add my first message as well.
Maarten corrected mistakes in my original coding (so that's solved).  My remaining question is regarding the code he proposed. 

If I run Maarten's code, for the "model with constraints" (biprobit (cat mpg price) (foreign mpg price), constraint (1 2), 
I get the error message:
(note: constraint number 1 caused error r(111))  ( no variables defined;)
(note: constraint number 2 caused error r(111)) 
It does not seem to accept the constraints, but runs the full model nevertheless. Can I assume for this that since the constraints entail coefficients from both models, when stata runs model 1 and model 2 separately it cannot apply the constraints because they are not known yet (seems logic enough). Just to be sure. The LR test gives results do I assume that stata acknowledged the constraints (as difference in df).

Thanks for your help and sorry for the mess,
Lieven



On Aug 28, 2012, at 11:29 AM, Nick Cox wrote:

> Asking this question without showing what you typed wastes everybody's time.
> 
> What is the entire and exact syntax that you typed?
> 
> Can you reproduce Maarten's example? What is different about what you typed.
> 
> Nick
> 
> On Tue, Aug 28, 2012 at 10:29 AM, Huybregts <lievenhu@gmail.com> wrote:
>> Many thanks for the reply and the coding Maarten, however if I run the model with constraints, I get the error message:
>> (note: constraint number 1 caused error r(111))  ( no variables defined;)
>> (note: constraint number 2 caused error r(111))
>> 
>> It does not seem to accept the constraints, but runs the full model nevertheless. Can I assume for this that since the constraints entail coefficients from both models, when stata runs model 1 and model 2 separately it cannot apply the constraints because they are not known yet (seems logic enough). Just to be sure.
>> Cheers,
>> 
>> Lieven
>> 
>> 
>> 
>> 
>> On Aug 28, 2012, at 11:05 AM, Maarten Buis wrote:
>> 
>>> sysuse auto.dta,clear
>>> egen cat=cut(rep78),grou(2) label
>>> 
>>> // model without constraints
>>> biprobit (cat mpg price)      ///
>>>        (foreign mpg price)
>>> estimates store R1
>>> 
>>> // replay the model, but see the coefficient names:
>>> biprobit, coeflegend
>>> 
>>> // use those name to define the constraints
>>> constraint define 1  _b[cat:mpg]   =  _b[foreign:mpg]
>>> constraint define 2  _b[cat:price] =  _b[foreign:price]
>>> 
>>> // Model with constraints
>>> biprobit (cat mpg price) ///
>>>        (foreign mpg price), constraint (1 2)
>>> estimates store R2
>>> lrtest R1 R2



>> On Aug 28, 2012, at 10:05 AM, Huybregts wrote:
<Dear Stata listers,
<
<To test if two binary outcomes have the same underlying pattern of predictors, we compared 2 biprobit models (one with constraints, one without) using a LR test. However we encounter a <recurring error for which we can't find a solution. To make this understandable I use the auto.dta dataset to replicate our problem from a different dataset. 
<
<************************************************
sysuse auto.dta,clear
egen cat=cut(rep78),grou(2) label

* model without constraints
xi: biprobit (cat mpg price) (foreign mpg price)
estimates store R1
matrix define coef=e(b)
matrix list coef
constraint define 1 coef[1,1] = coef[1,4]
constraint define 2 coef[1,2] = coef[1,5]

* Model with constraints  
xi: biprobit (cat mpg price) (foreign mpg price), constraint (1 2)
estimates store R2
lrtest R1 R2
<************************************************
<The error I get is (just after the model with constraints)
<
<Fitting comparison equation 1:
<(note: constraint number 1 caused error r(131))
<(note: constraint number 2 caused error r(131))
<
<I did not find a similar problem on the statalist, would it be impossible for the biprobit to converge adding constraints of equal coefficients?
<I use Stata 11.1.
<Many thanks for any help anyone could provide.
<
<Lieven Huybregts


*
*   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/


© Copyright 1996–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   Site index