Statalist


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

st: Nonlinear model using maximum likelihood


From   Magnus Soderberg <Magnus.Soderberg@unisa.edu.au>
To   "statalist@hsphsun2.harvard.edu" <statalist@hsphsun2.harvard.edu>
Subject   st: Nonlinear model using maximum likelihood
Date   Wed, 4 Mar 2009 09:09:18 +1030

Dear All,

I want to estimate the following nonlinear function:

Y = b0 + b1*exp(b2*x1)*b4*x2*x3 + Xb 

Where b0 to b3 are parameters (b vector of parameters), x1 to x3 variables (X a vector of variables). 

I could estimate this by using the Stata command nl, but I want to use ML. 

There is a similar problem and a solution posted at http://www.stata.com/support/faqs/stat/nl_ml.html which looks like

program mlnexpgr
	version 10
	args lnf b1x b0 sigma
	tempvar res
	quietly gen double `res' = $ML_y1 - `b0'*(1-exp(-`b1x'))
	quietly replace `lnf' = -0.5*ln(2*_pi)-ln(`sigma')-0.5*`res'^2/`sigma'^2
end

ml model lf mlnexpgr (b1: rep78 = headroom, nocons) (b0:) (sigma:)
  
ml max


I guess my problem is the specification of the "ml model"-line but despite numerous attempts I can't get a reasonable output.

Does anyone know how to do this?


All the best,
Magnus


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