optimizing two parameters using find instruction

Use this forum to post questions about syntax problems or general programming issues. Questions on implementing a particular aspect of econometrics should go in "Econometrics Issues" below.
Gilbril
Posts: 78
Joined: Thu Aug 19, 2010 2:00 pm

optimizing two parameters using find instruction

Unread post by Gilbril »

Dear Tom, I am trying to simulate a manually set forecast. I have a certain monthly series (series1) and I want to define the average annual growth rate for the recent calendar year. I am searching for the %mom growth rate, which match the defined annual average growth rate. However the %mom growth rate should converge from the most recent observation to the long run %mom growth rate at the end of the calendar year. Therefore the first adjustment parameter is the discount factor xm which adjusts the speed of convergence towards long run growt rate. This first step works fine.

However in some cases the annual growth rate can not be met by any reasonable discount factor. Ín these cases I want to adjust the end value of the convergence process by sfac.
Therfore the optimization should be:

1. optimize the Discount factor within the restricted value set
2. If this is not possible adjust the endpoint of the convergence process as litte as possible.


For some reason my code never adjusts sfac. Why is the second parameter sfac not adjusted? My code is below. I altered the code from page 180 in the reference Manual:

Thanks a lot!

dec real jd1
compute jd1 =-0.5
* annual average growth rate
dec real meanlr
compute meanlr =0.11


nonlin(parmset=xset) xm
nonlin(parmset=sset) sfac
*
compute xm=1.0,sfac=1.0
*
compute value=0.0
find(parmset=xset,trace) min value
compute distance=0
find(parmset=sset,method=simplex,noprint) min distance

dofor i = 1 to freq-%month(endseries1)

if xm<=0.0
compute value=%na

else
* the path of monthly changes should converge to the long run growth rate
* if this is not sufficient adjust the long rum growth rate by sfac

comp path(i)= ch_series1(endseries1)*xm^(i)+(meanlr+sfac)*(1-xm^(i))



*compute the new level
set series1dir endseries1+i endseries1+i = series1dir(endseries1+i-1)*(1+path(i)/100)


end dofor i

*compute annual avergaes
stats(noprint) series1dir fyear1start fyear1end
comp meanfy1 = %mean
stats(noprint) series1dir fyear1start-freq fyear1end-freq
comp meanoby = %mean
comp growth1 = ((meanfy1/meanoby)-1)*100


*minimizing criteria
comp value = (growth1-jd1)^2
compute distance=(0-sfac)^2


end find
end find
TomDoan
Posts: 7814
Joined: Wed Nov 01, 2006 4:36 pm

Re: optimizing two parameters using find instruction

Unread post by TomDoan »

Offhand, it looks like you need to put the COMPUTE DISTANCE after the first END FIND. As you have in written, DISTANCE will be zero with each evaluation of the outer FIND. Also, at your guess value of XM=1, the SFAC doesn't enter the function.
Post Reply