On Mon, 20 Aug 2012, Daniel Sirim wrote:
At first I want to show you my script to get an Imagination
of what i want to do.
Your mailer is producing an illegible mess. I've reformatted
some of your functions below.
A basic point is that gretl functions "know about" only those
variables that you pass as arguments, or that are defined
inside the function itself.
# Basic Functions
# Nr. 1 GO
function series GO (scalar a, scalar b1, series v1, scalar t0)
return a1*(1-exp(-b1*v1-t0))
end function
The symbol "a1" is not defined -- perhaps you meant "a"?
# Nr. 2 GOS
function series GOS (scalar a, scalar b2, series v1, scalar t0)
return a1*(1-(1+b1*v1-t0)*exp(-b1*v1-t0))
end function
This time both "a1" and "b1" are undefined. The computer is
not going to guess what you mean.
# Nr.3 HD
function series HD (scalar a, scalar b3, scalar c3,
series v1, scalar t0)
return a3*(1-exp(-b3*v1-t0))/(1+c3*exp(-b3*v1-t0))
end function
Here "a3" is undefined.
function series model (scalar a, scalar b1, scalar b2,
scalar b3, scalar c3, series v1)
scalar n1 = GO (t1, a, b1, v1, t)
scalar n2 = GOS(t2, a, b2, v1, t)+n1
scalar n3 = HD (t3, a, b3, c3 , v1, t)+n2
return (t<=v1)*GO (t1, a, b1, v1, t) \
+ (t>v1)*(t<=t2)*GOS(t2, a, b2, v1, t)+n1 \
+ (t>v1)*(t<=t3)*HD(t3, a, b3, c3 , v1, t)+n2
end function
In this function the undefined variables are t1, t2, and t3.
Also you are doing something funny with the inequalities
relating to "t" (which, unless it is redefined, gives you an
index of the observations). That is, you are comparing it
against both scalars (I think t1, t2 and t3 are supposed to be
scalars) and a series, v1. You can do that, but I'm not sure
it's what you want.
Further on, we have
catch nls v4 = model
"model" is a function with 6 parameters, as written, but
you're not passing any arguments.
You should start with a much simpler problem, to get the hang
of programming in general and gretl scripting in particular.
It should be fairly obvious that none of the functions above
will work as written.
Allin Cottrell