Statalist


[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

st: Error: "could not calculate numerical derivatives; missing valuesencountered" with command "ml model d0..."


From   [email protected]
To   [email protected]
Subject   st: Error: "could not calculate numerical derivatives; missing valuesencountered" with command "ml model d0..."
Date   Fri, 15 Aug 2008 21:05:46 -0700 (PDT)

Hi there, I was trying to estimate a piece-wise exponential model with discrete shared frailty with "ml model d0" command but it always stopped here. I have no clue what have caused the problem. Can you give me some suggestions that I can try? Many thanks!

The ado file that computes the lnf to be evaluated is this:

program define myereghet_dlf_sh
	version 7.0, missing
	args todo b lnf 

	tempvar beta 
	tempname theta1 theta2
	tempname pi2base
	mleval `beta' = `b', eq(1)
/* normalize theta1 to 0 */
	mleval `theta2' = `b', eq(2) scalar
	mleval `pi2base' = `b', eq(3) scalar

	local t = "$EREGt"
	local t0 = "$EREGt0"
	local d = "$EREGd"
	local by "by $EREG_by" 	

	quietly {

/* Calculate the log-likelihood */
	tempname pi1 pi2
	scalar `pi1'=1/(1+exp(`pi2base'))
	scalar `pi2'=exp(`pi2base')/(1+exp(`pi2base'))

 	        tempvar sums sumd logs dbeta sumdbeta
		gen double `logs' = exp(`beta')*(`t0'-`t') if $ML_samp
		gen double `dbeta' = `d'*`beta' if $ML_samp

		`by': gen double `sums' = cond(_n==_N, /*
			*/ sum(`logs'),.) if $ML_samp
		`by': gen double `sumd' = cond(_n==_N, /*
			*/ sum(`d'),.) if $ML_samp 
		`by': gen double `sumdbeta' = sum(`dbeta') if $ML_samp 

		mlsum `lnf' = cond(`sumd'<.,  /*
                   */ ln(`pi1'*exp( `sums' +`sumdbeta')  /*
			*/  + `pi2'*exp(exp(`theta2')*`sums'+`theta2'*`sumd'+`sumdbeta')),0)

		if `todo'==0 | `lnf'>=. {exit}
}
end



The ado file that contains the ml command has the following lines:

	version 8.1: ///
	ml model d0 myereghet_dlf_sh /*
		*/ (`t': `t'=`rhs' ,  `constant' `offopt') /*
		*/ /theta2 /pi2base `w' if `touse', `cont' noout /*
		*/ `robust' `cluopt' `scopt' `iniopt' `mlopts' /*
		*/ missing collin nopreserve /*
		*/ max search(quietly) `log' `options'  /*
*
*   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–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index