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.

creating FRML's

Postby John_Val » Tue Jan 12, 2010 4:51 pm

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

Re: creating FRML's

Postby TomDoan » Wed Jan 13, 2010 10:49 am

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.
TomDoan
 
Posts: 2720
Joined: Wed Nov 01, 2006 5:36 pm

Re: creating FRML's

Postby John_Val » Wed Jan 13, 2010 8:57 pm

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

Re: creating FRML's

Postby TomDoan » Thu Jan 14, 2010 11:20 am

The simplest is to write the three terms out. If you want to maintain the flexibility to change n, use %DO.
TomDoan
 
Posts: 2720
Joined: Wed Nov 01, 2006 5:36 pm

Re: creating FRML's

Postby John_Val » Sun Jan 17, 2010 9:11 pm

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

Re: creating FRML's

Postby TomDoan » Sun Jan 17, 2010 9:31 pm

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)
TomDoan
 
Posts: 2720
Joined: Wed Nov 01, 2006 5:36 pm


Return to Help With Programming

Who is online

Users browsing this forum: No registered users and 1 guest