The local linear trend model estimation (Kalman filter)
by Henrique Andrade

Dear Gretl Community,
I'm trying to replicate the results from Commandeur & Koopman (2007)
(chapter 3, section 3.2, pp. 23-26) but I'm getting no success :-(
Please take a look at the code I'm running (the .inp file is
attached):
<hansl>
set echo off
set messages off
clear
open "UK-KSI.gdt" --frompkg=StrucTiSM
series y = log(KSI)
setinfo y --description="log UK drivers KSI against time (in months)"
--graph-name="log UK drivers KSI against time (in months)"
##### 3.2. Stochastic level and slope #####
/* parameter initialization */
scalar var_irreg = 1
scalar var_level = 1
scalar var_slope = 1
/* state-space model setup */
matrix H = {1 ; 0}
matrix F = {1, 1; 0, 1}
matrix Q = {var_level, 0; 0, var_slope}
bundle kalman = ksetup(y, H, F, Q)
kalman.obsvar = var_irreg
kalman.diffuse = 1
/* maximum likelihood estimation */
"stochastic KSI" <- mle ll = ERR ? NA : kalman.llt
kalman.obsvar = var_irreg
kalman.statevar[1, 1] = var_level
kalman.statevar[2, 2] = var_slope
ERR = kfilter(&kalman)
params var_irreg var_level var_slope
end mle --lbfgs
</hansl>
The results from Commandeur & Koopman (2017) are:
observation variance estimate (irregular): 0.002118
state variance estimate (level): 0.012128
state variance estimate (slope): 0.000000
Any help will be very appreciated.
Best regards,
Henrique Andrade
6 years, 3 months

Error message with SVAR
by Olivo Victor

Hello:
I receive the error message in the attached picture whenever I try to estimate a SVAR in some sessions files where I have already estimated an saved a SVAR model. Do you know why?
6 years, 3 months

Vvariables orthogonalization
by Marcin Błażejowski

Hi,
I tried to replicate in gretl exercise with variable orthogonalization
explained in https://www.stata.com/manuals13/rorthog.pdf
but after running the script (dataset in attachment):
<hansl>
set verbose off
list X = const length weight headroom trunk
X_orth = qrdecomp({X})
series olength = X_orth[,2]
series oweight = X_orth[,3]
series oheadroom = X_orth[,4]
series otrunk = X_orth[,5]
ols price X --simple
ols price const olength oweight oheadroom otrunk --simple
</hansl>
the only identical coefficient is for const.
What am I doing wrong?
Regards,
Marcin
--
Marcin Błażejowski
6 years, 3 months

NMmax/min question
by oleg_komashko＠ukr.net

Dear all,
The question is:
How to change tolerance in these functions?
Oleh
6 years, 3 months

Quadratic from in log-likelihood contribution
by Alecos Papadopoulos

I guess this is elementary and I should be embarrassed, but it seems I
cannot find a way to tell gretl to include what is essentially a
quadratic form in the expression for the log-likelihood contributions
(llc) (1st line in the mle command).
I mean something like the following does not seem to work (N1 and N2 are
series-type)
...
scalar s1 = 1
scalar s2 = 1
scalar c12 = 0.5
matrix S = {s1^2,c12;c12,s2^2}
mle logl = check ? -0.5*ldet(S) - 0.5*qform(q,inv(S)) :NA
matrix q = {N1, N2}
scalar check = (s1>0) && (s2>0) && (abs(c12)<1)
params s1 s2 c12
end mle
...
The above is an example that attempts to estimate the parameters of a
bivariate normal distribution. The expression in the mle command line
attempts to express the log-likelihood at observation level as we do on
paper, hoping that Gretl will treat it as it does with series-type data,
i.e. consider one row of the q- (N x 2) matrix at a time. It seems it
doesn't though.
Of course one can always write out the quadratic explicitly, and then
use series as usual, but for more than two variables involved this is
two complicated, and my case is not just bivariate.
Is there a way to do this compactly?
--
Alecos Papadopoulos
PhD Candidate
Athens University of Economics and Business, Greece
School of Economic Sciences
Department of Economics
https://alecospapadopoulos.wordpress.com/
6 years, 3 months

When Julia is faster than C and Gretl
by Artur Tarassow

Dear all,
I just stumbled about this Julia post
https://www.juliabloggers.com/when-julia-is-faster-than-c/
and translated the code to hansl. Running the original Julia code on my
machine with 10^7 iterations takes about 0.19 seconds. Running the hansl
code below takes about 19 seconds which is 100 times slower compared to
Julia. I am pretty sure there is a much more efficient way to set this
up this up using gretl+hansl (Jack? :-D ) -- but this is not my point.
Let's just assume the average user would set up things as simple as
possible.
I am just curious to know at which point Julia makes it seemingly better
compared to C and hansl? Any ideas? Btw, I can't see that Julia makes
any use of parallelization -- according to CPU information only a single
core is fully used. The same holds for gretl.
<hansl>
function void euler(int n, scalar *mn) # pointer form
scalar m = 0
loop i = 1..n -q
scalar the_sum = 0
loop while the_sum<=1 -q
m++
the_sum += randgen1(u,0,1)
endloop
endloop
mn = m/n
end function
set verbose off
clear
set stopwatch
scalar mn = 0
euler(10^7,&mn) # originally 10^8
printf "This took = %.6f sec.\n", $stopwatch
mn
<hansl>
Best,
Artur
6 years, 3 months

Problem with accented folder names in "set workdir"
by Henrique Andrade

Dear Allin,
Gretl does not recognize accented folder names in the "set workdir"
command. I'm trying something like this:
set workdir "C:/Users/Henrique/Box Sync/Espaço de estados"
I'm using Gretl (build 2018-02-05) on my Windows Vista PC.
Best regards,
Henrique Andrade
6 years, 3 months