Bookmark and Share

Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at

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

st: Likelihood Maximisation for the exponential model in Survival Analysis

From   Dev Vencappa <>
To   "" <>
Subject   st: Likelihood Maximisation for the exponential model in Survival Analysis
Date   Thu, 24 Oct 2013 09:27:25 +0100

Dear Stata users, 

My attempt to code and maximise the log-likelihood from scratch for the exponential model has failed (message "could not calculate numerical derivatives -- flat or discontinuous region encountered"). My codes using the lf method are below and I would very much appreciate some pointers as to where I am going wrong with this?

Thanks and regards,

capture program drop myexp_ph_lf
program myexp_ph_lf
                *version 8.1
                args lnf llam
                quietly {
                                replace `lnf' = $ML_y2*`llam'- exp(`llam')*$ML_y1

*testing the above with the cancer data set:

sysuse cancer, clear
g drug2=drug==2
g drug3=drug==3
ml model lf myexp_ph_lf (studytime died = drug2 drug3 age) /lnlam
ml check 
ml search
ml maximize, difficult tech(nr bhhh dfp bfgs)

*but STATA streg command seems to work fine.
stset studytime, failure(died)
streg drug2 drug3 age, d(exponential)

This message and any attachment are intended solely for the addressee and may contain confidential information. If you have received this message in error, please send it back to me, and immediately delete it.   Please do not use, copy or disclose the information contained in this message or in any attachment.  Any views or opinions expressed by the author of this email do not necessarily reflect the views of the University of Nottingham.

This message has been checked for viruses but the contents of an attachment
may still contain software viruses which could damage your computer system, you are advised to perform your own checks. Email communications with the University of Nottingham may be monitored as permitted by UK legislation.

*   For searches and help try:

© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index