Mann-Kendall test
by Sven Schreiber

Hi,
I've just read about the non-parametric Mann-Kendall test for a trend
(hence my recent postings about Kendall's tau and ties in a series).
It looked pretty easy, so I'm attaching an attempt at a basic
implementation. Full disclosure: I've used the description from
https://cran.r-project.org/web/packages/trend/vignettes/trend.pdf (only
the basic version in section 1.1).
All you have to do is call "MannKendall(x)", where x is your series of
interest.
I'd be happy about feedback regarding cross-checks and correctness (for
example in the above document in equ. (4) the case S>0 wrongly appears
twice, and I had to make an educated guess where to switch the
signs...), whether it should become a function package and so on.
thanks,
sven
6 years, 3 months

how do packages in a model window grab the $model bundle?
by Sven Schreiber

Hi,
in the changelog of 2017b I read:
"Fix bug: ensure that the $model accessor (bundle) is
available to function packages that attach to a model window"
And indeed I have a function here (to be packaged) that takes a
$model-style bundle as an argument. How do I have to specify the
function signature or argument so that it is actually the $model bundle
that is automatically handed over to the package?
I looked briefly in the package guide, but couldn't find an answer (I
think).
thanks,
sven
6 years, 4 months

Dealing with big(!) matrix
by Marcin Błażejowski

Hi,
suppose I have really big vector/matrix (I mean 100000 or more rows and
1-2 cols) and I need to find out the position of certain value stored in
the first column in this matrix (like iminc and imaxc but for an
arbitrary value). The matrix is not sorted and it may systematically
grow (new rows are added at the bottom).
The question is: what is the numerical most effective may of doing this?
Marcin
--
Marcin Błażejowski
6 years, 4 months

Assumed innovation distribution for forecasts
by Sven Schreiber

Hi,
two remarks about the distribution which is used to derive the forecast
confidence intervals. Consider the following forecast:
<hansl>
open denmark
ols LRM 0 LRM(-1 to -2)
dataset addobs 5
fcast 1987:4 1988:4 # --plot=display
</hansl>
In the printout I see:
"For 95% confidence intervals, t(50, 0.025) = 2.009"
And indeed, the width of the confidence intervals seems to be twice the
reported standard error (0.03367 for step h=1) times 2.009.
However, there are several potential issues here I think:
- Gaussian innovations are implicitly assumed AFAICS. This is of course
a widespread assumption but isn't made explicit (and could be wrong).
- The t-distribution for a small estimation sample is quite ad hoc.
Maybe it would be a good idea to give the user an option to switch to a
plain Gaussian.
cheers,
sven
6 years, 4 months

ARIMA output
by Marcin Błażejowski

Hi,
simple script:
<hansl>
open australia.gdt
arima 2 0 0 ; PAU PUS(-1 to -2) IAU IUS 0 --conditional
</hansl>
Since we have ARIMA(2,0,0) model I would expect PAU_1 and PAU_2
variables but we have phi_1 and phi_2 (from autoregressive polynomial I
suppose). Is this correct?
Regards,
Marcin
--
Marcin Błażejowski
6 years, 4 months

gretl warnings in output: difference between packages and plain scripts?
by Sven Schreiber

Hi,
I'm seeing a difference in the output between what (I think) is the same
code, depending on whether it is called as a function package or whether
it is run as unpackaged scripts. With the package (run with
gretlcli.exe) from the CLI I'm getting warnings:
<gretl-output>
In regard to function VARboot (package johansensmall):
Warnung: erzeugte nichtendliche Werte
</gretl-output>
(meaning "created non-finite values")
And when I run the some code with gretlcli but not in a packaged form,
those warnings are absent. I have inserted a "set warnings off" into
that code where I think it could be necessary, and I would like to mute
those warnings also in the package.
So my question is: What could explain this different behavior? Is it
intended? How to switch off the warnings inside a package?
thanks,
sven
6 years, 4 months

error catching failing for "catch var..."
by Sven Schreiber

Hi,
I have the following strange behavior which was a bit difficult to track
down. Sorry, cannot give a minimal example because the problem then
doesn't appear. In my more complex setup it's reproducible, however.
The trigger is a "var 0 endolist" command, which is invalid because the
lag order isn't positive. (Actually it's "var km1 endolist; xlist
@somestring --silent", and km1 sometimes happens to be 0.)
My first minor complaint is that here gretl's error message could be a
bit more specific than just "invalid argument".
OK, so I'm trying to use "catch", and immediately after the "catch var"
line I have:
err = $error
if err
print err
<...>
endif
But: Now gretl, instead of printing the err and so on, throws another
error message "unpaired if" (re-translated from German). How can that
be? That must be bogus, because gretl doesn't complain in all those
cases where $error==0 (which happens most of the time; all this is
inside a random simulation loop).
Of course, the fix for me is to properly handle the km1==0 case in the
first place. But because of the mentioned behavior of gretl, it took me
a while to get to that insight.
thanks,
sven
6 years, 4 months

resample() extension...
by Sven Schreiber

... or: what's the best way to draw (with replacement) from an input a
vector that has a different length (shorter or longer)?
Let's say I have a vector 'myresids' of length T and I want to
draw/resample a random vector of length H != T. How can I do that in
hansl both efficiently and elegantly?
Using 'resample(myresids)[1:H]' would work for H<T but would probably be
inefficient, because T random draws are done instead of just H. (Also it
would have to be replaced by some kind of loop for H>T.)
Or I could do 'myresids[mrandgen(i, 1, T, H, 1)]', which should work for
any H and would hopefully be efficient (?). However, IMHO it's not
easily readable, because only the parameter H is actually really
important in this context, the rest is just confusing syntax.
So, might it be useful to have a better equivalent expression for the
above? I would have suggested 'resample(myresids, H)', but resample()
already has a different second argument.
Any hints for the present syntax or suggestions for new syntax features
appreciated.
thanks,
sven
6 years, 4 months

scalar as 1x1 matrix, feature or coincidence
by Sven Schreiber

Hi,
I'd like to know whether I can rely on a behavior in gretl 2017a which
seems to fail in 2016d (and earlier?).
The following is intended usage and runs fine here on 2017a:
<hansl>
function void mscheck(matrix m)
print m
end function
# call with actual matrix
mscheck(I(2))
# call with scalar as 1x1 matrix substitute
mscheck(3)
</hansl>
However, it seems that passing a scalar to a matrix argument provokes a
type mismatch error in gretl 2016d. (Couldn't run exactly the above
example now, but the error was pretty clear.)
So, is that a new feature in 2017a and is here to stay, or just luck?
thanks,
sven
6 years, 4 months