creating FRML's
creating FRML's
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.
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.
Re: creating FRML's
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:
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.
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 Re: creating FRML's
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.
Re: creating FRML's
The simplest is to write the three terms out. If you want to maintain the flexibility to change n, use %DO.
Re: creating FRML's
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
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
Re: creating FRML's
That needs to beJohn_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
Code: Select all
frml XX = %(exq=0.0,%do(i,1,3,exq = exq + h2(i)/(1+exp(-(h1(i)*libm{i})))),exq)