creating FRML's

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.
John_Val
Posts: 25
Joined: Sun May 17, 2009 2:18 pm

creating FRML's

Unread post by John_Val »

Hello,
I wrote the following program:

dec vec h1(3)
dec vec h2(3)
nonlin h1 h2

frml exq = 0
do i = 1,3
frml exq = exq + h2(i)/(1+exp(-(h1(i)*libm{i})))
end do i

com h1 = %ran(5)
com h2 = %ran(5)

nlls(frml=exq) libm
## NL1. FRML References More Than 20 Deep. Do You Have a Self-referencing FRML?

where libm is the series. What is the error message related to? Is the frml created through the do loop valid? I know I can just write out the model without using the loop, but I want to know how to loop over the frml command to creat long frmls with many parameters, without writing the model in one line.
TomDoan
Posts: 7814
Joined: Wed Nov 01, 2006 4:36 pm

Re: creating FRML's

Unread post by TomDoan »

FRML's don't work that way. While it's possible to define a single FRML using %DO, it's simpler to write a function instead:

Code: Select all

function exqf time
compute exqf=0.0
do i=1,3
   compute exqf = exqf + h2(i)/(1+exp(-(h1(i)*libm(time-i))))
end do i
end exqf

nlls(frml=exqf(t)) libm 
You have to pass the value of "T" to the function and use subscripts on the series reference in it, since it can't do the {...} notation for lags.
John_Val
Posts: 25
Joined: Sun May 17, 2009 2:18 pm

Re: creating FRML's

Unread post by John_Val »

I am still using version 5 and it does not have user defined functions. Is there an alternative way to do the above in version 5.
TomDoan
Posts: 7814
Joined: Wed Nov 01, 2006 4:36 pm

Re: creating FRML's

Unread post by TomDoan »

The simplest is to write the three terms out. If you want to maintain the flexibility to change n, use %DO.
John_Val
Posts: 25
Joined: Sun May 17, 2009 2:18 pm

Re: creating FRML's

Unread post by John_Val »

I tried setting it up by following the example that was done with the Markov-Switching model when setting up the likliehood function using %( ) and %do( ).
When I run the code below I get no error message but the program breaks down.


nonlin h1 h2
frml XX = %(exq=0.0,%do(i,1,3,exq + h2(i)/(1+exp(-(h1(i)*libm{i})))),exq)

com h1 = %ran(5)
com h2 = %ran(5)
nlls(frml=XX) libm
TomDoan
Posts: 7814
Joined: Wed Nov 01, 2006 4:36 pm

Re: creating FRML's

Unread post by TomDoan »

John_Val wrote:I tried setting it up by following the example that was done with the Markov-Switching model when setting up the likliehood function using %( ) and %do( ).
When I run the code below I get no error message but the program breaks down.


nonlin h1 h2
frml XX = %(exq=0.0,%do(i,1,3,exq + h2(i)/(1+exp(-(h1(i)*libm{i})))),exq)

com h1 = %ran(5)
com h2 = %ran(5)
nlls(frml=XX) libm
That needs to be

Code: Select all

frml XX = %(exq=0.0,%do(i,1,3,exq = exq + h2(i)/(1+exp(-(h1(i)*libm{i})))),exq)
Post Reply