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?
3 years, 8 months

Stata-like drop command
by Artur T.

Hello gretl users,
is there a command like "drop" (Stata) available in gretl? I would like
to drop units from a panel data set with less than x observations.
The reason is the following. Assume I have two units, A and B. For unit
A I have a fully balanced panel with three consecutive observations from
2000 to 2002. For unit B I have only two obs for 2000 and 2002,
respectively:
Variable X:
-----------
2000: 10 #unit A
2001: 11
2002: 9
2000: 10 # unit B
2001:
2002: 13
If I translate these obs into a matrix, I obtain a vector V with five
entries:
V = { 10 11 9 10 13 }
This even happens if I run:
series pn = pnobs(A)
smpl pnobs==pn --restrict --replace
If one could drop these units from the variables by a "drop"-like
command, this problem would not arise. Of course, alternatively one
could store the restricted dataset temporarily and re-open it, but then
lists and other stuff gets lost as well...
Best,
Artur
6 years, 6 months

Passing a list of series to a function
by Logan Kelly

Hello,
I am using Gretl 1.9.12cvs on WIN 8. Is there a way to pass a list series to a function? I used the following function declaration:
function void dplot(list lstDIV, string filetype, string strTitle[null], string strDisc[null])
string ddat = varname(lstDIV[1])
sprintf send "%s", date(firstobs(@ddat))
end function
but get this error
The symbol 'DQ_us' is undefined
*** error in function dplot, line 24
> sprintf send "%s", date(firstobs(DQ_us))
So I am able to pass the list but the individual series are not accessible? Anyway around this?
Thanks,
Logan
6 years, 7 months

Re: [Gretl-users] Gretl-users Digest, Vol 78, Issue 21
by Hugo Cohan

No graphs computer hangs, Gretl must be killed.
1.9.12.1 works OK with Ubuntu-LinuxMint 15, gnuplot 4.6.1.1-exp 1
I did try you suggestion. Running in terminal (gnuplot 4.6.3.1 installed)
There is a message, repeated in two lines:
sh: 1 Kde4 -config:not found
By the way, I also tried (debian Sid) gnuplot 4.6.3.2 and, again, no graphs and computer hangs.
Thank you for your interest.
> Message: 2
> Date: Sun, 28 Jul 2013 13:46:59 +0100
> From: "Cottrell, Allin" <cottrell(a)wfu.edu>
> Subject: Re: [Gretl-users] Trouble with Linux deb testing. Calling
> gnuplot 4.6.3.1
> To: Gretl list <gretl-users(a)lists.wfu.edu>
> Message-ID:
> <CA+BOgOCtgcuakucn_WdJ_NHf2CRHO3Bu0x7WvYOOPr2W6T6=_Q(a)mail.gmail.com>
> Content-Type: text/plain; charset=ISO-8859-1
>
> On Sat, Jul 27, 2013 at 10:30 PM, Hugo Cohan <hugobruno3785(a)hotmail.com> wrote:
> > Just a warning for Linux deb "testing" users
> >
> > Gretl 1.9.12.1 does not seem to communicate with gnuplot version 4.6.3.1
>
> What's the symptom -- just no graphs?
>
> Can you try running gretl from the command prompt in a terminal window and
> see if there are any relevant messages?
>
> Allin Cottrell
>
>
> ------------------------------
>
> _______________________________________________
> Gretl-users mailing list
> Gretl-users(a)lists.wfu.edu
> http://lists.wfu.edu/mailman/listinfo/gretl-users
>
> End of Gretl-users Digest, Vol 78, Issue 21
> *******************************************
6 years, 7 months

Access elements of a list
by Logan Kelly

Allin,
I have two questions. First, is this the correct list to post this question? I am not sure if it belongs here or in the gretl-devl list. Apologies, if I have guessed wrongly.
Second, regarding accessing a list element. Should following assign the data in the first series of lstX to matrix matX?
matrix matX = {lstX[1]}
Currently, this yields the matX = series id number. This question is related to an earlier question on the list see below.
Cheers,
Logan
On Sun, 5 Aug 2012, Allin Cottrell wrote:
> On Sat, 4 Aug 2012, Logan Kelly wrote:
>
>> Is it possible to access elements of a list. I need the variable name-as a
>> string-of the i_th element of a list. Something like
>>
>> string variable_name = varnam(ylist[i])
>
> You can't directly index into a list [...]
Actually, that seems a bit lame. Now in CVS and snapshots you
can do that -- the expression above should now work (apart
from the typo of "varnam" for "varname" ;-).
Allin Cottrell
6 years, 7 months

Standardize and bootstrap
by Carla Fernandes

Dear Gretl users,
Hi,
I need some help...
I need to do the following procedures in my data and empirical analysis:
- standardize all right-hand side variables used in regressions in order to facilitate the comparisons between countries;
- bootstrap the raw data in blocks to use a moving block-bootstrap to account for biased coefficient estimates and standard errors. The procedure is: first estimate a predictive regression for several time horizons and then repeatedly bootstrap the raw data in blocks to generate 10,000 new time series generated under the null of no predictability for all dependent and explanatory variables. Finally, predictive regressions are then estimated on these 10,000 artificial time series to obtain the bootstrap distribution of coefficient estimates.
Someone could you tell me, please, if I can do these with gretl?
Thank you very much for your attention.
Best regards.
Carla Fernandes.
___________________________________________
Carla Fernandes
Equiparada a Prof. Adjunta
Universidade de Aveiro - ISCA
R. Associação Humanitária dos Bombeiros de Aveiro
Apartado 58
EC AVEIRO
3811-902 Aveiro
Portugal
Telefone: + 351 234 380 110 / Fax: + 351 234 380 111
e-mail: carla.fernandes(a)ua.pt
6 years, 7 months

Minore mistake in the user's guide
by Giuseppe Vittucci

In Example 13.1 of the guide, KIDS is coded as:
series KIDS = (KL6 > 0) + ((KL6 > 0) || (K618 > 0))
and therefore it takes values:
KIDS = 0 -> no kids
KIDS = 1 -> older kids only
KIDS = 2 -> young or older kids
and not:
KIDS = 0 -> no kids
KIDS = 1 -> young kids only
KIDS = 2 -> young or older kids
as incorrectly stated.
In order to have the latter, KIDS should be coded as:
series KIDS = (K618 > 0) + ((KL6 > 0) || (K618 > 0))
i.e.
KIDS = 0 -> no kids
KIDS = 1 -> young kids only
KIDS = 2 -> (young and older kids) or (older kids only)
Just a minor mistake...
Bye
Giuseppe
6 years, 7 months

Re: [Gretl-users] VAR/Granger Causality
by Logan Kelly

Thanks. For my purpose, your function is actually superior to running the var function in that I can skip estimating the irrelevant equations.
Logan
-------- Original message --------
From: "Riccardo (Jack) Lucchetti" <r.lucchetti(a)univpm.it>
Date: 07/15/2013 5:49 PM (GMT-06:00)
To: Gretl list <gretl-users(a)lists.wfu.edu>
Subject: Re: [Gretl-users] VAR/Granger Causality
On Mon, 15 Jul 2013, Logan Kelly wrote:
> Thanks for your quick response. I can see the f-stats in the output that
> are the GC test, but I would like to collect the test statistic in a
> matrix for further formatting. In a single equation model I would use
>
> matrix matFSTAT = $Fstat
>
> I am running several VAR's in a loop and need to store only these
> f-stats. My question is only about storing this stat after running var.
> Any suggestions?
I suppose a function could do the job quite nicely. The following is an
example of the many ways in which this could be done.
<hansl>
set echo off
set messages off
function scalar GCtest(series y, series x, list detvars,
scalar order, scalar *pv[null])
ols y detvars y(-1 to -order) x(-1 to -order) --quiet
omit x(-1 to -order) --silent
pv = $pvalue
return $test
end function
# -- open data ----------------------------------
open AWM.gdt --quiet
# -- check the function works as intended -------
var 3 LTN STN --quiet
# compare
GC1 = GCtest(LTN, STN, const, 3)
PV = NA
GC2 = GCtest(STN, LTN, const, 3, &PV)
print GC2 PV
# -- apply the function in a loop ---------------
smpl +12 ;
matrix moo = zeros(12,2)
loop for i=1..12 --quiet
GC = GCtest(STN, LTN, const, i, &PV)
printf "GC test (%2d lags) = %g, (p-value = %g)\n", i, GC, PV
moo[i,] = {GC, PV}
end loop
print moo
</hansl>
Of course you could prefer incorporating the loop inside the function and
have it spit out the matrix you want, it would just be a matter of style.
-------------------------------------------------------
Riccardo (Jack) Lucchetti
Dipartimento di Scienze Economiche e Sociali (DiSES)
Università Politecnica delle Marche
(formerly known as Università di Ancona)
r.lucchetti(a)univpm.it
http://www2.econ.univpm.it/servizi/hpp/lucchetti
-------------------------------------------------------
6 years, 7 months

VAR/Granger Causality
by Logan Kelly

Hello,
I would like to access the Granger Causality stats after running var. I am using Gretl 1.9.12cvs. I would like to do something like
matrix matFSTAT = $Fstat
which of course does not work but this is the idea of what I need. Is there an easy way to do this?
6 years, 7 months