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

st: RE: Nonlinear least square


From   "Nick Cox" <n.j.cox@durham.ac.uk>
To   <statalist@hsphsun2.harvard.edu>
Subject   st: RE: Nonlinear least square
Date   Wed, 3 Jul 2002 08:52:07 +0100

Wei Tan
> 
> I try to estimate a mixture of normal models by NLS.
> ie I try to fit the following non linear least square
> model:
> 
> y=w*normcdf((xb-u1)/sigma1)+(1-w)*normcdf((xb-u2)/sigma2)
> 
> I write the following code in stata, however the stata
> program shows the following error message:
> 
> error #199 occurred in program nlrfgmm
> could not restore sort order because variables were
> dropped
> 
> could you please tell me what mistakes I made for this
> program?
> 
> thanks
> 
> wei
> 
> 
> program define nlrfgmm
> 	version 7.0
> 	if "`1'"=="?" {
> 	global S_1 "pi1 pi2 pi3 pi4 u2 sigma2 omega"
> 	global pi1=0.45
> 	global pi2=0.05
> 	global pi3=0.05
> 	global pi4=0.95
> 	global u2=0.45
> 	global sigma2=0.85
> 	global omega=0.5
> 	exit
> 	}
> 	u1=(1-$omega)*$u2/$omega
> 
> sigma1=((1-$u2^2-$sigma2^2)+$omega*($u2^2-$u1^2+$sigma2^2))/$omega)^0.5
> 	replace
> `1'=$omega*norm((x1*$pi1--u1)/sigma1)+(1-$omega)*norm((x1*$pi1-$u2
> )/$sigma2)
> 
> end
> 
> 
> use rfdata
> 
> nl rfgmm y x1 x2 x3 x4 
> 

Your lines 

u1 = ... 

and 

sigma1 = ... 

are not valid Stata syntax. 

Nick 
n.j.cox@durham.ac.uk 
*
*   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–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index