retrieve series name from within a function
by Artur Bala
Hi,
In the following code (as a simplified example), how do I retrieve the name
of the series Y so as the OLS output shows the actual name of the variable
instead of just "Y"? I use the "varnames()" for the X-list variables
names but couldn't come out with something feasible for Y
<\hansl
function matrix m (series Y , list X )
ols Y X
end function
<hansl>
Best,
Artur
2 weeks
On leverage command
by Artur Bala
Dear all,
When I execute the "leverage --save" command on the command line, the
related series (lever, influ and dffits) are not shown in the Main windows
(but they are created) . Is this behaviour intended?
Moreover, if I save one of the 3 series with the command "series k=lever"
this makes appear on the Main window all the series produced by the
leverage command (along with the new "k" series).
Just for testing, I also tried the same commands in a script file. Nothing
strange happened and all the new generated series are shown right after the
leverage command is executed.
Best,
Artur
2 weeks
State space modelling
by bjr.newmail@gmail.com
I wanted to estimate a model with a time varying parameter (on a simple linear trend) and would appreciate some guidance as I am not a programmer in Gretl's language.
1) Where in the GUI Model set of commands do you access the State Space modelling - is by writing the spec in the MLE option?
2) I loaded the example file AWM.gdt
3)Entered the commands below exactly as specified in the manual viz. Listing 34.4: Phillips curve on Euro data with time-varying slope
4) It died at the first line.
function void at_each_step(bundle *b)
b.obsymat = transp(b.mX[b.t,])
end function
open AWM.gdt --quiet
smpl 1974:1 1994:1
/* parameter initialization */
scalar b0 = mean(INFQ)
scalar s_obs = 0.1
scalar s_state = 0.1
/* bundle setup */
bundle B = ksetup(INFQ, 1, 1, 1)
matrix B.mX = {URX}
matrix B.depvar = {INFQ}
B.timevar_call = "at_each_step"
B.diffuse = 1
/* ML estimation of intercept and the two variances */
mle LL = err ? NA : B.llt
B.obsy = B.depvar - b0
B.obsvar = s_obs^2
B.statevar = s_state^2
err = kfilter(&B)
params b0 s_obs s_state
end mle
/* display the smoothed time-varying slope */
ksmooth(&B)
series tvar_b1hat = B.state[,1]
series tvar_b1se = sqrt(B.stvar[,1])
gnuplot tvar_b1hat --time-series --with-lines --output=display \
--band=tvar_b1hat,tvar_b1se,1.96 --band-style=fill
2 weeks, 1 day
Hamilton trend-cycle decomposition
by Riccardo (Jack) Lucchetti
Hi all,
yesterday, after having taught my students the HP decomposition, I
wondered if I should also tell them that one of the greatest time-series
econometricians on Earth recently wrote a rather scathing paper entitled
"Why You Should Never Use the Hodrick-Prescott Filter", where he proposes
a simple alternative.
So this morning I rustled up a little script with Hamilton's filter. Here
it is:
<hansl>
function series hamcycle(series y, bool do_plot[1], string title[null])
h0 = 2 * $pd
h1 = h0 + 4
list PROJ = y(-h0 to -h1)
ols y 0 PROJ -q
# ht = $yhat
hc = $uhat
if do_plot
if !exists(title)
title = argname(y)
endif
print title
diff8 = y - y(-h0)
setinfo diff8 --graph-name="Random walk"
setinfo hc --graph-name="Regression"
list PLT = diff8 hc
plot PLT
options time-series with-lines
literal set linetype 1 lc rgb "#ff0000"
literal set linetype 2 lc rgb "#000000"
literal set key top right
printf "set title '%s'", title
end plot --output=display
endif
return hc
end function
# example
nulldata 300
setobs 4 1947:1
open fedstl.bin
data gdpc1 expgsc1 pcecc96
list Y = gdpc1 expgsc1 pcecc96
LY = logs(Y)
strings Titles = strsplit("GDP Exports Consumption")
k = 1
# reproduce part of figure 6
loop foreach i LY --quiet
hc = hamcycle($i*100,,Titles[k++])
endloop
</hansl>
Should we turn this into a function package?
-------------------------------------------------------
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
-------------------------------------------------------
2 weeks, 2 days
“using observations” in the estimation output
by Artur Bala
Hi all,
Ok, this is not such a great topic but I'm going to submit it anyway...
In an estimation output, gretl uses the expression "using observations...", for example:
for time series,
"Model 1: OLS, using observations 1952-1981 (T = 30)" (1)
or, for undated dataset,
"Model 1: OLS, using observations 1- 30” (2)
And this does make sense when all observations are in a row. When missing/uncomplete observations exist, gretl also provides additional information:
"Missing or incomplete observations dropped:" (3)
Now, when data are sub-sampled on a conditional criteria), (1) and (2) are (always?) reframed, for example,
"Model 1: OLS, using observations 1-13" (4)
and here "using observations..." loses its meaning given that the actual observations used in the estimation are not in a row anymore.
What if “using observations” in (4) be replaced simply by the number of observations used and additionnal info like (4) be provided informing the user that sub-sampled data are used. This will make a clear difference with (1) and (2)* the only cases when all observations used are in a row.
*Note than (2) is correct even for time series sub-sampled data but yet with all observations in a row.
Thank you for reading,
Best,
Artur
2 weeks, 6 days
LaTeX tabular view error
by Artur Bala
Hi Allin,
I encountered the following error message from the "Model window > LaTeX >
View > Tabular" menu (which is probably also a language related issue
(french) :
Échec de traitement du fichier TeX # translation: Failed to process the TeX
file
This is pdfTeX, Version 3.14159265-2.6-1.40.18 (TeX Live 2017) (preloaded
format=pdflatex)
restricted \write18 enabled.
entering extended mode
LaTeX2e <2017-04-15>
Babel <3.10> and hyphenation patterns for 84 language(s) loaded.
Testing around with the "Tabular option" dialog box, I realized that if I
uncheck the "Standard error" option, the table view works fine.
I first suspected the french accent not being handled properly as "st.
error" starts with an É, but there are still a lot of other words starting
with an É in the output being printed out correctly (and more generally, I
do not have any problem using LaTeX with french)
There's also a log file that gretl produces along with the error message
that I saved in case you may need to look at.
Best,
Artur
3 weeks
print command
by Artur Bala
Hi,
Two questions related to the "print" command.
1) Is the "range" option supposed to work jointly with the "by-obs" option?
When by-obs is omitted the full range of series is printed out despite the
specification for range. For example:
? dataset sortby absr1std
? print absr1std --byobs --range=46:50
absr1std
ME 1.426741
MT 1.460884
VT 1.742409
DC 2.616447
FL 2.902663
? print absr1std --range=46:50
Full data range: 1 - 51 (n = 51)
0.0805403 0.0908925 0.0932311 0.0987927 0.127675 0.143004 0.164553
0.193521 0.203738 0.257765 0.280333 0.304542 0.307398 0.352839
... # I'm cutting here!!
? dataset sortby state
2) I'd like to print out the 5 greatest values of a series. As you may see
above, I first sort the whole dataset, then use print with range option and
finally sort again the dataset to revert to the initial position. Ok, these
operations come with no effort at all but, and this is just a suggestion,
would it be more intuitive if a sortby option be included in the print
command? Or a "dummy" option?
Best,
Artur
3 weeks
Repeatable crash on frequency distribution on a string-valued data series from GUI
by Fred Engst
Hi Allin and Jack,
I’m a real trouble maker, it seems. :)
OK, here is a test file with the troubled data with only the hprice and inc variables. In my current gretl, it will read the data as string-valued series, and a freq on hprice will crash my gretl.
If I shorten the dataset, gretl will not read it and will give an error message instead, so I have to send you the full sample, which is much larger than the one I send before.
Fred
>
> Hi Jack,
> Attached is a small sample dataset with 3 string-valued variables, CITY, =
> hprice, & inc that crashes on CITY, hprice, but not on inc.
>
> Fred
>
>
>>
>> On Thu, 24 Dec 2020, Fred Engst wrote:
>>
>>> Hi Allin,
>>> Another repeatable crash today. This is from a dataset that my student =
>> gave me.
>>> After looking into the issue, I found that the problematic data series =
>> was actually read as a string-valued
>>> series that looked like numbers.
>>> Once I corrected this data issue, the frequency plot was fine.
>>> However, it still crashes on any string-valued data series.
>>> Attached is the crash report.
>>
>> This is weird. Normally, there is no problem with "freq" on string-valued=
>> =20
>> variables. Example:
>>
>> <hansl>
>> open grunfeld.gdt
>> freq ticker --plot=3Ddisplay
>> </hansl>
>>
>> There must be something funny in your student's dataset. Would you mind=20
>> sending it over? Thanks.
>
>
> --Apple-Mail=_F6A326C4-1187-46BA-BB14-9E5641F06218--
>
> ------------------------------
>
> Date: Thu, 24 Dec 2020 08:55:07 -0500 (EST)
> From: Allin Cottrell <cottrell(a)wfu.edu>
> Subject: [Gretl-users] Re: Repeatable crash on frequency distribution
> on a string-valued data series from GUI
> To: Gretl list <gretl-users(a)gretlml.univpm.it>
> Message-ID:
> <alpine.LFD.2.20.3.2012240850230.355041(a)myrtle.attlocal.net>
> Content-Type: text/plain; charset=US-ASCII; format=flowed
>
> On Thu, 24 Dec 2020, Fred Engst wrote:
>
>> Another repeatable crash today. This is from a dataset that my
>> student gave me.
>>
>> After looking into the issue, I found that the problematic data
>> series was actually read as a string-valued series that looked
>> like numbers.
>>
>> Once I corrected this data issue, the frequency plot was fine.
>> However, it still crashes on any string-valued data series.
>> Attached is the crash report.
>
> Thanks, Fred. That's now fixed in git, snapshots to follow.
>
> Could you please send me the xlsx file that was imported to create
> the test3.gdt file that you posted? Besides the crashing problem
> itself there's something funny happening on importing those data: we
> end up with one string value consisting of 34 spaces, for hprice.
>
> Allin
>
> ------------------------------
>
> Date: Thu, 24 Dec 2020 16:20:18 +0100 (CET)
> From: "Riccardo (Jack) Lucchetti" <p002264(a)staff.univpm.it>
> Subject: [Gretl-users] Re: Repeatable crash on frequency distribution
> on a string-valued data series from GUI
> To: Gretl list <gretl-users(a)gretlml.univpm.it>
> Message-ID: <alpine.DEB.2.21.2012241618280.2199@newvaio>
> Content-Type: multipart/mixed;
> boundary="8323329-1436782324-1608823222=:2199"
>
> --8323329-1436782324-1608823222=:2199
> Content-Type: text/plain; charset=ISO-8859-15; format=flowed
> Content-Transfer-Encoding: quoted-printable
>
> On Thu, 24 Dec 2020, Allin Cottrell wrote:
>
>> On Thu, 24 Dec 2020, Fred Engst wrote:
>>
>>> Another repeatable crash today. This is from a dataset that my student=
> gave=20
>>> me.
>>> =20
>>> After looking into the issue, I found that the problematic data series=
> was=20
>>> actually read as a string-valued series that looked like numbers.
>>> =20
>>> Once I corrected this data issue, the frequency plot was fine.
>>> However, it still crashes on any string-valued data series.
>>> Attached is the crash report.
>>
>> Thanks, Fred. That's now fixed in git, snapshots to follow.
>>
>> Could you please send me the xlsx file that was imported to create the=20
>> test3.gdt file that you posted? Besides the crashing problem itself the=
> re's=20
>> something funny happening on importing those data: we end up with one s=
> tring=20
>> value consisting of 34 spaces, for hprice.
>
> I just pushed another commit to git to fix a bug exposed by the data file=
> =20
> that Fred sent. You'd get a segfault if you tried to apply the atof()=20
> function to the hprice series. Now this is fixed.
>
> Thanks, Fred!
>
> -------------------------------------------------------
> Riccardo (Jack) Lucchetti
> Dipartimento di Scienze Economiche e Sociali (DiSES)
>
> Universit=E0 Politecnica delle Marche
> (formerly known as Universit=E0 di Ancona)
>
> r.lucchetti(a)univpm.it
> http://www2.econ.univpm.it/servizi/hpp/lucchetti
> -------------------------------------------------------
> --8323329-1436782324-1608823222=:2199--
>
> ------------------------------
>
> Subject: Digest Footer
>
> _______________________________________________
> Gretl-users mailing list -- gretl-users(a)gretlml.univpm.it
> To unsubscribe send an email to gretl-users-leave(a)gretlml.univpm.it
> Website: https://gretlml.univpm.it/postorius/lists/gretl-users.gretlml.univpm.it/
>
>
> ------------------------------
>
> End of Gretl-users Digest, Vol 167, Issue 30
> ********************************************
3 weeks, 3 days
Repeatable crash on frequency distribution on a string-valued data series from GUI
by Fred Engst
Hi Allin,
Another repeatable crash today. This is from a dataset that my student gave me.
After looking into the issue, I found that the problematic data series was actually read as a string-valued series that looked like numbers.
Once I corrected this data issue, the frequency plot was fine.
However, it still crashes on any string-valued data series.
Attached is the crash report.
Best,
Fred
3 weeks, 4 days