Needs tuning, as the -egen- call won't work.
egen `X' = sum((_n < 34) * (_n*cos($B) + (_n-1)*tan($B)) )
is I think a step in the right direction.
Nick
[email protected]
> -----Original Message-----
> From: [email protected]
> [mailto:[email protected]]On Behalf Of Stephen P
> Jenkins
> Sent: 30 March 2004 11:42
> To: [email protected]
> Subject: st: RE: sum in nonlinear equations
>
>
> How about something along the following lines? (untested!!)
>
> Instead of
>
> gen `yh'= exp($A) + sum(from n =1 to 34)[n*cos($B)+
> (n-1)*tan($B)] -2 in
> 1
>
> try
>
> tempvar X
> egen `X' = (_n<=34)*sum( _n*cos($B) + _n-1*tan($B) )
> gen `yh'= exp($A) + `X' -2 in 1
>
> Assuming your data set has at least 34 obs in it, the idea is
> to use the
> egen to calculate the sum
>
*
* 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/