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: MLE for Tobit I


From   Matthew Baker <matthew.baker@hunter.cuny.edu>
To   statalist@hsphsun2.harvard.edu
Subject   Re: st: MLE for Tobit I
Date   Mon, 24 Oct 2011 13:11:30 -0400

Alba,

I'm wondering if this doesn't have something to do with the nature of
the data, or if the problem isn't occurring somewhere else.  What is
the exact error message or output you receive when you try and run the
above? I was able to get the function to work in version 11.2 as
follows.

/* Begin example */

clear all
set seed 5150
set obs 1000
gen x=invnormal(runiform())
scalar mu=.5
scalar beta=.3
gen e=invnormal(runiform())
gen y=mu+beta*x+e
gen y1=y
replace y1=0 if y<=0

capture program drop mytobit1
program mytobit1
	version 10.1
	args lnf beta sigma
	quietly replace `lnf'= log(1-normal(`beta'/`sigma')) if $ML_y1==0
	quietly replace `lnf'=
log((1/`sigma')*normalden(($ML_y1-`beta')/`sigma')) if $ML_y1>0
end

ml model lf mytobit1 (y1 = x) /sigma
ml check
ml maximize, nolog

/ * End example */

For this example, I get the output:


initial:       log likelihood =     -<inf>  (could not be evaluated)
feasible:      log likelihood = -1820.7288
rescale:       log likelihood = -1382.4015
rescale eq:    log likelihood = -1272.0074
Iteration 0:   log likelihood = -1272.0074
Iteration 1:   log likelihood = -1243.0683
Iteration 2:   log likelihood = -1240.0485
Iteration 3:   log likelihood = -1240.0446
Iteration 4:   log likelihood = -1240.0446

                                                  Number of obs   =       1000
                                                  Wald chi2(1)    =      63.71
Log likelihood = -1240.0446                       Prob > chi2     =     0.0000

------------------------------------------------------------------------------
          y1 |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
eq1          |
           x |   .2609818   .0326973     7.98   0.000     .1968964    .3250673
       _cons |   .5116592   .0336745    15.19   0.000     .4456584      .57766
-------------+----------------------------------------------------------------
sigma        |
       _cons |   .9906555   .0285645    34.68   0.000     .9346701    1.046641
------------------------------------------------------------------------------

.

So things seem to be working...

Best,

Matt Baker






On Mon, Oct 24, 2011 at 12:27 PM, Alba J. Collart-Dinarte
<ACollart@ag.tamu.edu> wrote:
> Dear Stata listers,
>
> I have a question about programming the likelihood function for Tobit models (type I, censored at zero) in STATA 10.1. This is the code I've written:
>
> program mytobit1
> version 10.1
> args lnf beta sigma
> quietly replace `lnf'= log(1-normal(`beta'/`sigma')) if $ML_y1==0
> quietly replace `lnf'= log((1/`sigma')*normalden(($ML_y1-`beta')/`sigma')) if $ML_y1>0
> end
>
> ml model lf mytobit1 (y1 = x) /sigma
> ml check
> ml maximize, nolog
>
> but it does not run. I believe that there is a problem in the way I define the likelihood function. I have looked into Gould, Pitblado and Poi (2010), but they mainly discuss probit, normal and weibull models.
>
> I have also tried:
> quietly replace `lnf'= cond($ML_y1==0,log(1-normal(`beta',`sigma')),log((1/`sigma')*normalden($ML_y1,`beta',`sigma')))
> and using normalden($ML_y1,`beta',`sigma') - instead of - normalden(($ML_y1-`beta')/`sigma')
> but no success.
>
> Any suggestions on how can I fix the code would be greatly appreciated.
>
> Thank you very much in advance!
>
> Alba Collart
> *
> *   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/
>



-- 
Dr. Matthew J. Baker
Department of Economics
Hunter College and the Graduate Center, CUNY

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