removing nan and inf from a matrix
by Logan Kelly

Hello,
I need to take the log difference of a matrix, i.e. log(M[2 rows(M):,]/M[1:rows(M)-1,]). Unfortunately, M has elements equal to zero. I need to replace the nan's and inf's with 0's. This almost works
M = isnan(M) ? 0 : M
but does not remove inf's. Any sugestions?
4 years, 8 months

Computing an index for unique combinations of discrete variables
by Giuseppe Vittucci

Hi,
I have firm level data and two categorical variables (region and
sector).
I need to define another variable which is an index identifying the
unique combinations region-sector each firm belongs to, so I can use it
in computing cluster-robust s.e.
One way to do this is to use the command "values" for region and sector
and then use a nested loop, but this seems quite time-consuming...
Is there a simpler way in gretl to do it?
BTW, it could be useful to allow one to use the option "cluster" also
with the FE estimator.
Since the robust s.e. used in FE is the Arellano estimator and this is a
s.e. clusterized over cross-sectional units and thus it can be
considered a specification of the cluster-robust estimator, it seems
quite natural to allow one to identify clusters different from the
units.
Something like:
panel y 0 x --robust=cvar
or
panel y 0 x --cluster=cvar
where the default behavior
panel y 0 x --robust
is to clusterize over cross-sectional units.
Bye
Giuseppe
6 years, 9 months

highlighting syntax
by Alessandro Astuti

Hi everybody!
I'm running gretl 1.9.14 on debian testing/sid with gnome shell 64 bit.
Everything works fine except the syntax highlighting. I checked on gretl
dependencies and I got a very generic gtksourceview.
Can someone tell me which are the right packages to install in order to
have syntax highlighting on gretl script editor?
Thanks!
--
Alessandro Astuti
6 years, 10 months

vectorized form of the following loop
by Artur T.

Hello,
I was thinking how to implement the following code snippet into a
vectorized form, but I couldn't figure out how to do this effectively. The
issue I face is the lagged value of y which changes over the loop. Does
anybody have an alternative way to run this thing?
<hansl>
scalar T = 100
scalar b1 = -0.2
scalar b2 = 0.5
matrix u = mnormal(T,1)
matrix dx = mnormal(T,1)
matrix dy = zeros(T,1)
matrix y = zeros(T,1)
loop i=2..T -q
dy[i] = b1*y[(i-1)] + b2*dx[i] + u[i]
y[i] = y[i-1] + dy[i]
endloop
<\hansl>
Thanks in advance.
Artur
6 years, 10 months

counting missing data
by cociuba mihai

Dear Gretl users,
I have a data panel with 500 variables and I would like to find if there
are missing observations in the dataset.
I've seen that it could be done manually by looking at the summary
statistics but I was wondering if there isn't a more clever way to do it?
Thanks, Mihai
6 years, 11 months

X12-ARMA failing
by GOO Creations

Hi,
I'm trying to estimate an ARMA model using X12. I'm linking the gretl
libraries to my program and these are the errors I'm getting:
//.spc: Permission denied//
//Failed to execute x12arima//
/
So I tried to execute my program as super user, and then the errors
change as follow:
/spawn: 'Failed to change to directory '' (No such file or directory)'//
// -r -p -q -n //
//Failed to execute x12arima//
/
I seems that x12arma is writing out files (or something similar). Can
anyone give me some advise on these errors?
Chris
6 years, 11 months

Possible bug in richardson_gradient
by GOO Creations

Hi,
I think this might be a bug. When using the ARMA model, I sometimes get
a message "numerical gradient: switching to Richardson". However, once I
get this message, nothing else happens, but the CPU stays at 100%. After
closer inspection, I've noticed that the richardson_gradient function in
lib/src/gretl_bfgs.c never returns (so some kind of infinite loop in
there). So I did some debugging and believe this is the problems:
The last part of the function has 2 nested loops as follows:
/ for (m=0; m<r-1; m++) {//
// for (k=0; k<r-m; k++) {//
// df[k] = (df[k+1] * p4m - df[k]) / (p4m - 1.0);//
// }//
// p4m *= 4.0;//
// }//
/
At the beginning of the function, r is initialized to RSTEPS which is 4,
and the array df has RSTEPS elements. When looking at the code above, we
can see that once the outer loop starts, m is 0. The inner loop will
therefore run from k=0 to k<r-m. r is 4, m = 0, therefore r-m=4-0=4. The
inner loop will therefore run with k equal to 0, 1, 2 and 3. Now inside
the inner loop, we access df[k+1]. If k=3, we will access df[3+1] which
is df[4]. Since df has a size of 4, we are accessing an invalid index
(max of 3 allowed). This probably causes some important memory to be
overriden, and the inner loop becomes infinite. For some reason (I think
some memory problems), the inner loop will just keep running. The value
of k will increase (0, 1, 2, 3, 4, 5, ... to infinity) and the value of
r-m will stay at 4, but for some reason the loop doesn't exit (so the
check k<r-m will not stop the loop, even if k exceeds 3).
If you remove the statement:
/df[k] = (df[k+1] * p4m - df[k]) / (p4m - 1.0);/
/
/from the inner loop, everything works perfectly. I therefore think the
access df[k+1] causes the problem.
Is this a bug or am I missing something?
Regards
Chris
6 years, 11 months

pre-allocating matrix
by Artur T.

Just out of curiosity: Does it make any difference, from a computational
perspective, whether I choose option 1 or 2? In option 2 I concretely
pre-allocate memory, which should be more efficient, right?
<hansl>
#Opt 1:
matrix X = x1~x2~..~xp
#Opt 2:
matrix X = zeros(T,p)
X[,1] = x1
X[,2] = x2
...
X[,p] = xp
<\hansl>
Artur
6 years, 11 months

Gretl forecast - undefined reference
by GOO Creations

Hi,
I'm trying to estimate the parameters for an ARMA model and then
forecast the next value. I've linked the library (libgretl-1.0) to my
program and am able to create datasets and estimate the ARMA model. I'm
however unable to use the forecast code.
I've noticed that forecast.h is not included in libgretl.h, which seems
strange. So I manually added forecast.h to my program. I now get
*undefined references* to all the functions in forecast.h. So I assume
the forecast functionality is not part of the libgretl-1.0 library.
Which library should I link to, to make use of this functionality? I've
tried linking all the libs in /usr/lib/gretl-gtk2, but that didn't help
either.
Any help would be appreciated
Chris
6 years, 11 months

last valid obs
by Sven Schreiber

Hi,
is there are more elegant/readable way of getting the last (valid) value
of a series (say, x) than this:
x[lastobs(x)]
?
Thanks,
sven
6 years, 11 months