Bookmark and Share

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


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

st: Parameter Restrictions on ML model


From   Dev Vencappa <[email protected]>
To   "[email protected]" <[email protected]>
Subject   st: Parameter Restrictions on ML model
Date   Wed, 27 Nov 2013 14:04:53 +0000

Dear Stata users, 

 I am trying to maximise a log likelihood function using method d0 and I need to impose restrictions on the parameters. Basically, in the codes below, I need to estimate parameters d, beta and T (through lnd,lnbeta,lnT).   The only variables are t and set, where set is a censoring indicator, and t is survival time taking values between  0.3 to 400 inclusive. As this is a complicated log-likelihood, I need to restrict the parameters of interest otherwise the log-likelihood returns missing values and stops. Having experimented with this in Excel (plugging in different values of d,beta,T), I calculated that to produce non-missing log-likelihood values, the following restrictions need to be applied:

0.67<d<0.998
beta> 328.9
1<T< 12.7

I experimented with these codes below and get the message: 


. ml maximize, tech(nr bhhh dfp bfgs) tol(1e-12) gtol(1e-12) force

initial:       log likelihood = -1527.7258
rescale:       log likelihood = -1527.7258
rescale eq:    log likelihood = -1527.6898
numerical derivatives are approximate
flat or discontinuous region encountered could not calculate numerical derivatives -- discontinuous region with missing values encountered could not calculate numerical derivatives -- discontinuous region with missing values encountered r(430);


I was wondering if I am doing something wrong here especially in the way I am imposing the parameter range of values?

Any help/suggestion would be very much appreciated.

Thanks and regards
Dev

capture program drop ej_d0_3het
program ej_d0_3het
	version 13.0
	args todo b lnf
	tempname d lnd beta lnbeta T lnT c0 c1 c2 c3
	tempvar  theta h1 h2 H1 H2 A
	mleval `lnd'=`b',eq(1) scalar
	mleval `lnbeta'=`b',eq(2) scalar
	mleval `lnT'=`b',eq(3) scalar
	quietly{
	scalar `d'=0.67+0.328*invlogit(`lnd')
	scalar `beta'=328.9+exp(`lnbeta')
	scalar `T'=1+11.7*invlogit(`lnT')
	scalar `c0' =(1-`d')*(`d'^-`T')
	scalar `c1'=(1-`d')*`beta'-(`d'^(1-`T'))
	scalar `c2'=`d'^(-`T')
	scalar `c3'= (1-`d')*`beta' 
	local t $ML_y1
	local set $ML_y2
	gen double `h1'=(`c0'*(`d'^`t'))/(`c1'+`c2'*(`d'^`t'))
	gen double `h2'=(`c0'*`c3'*(`d'^`t')) / ( (`c1'+`c2'*(`d'^`t'))^2)
	gen double `H1'=`c0'*(ln(`c1'+`c2'*(`d'^`t'))-ln(`c1'+`c2'))/(`c2'*ln(`d'))
	gen double `H2'=(`c0'*`c3'*((`d'^`t')-1) ) / ((`c1'+`c2'*(`d'^`t'))*(`c1'+`c2')*ln(`d'))
	gen double `A'= ( (`h1'+`h2')^`set')*exp(-(`H1'+`H2'))
	mlsum `lnf'=ln(`A')
		}
end

ml model d0 ej_d0_3het (dsetw settled = ) (lnd:) (lnbeta:) (lnT:) ml check ml graph ml maximize, tech(nr bhhh dfp bfgs) tol(1e-12) gtol(1e-12) force ml query

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:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/faqs/resources/statalist-faq/
*   http://www.ats.ucla.edu/stat/stata/


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