Hi everybody,
I hope you've had a happy Christmas, where that applies!
This is just to inform you that the contributed function package tsfcst
is going to be updated shortly. Why this message? Because the package is
not really maintained anymore, so the gretl team is just doing some
housekeeping on it. This means that the upcoming version 0.6 will
require a fairly recent gretl version, but more importantly the
functions NMmaxC, NMminC, and hinv are going to be removed from the package.
The mentioned functions weren't needed for the main functionality, so
the rest of the package is not affected. However, there may be a small
possibility that someone was using those specific functions, although it
seems relatively unlikely. For those of you let me just paste the hansl
code of those functions directly at the bottom of this message. (Notice
that there seems to be a typo in one line; we haven't checked how
relevant that line is for typical usage.)
Finally, to give you some context, the package apparently implements
some methods that can also be found in an R package by Hyndman. For your
convenience here's a snippet from the package's help text, but be sure
to check out the entire help in the package for more details (until it
is moderated and really published, the updated version is in staging
here:
http://gretl.sourceforge.net/staging_fnfiles/tsfcst.gfn):
<tsfcst-help>
...
PACKAGE DESCRIPTION
===================
The "main" forecasting function is stheta(), which implements the
theta method, including a version for seasonal data; expsmpars()
outputs auto-selected alpha and y_0 to use for exponential smoothing.
...
</tsfcst-help>
OK, so much for that, enjoy the rest of this ugly year!
cheers
sven
--------------------
# Old functions from Oleh's package tsfcst <= v0.53
# which didn't really have to do with the rest of the package.
# Apparently does constrained (Nelder-Mead) optimization
# by mapping the function from 0-1 domain to infinite domain
# via the hyperbolic tangent inverse or something.
function matrix NMmaxC (string fu "quoted expression to minimize",
matrix los "left bounds",
matrix his "right bounds",
matrix z[null] "other variables",
matrices M[null] "yet other variables",
list L[null] "further variables as series",
matrix x[null] "init. val. of optimizing variable")
# inside fu the optimizing variable is 'x'
# M is needed when one has many matrices of different shape
if !exists(x) # was isnull()
matrix x = start_mt(los,his)
else
matrix x = x
endif
fu0 = fu
fu = smartstrsub(fu,"x","hinv(x,los,his)")
n = nelem(los)
cns = n == 1 ? "fmax x" : "fmax"
if n == 1
xi = "x[1]"
txtxi = "hinv_sc(x[1],los[1],his[1)" # must be a typo here
else
loop i = 1..n -q
xi = sprintf("x[%d]",i)
txtxi = sprintf("hinv_sc(x[%d],los[%d],his[%d])",i,i,i)
fu = strsub(fu,xi,txtxi)
cns = cns~" "~xi
endloop
endif
fu = "("~fu~")"
nm = NMmax(x,@fu)
x = hinv(x,los,his)
fmi = @fu0
matrix ret = fmi~x
cnameset(ret,cns)
return ret
end function
function matrix NMminC (string fu "quoted expression to minimize",
matrix los "left bounds",
matrix his "right bounds",
matrix z[null] "other variables",
matrices M[null] "yet other variables",
list L[null] "further variables as series",
matrix x[null] "start values of 'wrt. to'
variable")
# inside fu the optimizing variable is 'x'
# M is needed when one has many matrices of different shape
if !exists(x) # was isnull()
matrix x = start_mt(los,his)
else
matrix x = x
endif
fu0 = fu
fu = smartstrsub(fu,"x","hinv(x,los,his)")
n = nelem(los)
cns = n == 1 ? "fmin x" : "fmin"
if n == 1
xi = "x[1]"
txtxi = "hinv_sc(x[1],los[1],his[1)" # again a typo apparently
else
loop i = 1..n -q
xi = sprintf("x[%d]",i)
txtxi = sprintf("hinv_sc(x[%d],los[%d],his[%d])",i,i,i)
fu = strsub(fu,xi,txtxi)
cns = cns~" "~xi
endloop
endif
fu = "("~fu~")"
nm = NMmin(x,@fu)
x = hinv(x,los,his)
fmi = @fu0
matrix ret = fmi~x
cnameset(ret,cns)
return ret
end function
function matrix hinv (matrix x "arguments of objective function",
matrix lo "lower bounds in restrictions",
matrix hi "upper bounds in restrictions")
# box -> R^n transformation
nl = nelem(lo)
matrix hix = x
loop i = 1..nl
hix[i] = hinv_sc(x[i],lo[i],hi[i])
endloop
return hix
end function
function scalar hinv_sc (scalar x,
scalar lo,
scalar hi)
if hi <= lo
funcerr "'hi' cannot be less or equal to 'lo'."
endif
if (lo > -$huge) && (hi < $huge)
return (lo+hi) / 2 + (hi-lo) / 2 * tanh(x-(lo+hi)/2)
elif (lo>-$huge) && (hi>=$huge)
return lo + exp(x-lo)
elif (lo<=-$huge) && (hi<$huge)
return hi - exp(hi-x)
else
return x
endif
end function