GRETL
(Gnu Regression, Econometrics and
Time-series Library)
In this project you should analyze generated and real data. Analysis of each set of data should contain:
a) Descriptive statistics. b) Time series plot. c) Checking of normality.
d) If data are non-stationary take, for example log-differences to assure stationarity.
e) Descriptive statistics, time series plot, checking of normality, analysis of stationarity of new data. f) Analysis of correlogram, finding AR and MA processes order.
g) Estimating ARMA processes (in gretl)
h) Compare estimated models using information criterions. i) Choosing the best ARMA model.
j) Estimating ARMA-GARCH processes (in Ox)
k) Compare estimated models using information criterions. l) Choosing the best ARMA-GARCH model.
Projekty oddajemy w wersji papierowej. Kazdy projekt bedzie "broniony" indywidualnie.
W projekcie prosze zamiescic kolejne kroki dochodzenia do ostatecznego modelu
(co obserwujemy, jakie modele beda rozpatrywane w zwiazki z tym, jakie sa kryteria wyboru optymalnego modelu itd, warto porobic troche rysunkow)
Which financial time series features do you observe? Which class of models do you chose and why?
What are the probably orders of the models? Which model is the best for given data?
Is it really the best existing model?
wygenerowane dane pochodza z modeli poznanych na wykladzie -ARMA + szeroka klasa modeli GARCH z roznymi efektami + rozne rozklady warunkowe
rzedy modeli sa zdroworozsadkowe czyli zawiaraja sie w ARMA(2,2), GARCH(2,1)
1. How to get and install gretl
a) Go to page
http://gretl.sourceforge.net/ or www.gretl.pl
and download gretl
b) Install gretl with default parameters
After that, gretl will be installed, but usually in Polish
language, to run gretl in English language you have to
click:
Narz
ę
dzia -> Ustawienia -> Ogólne
or Tools -> Preferences -> General
Choose Wybór j
ę
zyka dla GUI -> English
or Language Preserence -> Polish
2. To load data to gretl from ASCI (text) file, you have to choose
from menu:
File -> Open data -> Import -> Text/CSV…
When gretl loads chosen file it will open window with question
about structure of data. Answer Yes
a) Choose Time series, then click Forward
b) Choose Daily (5 days), then click Forward
c) Type 1970/01/01 as a starting date, then click Forward (any
other date will do)
3.
To load data to gretl from Excel file:
File -> Open data -> Import -> Excell…
Gretl will open first window, click Yes. Then it will open
next window with the same question like previous, so
5.
With loaded and set data you can:
a) Get a time series plot: click with right mouse button
second variable name (first is a constant added by
gretl) and choose Time series plot
b) Get a descriptive statistics: click with right mouse
button and choose Descriptive statistics
c) Get a correlogram: click with right mouse button and
choose Correlogram (you have to choose a proper lag,
in most cases the default lag will be good)
After choosing lag two windows will open, first with graph of
autocorrelation and partial autocorrelation, second with coefficient of
autocorrelation and partial autocorrelation functions (with significance of
each coefficient).
6
. Transformations of variables:
a) returns:
Add -> Define new variable…
In opened window type: new_variable = (x – x(-1))/x(-1)
where x – name of variable
b) logarithmic returns:
8. Checking of normality:
Variable -> Frequency distribution
Variable -> Frequency distribution-> Against Normal
-10 -8 -6 -4 -2 0 2 4 6 -4 -3 -2 -1 0 1 2 3 4 Normal quantiles
Q-Q plot for rates y = x
The lower the p-value, the less likely the result is if the null hypothesis is true,
and consequently the more "significant" the result is, in the sense of statistical
significance.
One often rejects the null hypothesis when the p-value is less
than 0.05 or 0.01
, corresponding respectively to a 5% or 1% chance of
rejecting the null hypothesis when it is true (Type I error).
9. Checking AR and MA processes order:
Variable -> Correlogram
-1 -0.5 0 0.5 1 0 2 4 6 8 10 12 14 16 lagACF for Data
+- 1.96/T^0.5 -1 -0.5 0 0.5 1 0 2 4 6 8 10 12 14 16 lag
PACF for Data
+- 1.96/T^0.5
10. Estimating ARMA processes:
a) Model -> Time series -> ARIMA…
b) Choose dependent variable.
H0: parameter insignificant p-value<0.05 – reject H0
11. You can save the residuals of model by choosing
-0.08 -0.06 -0.04 -0.02 0 0.02 0.04 0.06 0.08 0 2 4 6 8 10 12 14 16 lag
ACF for uhat6
+- 1.96/T^0.5 -0.08 -0.06 -0.04 -0.02 0 0.02 0.04 0.06 0.08 0 2 4 6 8 10 12 14 16 lag
PACF for uhat6
0 5 10 15 20 25 30 -0.04 -0.02 0 0.02 0.04 0.06 Density Data Data N(0.0037189,0.01697) Test statistic for normality:
Chi-squared(2) = 42.977 pvalue = 0.00000
Example
Example – data_gretl.xls
-0.2 -0.1 0 0.1 0.2 0 2 4 6 8 10 12 14 16 lagACF for Data
+- 1.96/T^0.5 -0.2 -0.1 0 0.1 0.2 0 2 4 6 8 10 12 14 16 lag
PACF for Data
-0.08 -0.06 -0.04 -0.02 0 0.02 0.04 0.06 0.08 0 5 10 15 20 lag Residual ACF +- 1.96/T^0.5 -0.08 -0.06 -0.04 -0.02 0 0.02 0.04 0.06 0.08 0 5 10 15 20 lag Residual PACF +- 1.96/T^0.5
check the normality of ARMA residuals
do the ARCH test
Test for normality of residual -
Null hypothesis: error is normally distributed
Test statistic: Chi-square(2) = 21.7633
Test for ARCH of order 5 -
Null hypothesis: no ARCH effect is present
Test statistic: LM = 92.6072
with p-value = P(Chi-square(5) > 92.6072) = 1.90273e-018
Test for ARCH of order 5
coefficient std. error t-ratio p-value
---
alpha(0) 0.000137679 1.99112e-05 6.915 8.41e-012 ***
alpha(1) 0.175695 0.0316164 5.557 3.53e-08 ***
alpha(2) 0.0596048 0.0318745 1.870 0.0618 *
alpha(3) 0.0377358 0.0319088 1.183 0.2372
alpha(4) 0.120201 0.0318733 3.771 0.0002 ***
alpha(5) 0.105740 0.0316159 3.345 0.0009 ***
0 0.05 0.1 0.15 0.2 0.25 0.3 0.35 0.4 0.45 -3 -2 -1 0 1 2 3 Density uhat6 N(0.01685,1.0021) Test statistic for normality:
Chi-squared(2) = 3.736 pvalue = 0.15440
-0.08 -0.06 -0.04 -0.02 0 0.02 0.04 0.06 0.08 0 5 10 15 20 lag ACF for usq6
+- 1.96/T^0.5 -0.08 -0.06 -0.04 -0.02 0 0.02 0.04 0.06 0.08 0 5 10 15 20 lag PACF for usq6
+- 1.96/T^0.5
0 0.05 0.1 0.15 0.2 0.25 0.3 0.35 0.4 0.45 -3 -2 -1 0 1 2 3 Density uhat6 uhat6 N(0.01685,1.0021) Test statistic for normality:
Chi-squared(2) = 3.736 pvalue = 0.15440
if it is not Gaussian distribution we need t-Student
distribution or skewed t-St