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

st: Nonlinear ML


From   Ed Blackburne <[email protected]>
To   [email protected]
Subject   st: Nonlinear ML
Date   Thu, 15 Jul 2004 09:43:34 -0500

I am having trouble estimating the following via ml. Specifically, I get
the familiar:

could not calculate numerical derivatives
flat or discontinuous region encountered

This is a d0 model of the (error corrrection) form:

d.y=b_0(l.y+b_1+b_2(x1)+b_3(x3))+b_4(d.x1)+b_5(d.x2)

Clearly, this model is nonlinear in the betas.

I cannot use nlreg since this is a panel dataset.

The model estimates correctly with

xtreg d.y y x1 x2 d.x1 d.x2, mle

but I want to easily recover the betas and associated standard errors.

Here is a snippet of my code (parts should look familiar!):
***********************************************************************
quietly {
		gen double `z' = `depvar' +`deltas'-`phi'*($ML_y2-`thetas')
		by `by': gen `last' = _n==_N
		by `by': gen `T' = _N
		by `by': gen double `Sum_z2' = sum(`z'^2)
		by `by': gen double `Sumz_2' = sum(`z')^2
		gen double `a' = `lnsigma_u'^2 / (`T'*`lnsigma_u'^2 + `lnsigma_e'^2)
		mlsum `lnf' = -.5 *
((`Sum_z2'-`a'*`Sumz_2')/`lnsigma_e'^2+ln(`T'*`lnsigma_u'^2/`lnsigma_e'^2 + 1 )+`T'*ln(2*_pi*`lnsigma_e'^2)) if `last' == 1
	} 
end
set more off
global MY_panel id

ml model d0  ecrandom_d0 (dc=dy dpi) (lc=y pi, nocons) /phi /theta1
/theta2 /lnsigma_u  /lnsigma_e
**********************************************************************************


Thanks for any help,

Ed



*
*   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–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index