Stata The Stata listserver
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

st: maximum likelihood estimation weibull model with sample selection


From   "Kok Jb (OS)" <Jb.Kok@os.unimaas.nl>
To   <statalist@hsphsun2.harvard.edu>
Subject   st: maximum likelihood estimation weibull model with sample selection
Date   Mon, 14 Feb 2005 17:10:52 +0100

Hello,

I am trying to model a weibull model with sample selection in stata 8.2.
My problem is that Stata produces unsatisfactory output. I have the
feeling that rounding in the maximization routines contribute to these
results but I am not sure. I provide the output from my do-file. 

sysuse cancer, clear
(Patient Survival in Drug Trial)

. 
. gen drug2 = drug == 2

. gen drug3 = drug == 3

. 
. 
. /*
> WEIBULL MODEL WITH SAMPLE SELECTION FROM RIGHT TRUNCATED SPELL DATA
(OUTFLOW SAMPLE)
> 
> The likelihood for this model is given by
> 
> (1) L = f(t) / F(t)                             (control for a
overrepresentation of short spells relative to long spells)
> 
> with weibull density function (see Maximum Likelihood Estimation with
Stata (2nd edition), 2004: page 221)
> 
> f(t; e, g) = (e/g) *(t/e)^(g-1) * exp(-(t/e)^g
> 
> and failure function
> 
> F(t; e, g) = 1 -  exp(-t/e)^g
> 
> with parameters  (gamma) g and (eta) e=exp(Xb)
> */
. 
. capture program drop myweibull_sampleselection_lf

. 
. program myweibull_sampleselection_lf
  1.         version 8.1
  2.         args lnf leta lgam
  3.         tempvar p M R
  4.         quietly         {
  5.                         gen double `p'  = exp(`lgam')
  6.                         gen double `M' = ($ML_y1*exp(-`leta'))^`p'
  7.                         gen double `R' = ln($ML_y1)-`leta'
  8.                         replace `lnf' =   -`M' + $ML_y2 * (`lgam' -
`leta' + (`p'-1) * `R') - ln(1-(exp(-`M')))
  9.                 }
 10. end

. 
. 
. ml model lf myweibull_sampleselection_lf (lneta: studytime died =
drug2 drug3 age)/ lngamma

. 
. ml maximize

initial:       log likelihood =  -742.8257
alternative:   log likelihood = -355.05562
rescale:       log likelihood = -192.23867
rescale eq:    log likelihood =  452.20041
Iteration 0:   log likelihood =  452.20041  (not concave)
Iteration 1:   log likelihood =  452.31598  (not concave)
Iteration 2:   log likelihood =  452.35131  (not concave)
Iteration 3:   log likelihood =  452.35485  
Iteration 4:   log likelihood =  452.36837  (not concave)
Iteration 5:   log likelihood =  452.36972  (not concave)
Iteration 6:   log likelihood =  452.36999  (not concave)
numerical derivatives are approximate
flat or discontinuous region encountered
numerical derivatives are approximate
nearby values are missing
Iteration 7:   log likelihood =  452.37005  (not concave)
numerical derivatives are approximate
flat or discontinuous region encountered
numerical derivatives are approximate
flat or discontinuous region encountered
Iteration 8:   log likelihood =  452.37005  (not concave)
numerical derivatives are approximate
flat or discontinuous region encountered
numerical derivatives are approximate
flat or discontinuous region encountered



I would really appreciate anyone's ideas about this issue.

Best regards,

Jasper Kok
Ph-D student
Maastricht University
Netherlands

*
*   For searches and help try:
*   http://www.stata.com/support/faqs/res/findit.html
*   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   |   What's new   |   Site index