Examples of Gretl scripts
by Carlos Andrade
Dear All,
Where to get examples of Gretl scripts for different types of analysis?
--
Atenciosamente,
Prof. Carlos A. S. de Andrade
LAPEA - Laboratório de Pesquisa em Economia Aplicada e Engenharia de
Produção
Universidade Federal de Campina Grande.
Centro de Humanidades
Unidade Acadêmica de Economia
12 years
Re: [Gretl-users] GARCH, Forecasting
by Allin Cottrell
On Mon, 17 Jan 2011, [ISO-8859-1] Alejandro Mosi�o wrote:
> Maybe i was not too much specific last time:
>
> I have a variable "y" that follows a GARCH(1,1) process. Then, i Gretl i
> type:
>
> garch 1 1 ; y const
>
> Then i got the result and forecasting the out-of-sample values of y can
> be done in the usual way. However, i'm interested in forecasting the
> out-of-sample variance. I don't know if such a function exists in Gretl.
There is no built-in function to do this, but you can compute a
one-step ahead forecast of the variance from the model data, as
hown in the following example script.
<script>
open b-g.gdt
garch 1 1 ; Y
series e = $uhat
series h = $h
dataset addobs 10
a0 = $coeff[2]
a1 = $coeff[3]
b1 = $coeff[4]
series hfc = h
# set future errors to their expectation
e = misszero(e)
# forecast the variance
hfc = a0 + a1 * e(-1)^2 + b1 * hfc(-1)
smpl 1970 ;
print e h hfc --byobs
</script>
Allin Cottrell
12 years, 5 months
Hansl Help
by Henrique Andrade
Dear Hansl experts,
I would like to write a Hansl code but unfortunately I'm out of creativity
:(
I have a binary series with blocks of 0 and 1. Something like
X=(0,0,0,1,1,1,1,1,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1).
Here are the steps I need do follow:
(1) Find the number of 1-blocks;
(2) Calculate the average number of observations inside these blocks.
In my hypothetical example, the X series, I have two blocks, and these
blocks have an average of 8 observations (five observations in the first
block and eleven observations in the second block).
Any help will be appreciated.
Um abraço,
Henrique Andrade*
*
13 years, 4 months
Problem in the Command Help Example
by Henrique Andrade
Dear Gretl Team,
I think I found a little error in the example of the "printf" command help:
<hansl>
ols 1 0 2 3
genr b = $coeff(2)
genr se_b = $stderr(2)
printf "b = %.8g, standard error %.8g, t = %.4f\n", b, se_b, b/se_b
</hansl>
If we use "[ ]" instead of "( )" the error goes away :-)
Um abraço,
Henrique Andrade*
*
13 years, 4 months
CSV and decimal point character
by Henrique Andrade
Dear Gretl Community,
I´m trying to save data into comma-separated values (the csv extension)
files using the Brazilian standard (comma as the decimal point character)
but it is not working. Gretl only saves the text file with point as the
decimal point character.
In order to do this I'm using the following script:
<hansl>
open australia.gdt
set csv_delim semicolon
set force_decpoint on
set csv_na ""
store "C:\Users\Henrique\Desktop\Teste.csv" --csv --overwrite
--comment="Dados dessazonalizados no Gretl via X-12-Arima"
</hansl>
Best regards,
Henrique Andrade
13 years, 5 months
Create a random variable
by Carlos Andrade
Gretl List
How to generate a random variable for a given range of values?
Example: 46 observations between 0 and 45.
--
Atenciosamente,
Prof. Carlos A. S. de Andrade
LAPEA - Laboratório de Pesquisa em Economia Aplicada e Engenharia de
Produção
Universidade Federal de Campina Grande.
Centro de Humanidades
Unidade Acadêmica de Economia
13 years, 5 months
Ralph M Rodriguez/PO/KAIPERM is out of the office.
by Ralph.M.Rodriguez@kp.org
I will be out of the office starting 11/23/2011 and will not return until
12/01/2011.
Hi All, I will be out of the office on business from Monday Nov 28
returning to the office Thursday Dec 1, 2011. I will be cheking emails
during my trip. But, if you have an immediate concern with Cost Model,
email CM-Help(a)kp.org or contact Bradley Njus at 510 625 4595.
Thanks so much,
Ralph
13 years, 5 months
Re: [Gretl-users] Time Diversification and Estimation Risk
by Arina Andryeyeva
>> Hello,
>>
>> We are students in the Masters of Finance program in Belgium and are working on a project of Time Diversification. In order to check whether this concept exists, we need to perform a block bootstrap simulation together with the portfolio optimization analysis. We need to perfrom the above mentioned techniques in Gretl and have some questions for you.
1. How to write a code in order to divide a sample of three different series (Stocks, bonds and tbills) into a subsample. We have a sample that consists of 274 observations, we should divide it into subsamples: from 1st observation to 12th one (1 year holding period), from 1st to 60th etc
2. How to build variance-covariance matrix
3. How to find optimal weights for each holding period (our holding periods are of 1 year, 5 yrs, 10, 15 and 20)
>>
>> We very much appreciate your help and thank you in advance for taking the time in addressing these questions.
>>
>> Arina and Valeriya.
>
This is what we basically need to do in Gretl:
Method
In this section, we describe the optimization method used to find the asset weights of the efficient portfo- lios and how we applied the bootstrap approach to construct empirical distributions for asset weights.
Efficient Portfolios. Investorswere assumed to use the mean-variance criterion when forming their optimal portfolios, and the investment hori- zons we considered were 1 year, 5 years, and 10 years.5 The investors look for the portfolio weights x that minimize the following trade-off between
Min x'lx - Xg'x
subject to I'x = 1 X?>0,
variance and expected investment horizon:
The Bootstrap Approach. The bootstrap method, introduced by Efron (1979), is a computer- intensive method for estimating the distribution of an estimator or a statistic by resampling the data at hand. In this study, we used a nonparametric mov- ing block bootstrap introduced by Carlstein (1986) and Kiinch (1989), in which serial dependence, as well as cross-sectional correlation, is preserved within the blocks. We used a nonparametric boot- strap because a parametric form gives inconsistent estimates if the structure of the serial correlation is misspecified or not tractable. The assets were drawn cross-sectionally, so they belonged to the same time period in the original series. Thus, we never con- structed a five-year relationship between stocks and bills that did not exist in the original series. The sample of real continuous returns on stocks and bills, R, was grouped into k overlapping blocks of 60 months. We chose a block length of 60 months because it is probably long enough to pick up most forms of possible time dependencies. The blocks were then resampled with replacement b times until a series R*with the same length as R was obtained, which was equivalent to constructing a realization or trajectory for stocks and bills for each drawing or R*.From each resampled R*,we calcu- lated a variance-covariance matrix, Y*, and an expected return vector, p&*,for each investment horizon from nonoverlapping holding-period returns. We then used 1* and ,u as inputs to the mean-variance optimization and obtained the opti- mal portfolio weights, x*. We repeated this proce- dure 1,000 times. In the end, we had a set of bootstrapped observations for each optimal portfo- lio in the mean-variance optimization and every investment horizon.
The empirical distribution of the weights, based on the bootstrap samples, allowed us to draw infer- ences about the weights. We constructed 90 percent confidence intervals based on the percentiles of the distribution of the assets weights. We ordered the observations in ascending order. That is, the 5 per- cent percentile, x*(a)i,s the 50th ordered value of the replications and x*(l-a)is the 95 percent percentile and the 950th ordered value of the replications. We obtained an indication of the magnitude of the esti- mation risk from the intervals because the confi- dence region displayed the degree of uncertainty associated with the efficient frontier. Our bootstrap approach to measuring estimation risk is an alterna- tive to the confidence regions
13 years, 5 months
use of lagged dependent variables with Cochrane-Orcutt and Prais-Winsten estimation
by Gabor Ruzsa
Dear Gretl users,
I'm totally puzzled by the option in Gretl to include lags of the dependent
variable in time series models estimated via FGLS (Cochrane-Orcutt or
Prais-Winsten). As much as I know, the consistence of the FGLS estimator
requires the strict exogeneity of the regressors, i.e. including lagged
dependent variables is out of question.
Does anybody have a possible explanation? I've looked in Gretl's user's
manual but haven't found any indication about this matter.
Any comments are very welcome and appreciated.
Gabor Ruzsa
Corvinus University of Budapest, Hungary
13 years, 5 months
an econometric question about panels (off topic ?)
by nadaud@centre-cired.fr
Dear all gretl listers, greetings from Paris !
I would like your advice on an econometric question.
May be a bit off topic I guess, but well, I could not find a clear answer...
I have to review results on a panel an estimation on 17 OECD countries
1985-2003. The series stationarity is assumed and not tested, but it seems
reasonable for most (i.e: most are in first differences but some in
levels). The authors use 2SLS with IV but do not test stationarity.
What makes me uneasy is when they do not report the usual residuals checks
nor conduct a Chow test (My guess is that the test on this period is so
bad that the whole results are not tenable).
I think this is not very good practice, do you agree ?
Finally I computed semi-partial correlations and these reveal that just
one variable seem to have any explanatory power. I would like to know if
it OK to compute semi-partial correlations after estimation in this
context, and if these have at least an indicative content.
Also the guys tried about 23 other variables which were rejected. There is
strong flavor of datamining here, I know it is very sensitive question but
my opinion is that the results are very suspicious with the usual standard
significance levels.
So, I would like your advice on those questions.
I will try to find the data and run them into GRETL but here in France
this study begins to generate a real political mess !
cheers to all !
Sincerely
Franck
Franck Nadaud
CIRED
UMR 8568 CNRS - EHESS, ENPC, ENGREF, CIRAD
45 bis avenue de la Belle Gabrielle
94736 Nogent-sur-Marne Cedex
TEL: 33-1-43-94-73-94
FAX: 33-1-43-94-73-70
MOB: 06-07-39-92-75
France
13 years, 5 months
OPG inversion problem
by Dan Běsoň
Dear everybody,
I am trying to estimate an ARMA process using MLE and then to extend it by jointly estimating ARMA-GARCH. The following code
series in = log_ret*100
scalar mu = mean(in)
scalar h = var(in)
scalar c = 0.001
scalar phi1 = -0.9
scalar phi2 = -0.89
scalar phi3 = -0.47
scalar phi4 = -0.90
scalar phi5 = -0.45
scalar phi6 = -0.31
scalar phi7 = -0.14
scalar theta1 = 0.87
scalar theta2 = 0.81
scalar theta3 = 0.29
scalar theta4 = 0.82
scalar theta5 = 0.33
scalar theta6 = 0.17
mle ll=-0.5*(log(h) + (e^2)/h)
series e = in - mu
params c phi1 phi2 phi3 phi4 phi5 phi6 phi7 theta1 theta2 theta3 theta4 theta5 theta6
end mle --hessian
produces an "failed to invert OPG matrix GG" error regardless of whether I use --hessian. log_ret are daily logreturns of the FTSE index. What could be the problem? The initial values of phis and thetas are taken close to the real values estimated by the ARMA window. Any hint is much appreciated.
Daniel.
13 years, 5 months
unit root test
by Surya Dev
how do you choose optimal lag while carrying out ADF test in Gretl?
13 years, 5 months
Xlsx problem
by Henrique Andrade
Dear Gretl Developers,
I´m trying to open some .xlsx files and I´m getting the following error
messages:
? open "L:\CONFIDENCIAL\Planilha\Dados Países\Brasil\Mercado de
Crédito\Dados Crédito.xlsx" --sheet="Gretl2" --rowoffset=148
'Gretl2' -> worksheets/sheet12.xml
expected 403 shared strings but only found 397
Error executing script: halting
expected 403 shared strings but only found 397
Error executing script: halting
I think the error is related with the Excel file format because when I
convert to the old format (the .xls one) the error disappears.
Best regards,
Henrique Andrade*
*
13 years, 5 months
on variable labels
by artur bala
Dear Allin,
I'm importing some data from SPSS with a lot of value labels and I
wonder if it can be manageable for you to make gretl save/add/change the
value labels for dicrete/ordinal/categorical variables?
best,
artur
13 years, 5 months
how to reproduce Verbeek's Table 5.4 (one-step GMM)?
by Qi Shi
Dear all,
I want to reproduce Verbeek's Table 5.4, below is my scripts:
open pricing.gdt
set force_hc on
scalar delta=0.5
scalar gamma=0.5
series e0=delta*cons^(-gamma)*(1+rf)-1
series e1=delta*cons^(-gamma)*(rf-r1)
series e2=delta*cons^(-gamma)*(rf-r2)
series e3=delta*cons^(-gamma)*(rf-r3)
series e4=delta*cons^(-gamma)*(rf-r4)
series e5=delta*cons^(-gamma)*(rf-r5)
series e6=delta*cons^(-gamma)*(rf-r6)
series e7=delta*cons^(-gamma)*(rf-r7)
series e8=delta*cons^(-gamma)*(rf-r8)
series e9=delta*cons^(-gamma)*(rf-r9)
series e10=delta*cons^(-gamma)*(rf-r10)
list xlist=e0 e1 e2 e3 e4 e5 e6 e7 e8 e9 e10
matrix V0=I(11)
gmm list e=xlist
orthog e; const
weights V0
params delta gamma
end gmm
what is the problem? Who can tell me? Thanks
--
shi, qi
13 years, 5 months
missing value functions for matrices
by Annaert Jan
Is there a reason why functions like missing, misszero and zeromiss are not available for matrices? The ok function does seem to work with matrices (in contrast to the function reference).
Jan Annaert
13 years, 5 months
Button Install for functions in gretl 1.9.6
by Giuseppe Vittucci
Dear all,
I do not know if the problem has been already solved.
I have recently used gretl 1.9.6 on Windows Vista.
On a fresh installation, the button Install on the left-top corner of
the window in File -> Function files -> On server.. does not work and
returns an error message (File not found).
All works instead by right-clicking on the file and using the option
Install in the menu.
Bye
Giuseppe
13 years, 5 months
Problemas en Gretl 1.9.6
by Hebert Suárez Cahuana
Estimados todos:
Parece que algo anda mal con la versión 1.9.6, utilizo linux ubuntu, le doy
./configure make make check y se instala pero ahora no puede abrir ningún
archivo, no se puede hacer nada porque el programa se cierra
automáticamente y aparece en la consola el mensaje siguiente: Ilegal
instruccion
Quiero regresar a la versión 1.9.5 que si estaba bien pero no se como
hacerlo.
Saludos
Hebert Suarez Cahuana
Perú
--
Atentamente:
Hebert Suárez Cahuana
Departamento Académico de Economía
Escuela Profesional de Economía
Universidad Nacional de San Agustín
Av. Venezuela S/N Cercado
www.unsa.edu.pe
Arequipa-Peru
Telefono 51 54 215105
E-mail: hsuarezc(a)unsa.edu.pe
"NO PREGUNTES QUE PUEDE HACER TU PAÍS POR TI, SINO PREGUNTA QUE PUEDES
HACER TU POR TU PAÍS" John Kennedy Presidente de los Estados Unidos
13 years, 5 months
Failed to load plugin Excel-import
by Sergey Tsabolov (aka linuxman)
Hi to all,
I run the gretl version 1.9.2 and when I need to import excel file I
get the *Failed to load plugin: /usr/lib/gretl-gtk2/excel_import.so*
PC run Ubuntu 10.04 Full upgraded
Have some one solution for the problem.
Thanks for help.
--
---------------------------------------------------------------
Don't send me documents in .doc , .docx, .xls, .ppt , .pptx .
Send it with ODF format : .odt , .odp , .ods or .pdf .
Try to use Open Document Format : http://el.libreoffice.org
Save you money and use GNU/Linux Distro http://distrowatch.com/
--------------------------------------------------------------
First they ignore you, then they ridicule you, then they fight you,then you win!!!
13 years, 5 months
emacs mode for gretl
by ahmadou dicko
Hi everyone
This is my first post in this list, and i'm very grateful for those working
on this wonderful project so far, gretl is very great. I (already started)
would like to promote the use of this software in my school in Senegal.
But I'm also a R user and one thing Gretl lack is a complete emacs mode
like the ESS R-mode, with the gretlcli console as inferior-process, i'm
aware of the gretl-mode (which is great) but as far as I know it's not
interactive, for example you can't send line or block of code to an
inferior process...such mode can be great to learn hansl.
My elisp skill is not good enough to write a comint-mode, i started one
based on Octave-mode el file but it doesn't work.
I want to know if it's possible to create such mode using the gretcli or if
there are other possibilities ?
Any advice, hint, help or documentation on how to create such mode will be
greatly appreciated
I use ubuntu 11.10, gretl 1.96 and emacs 23.3
cheers
Ahmadou
13 years, 5 months
How can I program these in Gretl
by Samantha buxton
Hi
Im trying to do these diffusion models in Gretl and I am unsure of how I
would write a script for them.
I have attached a file as they do not want to copy over and it is very
diffucult to write them correctly in an e-mail
Thanks
Samantha Buxton
13 years, 5 months
Exact collinearity and modprint
by Giuseppe Vittucci
Dear all,
when in a regression one or more variables are omitted due to exact
collinearity, the command modprint leads to misleading results cause the
initial list of regressors does not match the vector of coefficients
returned by gretl.
Is there a way to retrieve the list of regressors dropped by gretl or
the list of regressors eventually used in the regression?
Thanks
Giuseppe
13 years, 5 months
GUI to quantreg
by Sergio Pastorello
Dear all,
it seems to me that the GUI to the quantreg command is broken in release
1.9.6. I tried to replicate the example on p. 252 of the User's Guide, but
I got an "Invalid quantile specification" error message. However, the
quantreg command still works perfectly when invoked from the console.
Also, the GUI works fine in release 1.9.5.
Is there a problem, or am I missing something?
Many thanks you for your help
Sergio Pastorello
--
Sergio Pastorello
Dipartimento di Scienze Economiche
Università di Bologna
Piazza Scaravilli, 2
40126 Bologna (BO)
ITALY
tel. +39 051 2098144
fax. +39 051 2098040
13 years, 5 months
Bug-hunting: Syntax highlighting
by Henrique Andrade
Dear Allin,
Please take a look into the pdf files attached. As one can see, there's
something wrong with the "colorido.pdf" file (lines between 73 and 197
weren't printed out in Windows Vista).
Best regards, Henrique
*Henrique*
<http://www.ufrgs.br/ppge>
13 years, 5 months
How to in Gretl
by Sam Buxton
Hi all,
I am having problems doing a number of things in gretl. I was just
wondering if anyone could help if they know how to produce the following
models in gretl
1) exponential smoothing
2) moving average
3) naive model
4) bass diffusion model.
Thanks a speedy response would be greatly apprecieated.
Sam
--
Gall y neges e-bost hon, ac unrhyw atodiadau a anfonwyd gyda hi,
gynnwys deunydd cyfrinachol ac wedi eu bwriadu i'w defnyddio'n unig
gan y sawl y cawsant eu cyfeirio ato (atynt). Os ydych wedi derbyn y
neges e-bost hon trwy gamgymeriad, rhowch wybod i'r anfonwr ar
unwaith a dilëwch y neges. Os na fwriadwyd anfon y neges atoch chi,
rhaid i chi beidio â defnyddio, cadw neu ddatgelu unrhyw wybodaeth a
gynhwysir ynddi. Mae unrhyw farn neu safbwynt yn eiddo i'r sawl a'i
hanfonodd yn unig ac nid yw o anghenraid yn cynrychioli barn
Prifysgol Bangor. Nid yw Prifysgol Bangor yn gwarantu
bod y neges e-bost hon neu unrhyw atodiadau yn rhydd rhag firysau neu
100% yn ddiogel. Oni bai fod hyn wedi ei ddatgan yn uniongyrchol yn
nhestun yr e-bost, nid bwriad y neges e-bost hon yw ffurfio contract
rhwymol - mae rhestr o lofnodwyr awdurdodedig ar gael o Swyddfa
Cyllid Prifysgol Bangor. www.bangor.ac.uk
This email and any attachments may contain confidential material and
is solely for the use of the intended recipient(s). If you have
received this email in error, please notify the sender immediately
and delete this email. If you are not the intended recipient(s), you
must not use, retain or disclose any information contained in this
email. Any views or opinions are solely those of the sender and do
not necessarily represent those of the Bangor University.
Bangor University does not guarantee that this email or
any attachments are free from viruses or 100% secure. Unless
expressly stated in the body of the text of the email, this email is
not intended to form a binding contract - a list of authorised
signatories is available from the Bangor University Finance
Office. www.bangor.ac.uk
13 years, 5 months
Re: [Gretl-users] [Gretl-devel] saving the row/col names of a matrix
by Riccardo (Jack) Lucchetti
On Wed, 2 Nov 2011, Riccardo (Jack) Lucchetti wrote:
> On Tue, 1 Nov 2011, Allin Cottrell wrote:
>
>> (b) Row and/or column names are attached to the gretl_matrix struct
>> itself, rather than the wrapper. That is more plausible, but I still
>> don't like it much. The extra memory required for an empty
>> gretl_matrix would only be two pointers (8 bytes on a 32-bit system)
>> but it represents additional complexity that I'd prefer to keep out
>> of what is in concept a mathematical type.
>
> I agree: matrices should stay as lean-and-mean as possible. Besides, there is
> the possibility of achieving Artur's original aim in Hansl, albeit in a way
> that most people will find a bit convoluted: here's two ways to do it. My
> personal preference goes to func2, but I happen to like bundles quite a lot.
Sorry for the noise: (1) I forgot to send my previous message to the
users' list; (2) there was a small glitch in func2 (corrected below); (3)
I'd like to express my point more explicitly: IMO, base types such as
matrices should stay as unencumbered by extra info (or metadata, call it
what you want) in the interest of efficiency. If you really need to wrap
up a complex set of information into one entity, that's exactly what
bundles are for.
<hansl>
set echo off
set messages off
function string func1(scalar r, scalar c, matrix *m)
string rl = ""
loop i=1..r --quiet
sprintf rl "%s,row_%d", rl, i
end loop
string cl = ""
loop i=1..c --quiet
sprintf cl "%s,col_%d", cl, i
end loop
m = zeros(r,c)
sprintf ret "%s %s", rl, cl
return ret
end function
function bundle func2(scalar r, scalar c)
bundle ret
string rl = ""
loop i=1..r --quiet
sprintf rl "%s row_%d", rl, i
end loop
ret["Rlab"] = rl
string cl = ""
loop i=1..c --quiet
sprintf cl "%s col_%d", cl, i
end loop
ret["Clab"] = cl
m = zeros(r,c)
ret["X"] = m
return ret
end function
# ----- using func1 -----------------------------
a = {}
boo = func1(3,2,&a)
rowlab = strsub(strsplit(boo, 1), ",", " ")
collab = strsub(strsplit(boo, 2), ",", " ")
rownames(a, rowlab)
colnames(a, collab)
print a
# ----- using func2 -----------------------------
bundle zoo = func2(3,2)
rowlab = zoo["Rlab"]
collab = zoo["Clab"]
a = zoo["X"]
rownames(a, rowlab)
colnames(a, collab)
print a
</hansl>
Riccardo (Jack) Lucchetti
Dipartimento di Economia
Università Politecnica delle Marche
r.lucchetti(a)univpm.it
http://www.econ.univpm.it/lucchetti
13 years, 5 months