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 at the end of May, 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   Nick Cox <njcoxstata@gmail.com>
To   statalist@hsphsun2.harvard.edu
Subject   Re: st: Introducing constraints to biprobit model
Date   Tue, 28 Aug 2012 16:54:10 +0100

Someone with experience with these models should now be able to comment.

Nick

On Tue, Aug 28, 2012 at 4:38 PM, Huybregts <lievenhu@gmail.com> wrote:
> Dear Nick, I think there was a misunderstanding. I did post the syntax, but I think you want to see the output. Here is the  complete output. First the syntax I have been using, which didn't work, then What Maarten wrote, which is much better. However, I have a remaining question on the r111 error. I don't know if the results obtained by the LR test are correct.
> Many thanks for any feedback you can provide on this and my apologies for misunderstanding. I did read the rules well to make this as clear as possible. I use Stata 11.1.
> Lieven
>
>
> First you can see  what I have been doing, which didn't work:
>
>  /*My original synthax */
> . sysuse auto.dta,clear
> (1978 Automobile Data)
>
> . egen cat=cut(rep78),grou(2) label
> (5 missing values generated)
>
> .
> . // model without constraints
> . xi: biprobit (cat mpg price) (foreign mpg price)
>
> Fitting comparison equation 1:
>
> Iteration 0:   log likelihood = -28.552789
> Iteration 1:   log likelihood = -27.110671
> Iteration 2:   log likelihood = -27.076711
> Iteration 3:   log likelihood = -27.076625
> Iteration 4:   log likelihood = -27.076625
>
> Fitting comparison equation 2:
>
> Iteration 0:   log likelihood = -42.400729
> Iteration 1:   log likelihood = -33.271394
> Iteration 2:   log likelihood = -33.188125
> Iteration 3:   log likelihood = -33.188014
> Iteration 4:   log likelihood = -33.188014
>
> Comparison:    log likelihood =  -60.26464
>
> Fitting full model:
>
> Iteration 0:   log likelihood =  -60.26464
> Iteration 1:   log likelihood = -57.973106
> Iteration 2:   log likelihood = -57.880512
> Iteration 3:   log likelihood = -57.873467
> Iteration 4:   log likelihood = -57.873061
> Iteration 5:   log likelihood = -57.873057
>
> Seemingly unrelated bivariate probit              Number of obs   =         69
>                                                   Wald chi2(4)    =      14.79
> Log likelihood = -57.873057                       Prob > chi2     =     0.0052
>
> ------------------------------------------------------------------------------
>              |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
> -------------+----------------------------------------------------------------
> cat          |
>          mpg |   .0710587   .0454513     1.56   0.118    -.0180242    .1601416
>        price |   .0000924   .0000748     1.24   0.216    -.0000541    .0002389
>        _cons |  -.9485728   1.211113    -0.78   0.433    -3.322311    1.425166
> -------------+----------------------------------------------------------------
> foreign      |
>          mpg |    .140959   .0373519     3.77   0.000     .0677506    .2141674
>        price |   .0001253   .0000681     1.84   0.066    -8.08e-06    .0002588
>        _cons |  -4.377398   1.114323    -3.93   0.000    -6.561432   -2.193365
> -------------+----------------------------------------------------------------
>      /athrho |   1.259137   2.237519     0.56   0.574     -3.12632    5.644595
> -------------+----------------------------------------------------------------
>          rho |   .8508261   .6177676                     -.9961567     .999975
> ------------------------------------------------------------------------------
> Likelihood-ratio test of rho=0:     chi2(1) =  4.78317    Prob > chi2 = 0.0287
>
> . estimates store R1
>
> . matrix define coef=e(b)
>
> . matrix list coef
>
> coef[1,7]
>            cat:        cat:        cat:    foreign:    foreign:    foreign:     athrho:
>            mpg       price       _cons         mpg       price       _cons       _cons
> y1   .07105866   .00009241  -.94857276   .14095901   .00012534  -4.3773984   1.2591375
>
> . 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)
>
> Fitting comparison equation 1:
>
> (note: constraint number 1 caused error r(131))
> (note: constraint number 2 caused error r(131))
> Iteration 0:   log likelihood = -28.552789
> Iteration 1:   log likelihood = -27.110671
> Iteration 2:   log likelihood = -27.076711
> Iteration 3:   log likelihood = -27.076625
> Iteration 4:   log likelihood = -27.076625
>
> Fitting comparison equation 2:
>
> (note: constraint number 1 caused error r(131))
> (note: constraint number 2 caused error r(131))
> Iteration 0:   log likelihood = -42.400729
> Iteration 1:   log likelihood = -33.271394
> Iteration 2:   log likelihood = -33.188125
> Iteration 3:   log likelihood = -33.188014
> Iteration 4:   log likelihood = -33.188014
>
> Comparison:    log likelihood =  -60.26464
>
> Fitting full model:
> (note: constraint number 1 caused error r(131))
> (note: constraint number 2 caused error r(131))
>
> Iteration 0:   log likelihood =  -60.26464
> Iteration 1:   log likelihood = -57.973106
> Iteration 2:   log likelihood = -57.880512
> Iteration 3:   log likelihood = -57.873467
> Iteration 4:   log likelihood = -57.873061
> Iteration 5:   log likelihood = -57.873057
>
> Seemingly unrelated bivariate probit              Number of obs   =         69
>                                                   Wald chi2(4)    =      14.79
> Log likelihood = -57.873057                       Prob > chi2     =     0.0052
>
> ------------------------------------------------------------------------------
>              |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
> -------------+----------------------------------------------------------------
> cat          |
>          mpg |   .0710587   .0454513     1.56   0.118    -.0180242    .1601416
>        price |   .0000924   .0000748     1.24   0.216    -.0000541    .0002389
>        _cons |  -.9485728   1.211113    -0.78   0.433    -3.322311    1.425166
> -------------+----------------------------------------------------------------
> foreign      |
>          mpg |    .140959   .0373519     3.77   0.000     .0677506    .2141674
>        price |   .0001253   .0000681     1.84   0.066    -8.08e-06    .0002588
>        _cons |  -4.377398   1.114323    -3.93   0.000    -6.561432   -2.193365
> -------------+----------------------------------------------------------------
>      /athrho |   1.259137   2.237519     0.56   0.574     -3.12632    5.644595
> -------------+----------------------------------------------------------------
>          rho |   .8508261   .6177676                     -.9961567     .999975
> ------------------------------------------------------------------------------
> Likelihood-ratio test of rho=0:     chi2(1) =  4.78317    Prob > chi2 = 0.0287
>
> . estimates store R2
>
> . lrtest R1 R2
> df(unrestricted) = df(restricted) = 7
> r(498);
> end of do-file
>
>
>
> Here you can see what Maarten proposed in his previous posting, my question is how to interpret the (note: constraint number 2 caused error r(111)).
>
> . /*  Maarten's proposal */
> . sysuse auto.dta,clear
> (1978 Automobile Data)
>
> . egen cat=cut(rep78),grou(2) label
> (5 missing values generated)
>
> .
> . // model without constraints
> . biprobit (cat mpg price)      ///
>>         (foreign mpg price)
>
> Fitting comparison equation 1:
>
> Iteration 0:   log likelihood = -28.552789
> Iteration 1:   log likelihood = -27.110671
> Iteration 2:   log likelihood = -27.076711
> Iteration 3:   log likelihood = -27.076625
> Iteration 4:   log likelihood = -27.076625
>
> Fitting comparison equation 2:
>
> Iteration 0:   log likelihood = -42.400729
> Iteration 1:   log likelihood = -33.271394
> Iteration 2:   log likelihood = -33.188125
> Iteration 3:   log likelihood = -33.188014
> Iteration 4:   log likelihood = -33.188014
>
> Comparison:    log likelihood =  -60.26464
>
> Fitting full model:
>
> Iteration 0:   log likelihood =  -60.26464
> Iteration 1:   log likelihood = -57.973106
> Iteration 2:   log likelihood = -57.880512
> Iteration 3:   log likelihood = -57.873467
> Iteration 4:   log likelihood = -57.873061
> Iteration 5:   log likelihood = -57.873057
>
> Seemingly unrelated bivariate probit              Number of obs   =         69
>                                                   Wald chi2(4)    =      14.79
> Log likelihood = -57.873057                       Prob > chi2     =     0.0052
>
> ------------------------------------------------------------------------------
>              |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
> -------------+----------------------------------------------------------------
> cat          |
>          mpg |   .0710587   .0454513     1.56   0.118    -.0180242    .1601416
>        price |   .0000924   .0000748     1.24   0.216    -.0000541    .0002389
>        _cons |  -.9485728   1.211113    -0.78   0.433    -3.322311    1.425166
> -------------+----------------------------------------------------------------
> foreign      |
>          mpg |    .140959   .0373519     3.77   0.000     .0677506    .2141674
>        price |   .0001253   .0000681     1.84   0.066    -8.08e-06    .0002588
>        _cons |  -4.377398   1.114323    -3.93   0.000    -6.561432   -2.193365
> -------------+----------------------------------------------------------------
>      /athrho |   1.259137   2.237519     0.56   0.574     -3.12632    5.644595
> -------------+----------------------------------------------------------------
>          rho |   .8508261   .6177676                     -.9961567     .999975
> ------------------------------------------------------------------------------
> Likelihood-ratio test of rho=0:     chi2(1) =  4.78317    Prob > chi2 = 0.0287
>
> . estimates store R1
>
> .
> . // replay the model, but see the coefficient names:
> . biprobit, coeflegend
>
> Seemingly unrelated bivariate probit              Number of obs   =         69
>                                                   Wald chi2(4)    =      14.79
> Log likelihood = -57.873057                       Prob > chi2     =     0.0052
>
> ------------------------------------------------------------------------------
>              |      Coef.  Legend
> -------------+----------------------------------------------------------------
> cat          |
>          mpg |   .0710587  _b[cat:mpg]
>        price |   .0000924  _b[cat:price]
>        _cons |  -.9485728  _b[cat:_cons]
> -------------+----------------------------------------------------------------
> foreign      |
>          mpg |    .140959  _b[foreign:mpg]
>        price |   .0001253  _b[foreign:price]
>        _cons |  -4.377398  _b[foreign:_cons]
> -------------+----------------------------------------------------------------
>      /athrho |   1.259137  _b[athrho:_cons]
> -------------+----------------------------------------------------------------
>          rho |   .8508261
> ------------------------------------------------------------------------------
> Likelihood-ratio test of rho=0:     chi2(1) =  4.78317    Prob > chi2 = 0.0287
>
> .
> . // 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)
>
> Fitting comparison equation 1:
>
> (note: constraint number 1 caused error r(111))
> (note: constraint number 2 caused error r(111))
> Iteration 0:   log likelihood = -28.552789
> Iteration 1:   log likelihood = -27.110671
> Iteration 2:   log likelihood = -27.076711
> Iteration 3:   log likelihood = -27.076625
> Iteration 4:   log likelihood = -27.076625
>
> Fitting comparison equation 2:
>
> (note: constraint number 1 caused error r(111))
> (note: constraint number 2 caused error r(111))
> Iteration 0:   log likelihood = -42.400729
> Iteration 1:   log likelihood = -33.271394
> Iteration 2:   log likelihood = -33.188125
> Iteration 3:   log likelihood = -33.188014
> Iteration 4:   log likelihood = -33.188014
>
> Comparison:    log likelihood =  -60.26464
>
> Fitting full model:
>
> Iteration 0:   log likelihood = -83.049875
> Iteration 1:   log likelihood = -65.030586  (not concave)
> Iteration 2:   log likelihood = -59.728978
> Iteration 3:   log likelihood = -58.803484
> Iteration 4:   log likelihood = -58.800879
> Iteration 5:   log likelihood = -58.800664
> Iteration 6:   log likelihood = -58.800664
>
> Seemingly unrelated bivariate probit              Number of obs   =         69
>                                                   Wald chi2(2)    =      14.07
> Log likelihood = -58.800664                       Prob > chi2     =     0.0009
>
>  ( 1)  [cat]mpg - [foreign]mpg = 0
>  ( 2)  [cat]price - [foreign]price = 0
> ------------------------------------------------------------------------------
>              |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
> -------------+----------------------------------------------------------------
> cat          |
>          mpg |   .1214969   .0324577     3.74   0.000      .057881    .1851127
>        price |   .0001177   .0000556     2.12   0.034     8.82e-06    .0002267
>        _cons |  -2.072698   .8765444    -2.36   0.018    -3.790693   -.3547025
> -------------+----------------------------------------------------------------
> foreign      |
>          mpg |   .1214969   .0324577     3.74   0.000      .057881    .1851127
>        price |   .0001177   .0000556     2.12   0.034     8.82e-06    .0002267
>        _cons |  -3.888234   .9489108    -4.10   0.000    -5.748065   -2.028403
> -------------+----------------------------------------------------------------
>      /athrho |   1.776488   175.2688     0.01   0.992     -341.744    345.2969
> -------------+----------------------------------------------------------------
>          rho |   .9443162   18.97581                            -1           1
> ------------------------------------------------------------------------------
> Likelihood-ratio test of rho=0:     chi2(1) =  2.92795    Prob > chi2 = 0.0871
>
> . estimates store R2
>
> . lrtest R1 R2
>
> Likelihood-ratio test                                  LR chi2(2)  =      1.86
> (Assumption: R2 nested in R1)                          Prob > chi2 =    0.3955
>
> .
> end of do-file
>
>
>
>
>
>
> On Aug 28, 2012, at 3:35 PM, Nick Cox wrote:
>
>> There is plenty of good will to help you, but there is no way round
>> this: you have yet to post the entire syntax that you used. So I don't
>> think anyone can see what you are doing wrong even in trying to
>> reproduce Maarten's example. This logic should seem compelling even to
>> first-time posters.
>>
>> Nick
>>
>> On Tue, Aug 28, 2012 at 12:50 PM, Huybregts <lievenhu@gmail.com> wrote:
>>> 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.
>>> <
>>
>> *
>> *   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/

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