1 GRETL (Gnu Regression, Econometrics and Time-series Library)
2 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.
3 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) proponowane narzedzia do analizy to GRETL oraz OX z pakietem G@rch
4 1. How to get and install gretl a) Go to page http://gretl.sourceforge.net/ or www.gretl.pl and download gretl (Section Gretl for Windows, gretl-1.9.6.exe)
5 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
Choose Wybór języka dla GUI -> English or Language Preserence -> Polish 6
7 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) d) Click Apply (if everything is OK).
8
9
right mouse button 10
11 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 you have to choose the same steps.
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). 12
13 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: Add -> Log differences of selected variables
14
15 8. Checking of normality: Variable -> Frequency distribution Variable -> Frequency distribution-> Against Normal Q-Q plot for rates 6 y = x 4 2 0-2 -4-6 -8-10 -4-3 -2-1 0 1 2 3 4 Normal quantiles
16 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).
17 9. Checking AR and MA processes order: Variable -> Correlogram other data than APATOR!! ACF for Data 1 +- 1.96/T^0.5 0.5 0-0.5-1 0 2 4 6 8 10 12 14 16 lag PACF for Data 1 +- 1.96/T^0.5 0.5 0-0.5-1 0 2 4 6 8 10 12 14 16 lag
18 10. Estimating ARMA processes: a) Model -> Time series -> ARIMA b) Choose dependent variable.
H0: parameter insignificant p-value<0.05 reject H0 19
20 11. You can save the residuals of model by choosing Save->Residuals in the window with models characteristics
21 ACF for uhat6 0.08 0.06 0.04 0.02 0-0.02-0.04-0.06-0.08 +- 1.96/T^0.5 0 2 4 6 8 10 12 14 16 lag PACF for uhat6 0.08 0.06 0.04 0.02 0-0.02-0.04-0.06-0.08 +- 1.96/T^0.5 0 2 4 6 8 10 12 14 16 lag
TEST of ARCH effect in residuals 22
GARCH models 23
GARCH model 24
Example data_gretl.xls 25
Density 26 Example data_gretl.xls 30 Test statistic for normality: Chi-squared(2) = 42.977 pvalue = 0.00000 Data N(0.0037189,0.01697) 25 20 15 10 5 0-0.04-0.02 0 0.02 0.04 0.06 Data
27 Example data_gretl.xls ACF for Data 0.2 +- 1.96/T^0.5 0.1 0-0.1-0.2 0 2 4 6 8 10 12 14 16 lag PACF for Data 0.2 +- 1.96/T^0.5 0.1 0-0.1-0.2 0 2 4 6 8 10 12 14 16 lag
28
29
30 Residual ACF 0.08 0.06 0.04 0.02 0-0.02-0.04-0.06-0.08 +- 1.96/T^0.5 0 5 10 15 20 lag Residual PACF 0.08 0.06 0.04 0.02 0-0.02-0.04-0.06-0.08 +- 1.96/T^0.5 0 5 10 15 20 lag
31
32 check the normality of ARMA residuals do the ARCH test
33 Test for normality of residual - Null hypothesis: error is normally distributed Test statistic: Chi-square(2) = 21.7633 with p-value = 1.88e-005
34
35 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 ***
36
Density standardized residuals 0.45 0.4 Test statistic for normality: Chi-squared(2) = 3.736 pvalue = 0.15440 uhat6 N(0.01685,1.0021) 0.35 0.3 0.25 0.2 0.15 0.1 0.05 0-3 -2-1 0 1 2 3 uhat6 37
squared residuals of ARMA model 38
39 squared standardized residuals ACF for usq6 0.08 0.06 0.04 0.02 0-0.02-0.04-0.06-0.08 +- 1.96/T^0.5 0 5 10 15 20 lag PACF for usq6 0.08 0.06 0.04 0.02 0-0.02-0.04-0.06-0.08 +- 1.96/T^0.5 0 5 10 15 20 lag
Density 40 if it is not Gaussian distribution we need t-student distribution or skewed t-st leverage effect OX + G@rch 0.45 0.4 Test statistic for normality: Chi-squared(2) = 3.736 pvalue = 0.15440 uhat6 N(0.01685,1.0021) 0.35 0.3 0.25 0.2 0.15 0.1 0.05 0-3 -2-1 0 1 2 3 uhat6