Introduction to Econometrics
Practical exercise with GRETL
Roberto Casarin
Universitá Ca’ Foscari
9th October 2012
R. Casarin (Universitá Ca’ Foscari) Introduction to Econometrics Practical exercise with GRETL 9th October 2012 1 / 18
Contents
1 Import Data
2 Stationarity test
3 Specify the static model
4 Test the residuals for Normality, Heteroskedasticity and Autocorrelation
5 Specify the dynamic model
6 Test the residuals for Normality, Heteroskedasticity and Autocorrelation
R. Casarin (Universitá Ca’ Foscari) Introduction to Econometrics Practical exercise with GRETL 9th October 2012 2 / 18
Import Data
Have a look to the data file Let name [Link] be the file which contains the
dataset. Open it and copy data block (e.g. cells A9:H138 ) of Foglio1 to Foglio2
(e.g. cells A2:H131 ). Put in the first line of Foglio2 the name of the variables.
Save the file and exit it.
Import data Import data from excel using Open>Import Data>Excel, choose
name [Link]. The sheet to import is Foglio2. Use a time series interpretation and
the option other for the frequency.
R. Casarin (Universitá Ca’ Foscari) Introduction to Econometrics Practical exercise with GRETL 9th October 2012 3 / 18
Stationarity test
Run an Augmented-Dickey Fuller (ADF) test for stationarity of the series y .
Select from the main menu use: Variable>Unit Roots> ADF.... Then you need to
specify
1 number of lag (e.g. 12)
2 with constant
3 level of variable
If the p-value of the ADF statistics less than the significance level (e.g. 5%) then
we reject the null hypothesis (i.e. there is not a unit root).
Remark: the null of the ADF is presence of unit root.
Remark: if the dependent variable has not a unit root then you can use the level
of the dependent variable in the next step of the practical exercise. Otherwise one
solution is to use the difference of the dependent y and independent x1 ,...,x7
variables.
R. Casarin (Universitá Ca’ Foscari) Introduction to Econometrics Practical exercise with GRETL 9th October 2012 4 / 18
Specify the static model
We would like to estimate the following model
i .i .d.
yt = β0 + β1 x1t + . . . + β7 x7t + εt , εt ∼ N (0, σ 2 ) (1)
Select from the main menu: Model>OLS.... Let y be the dependent variable and
x1 , . . . , x7 the independent variable.
Model 1: OLS, using observations 1–130, Dependent variable: y
Coefficient Std. Error t-ratio p-value
const 111.592 40.5481 2.7521 0.0068
x1 2.87047 5.40126 0.5314 0.5961
x2 2.25649 4.43552 0.5087 0.6119
x3 −0.0742018 0.493227 −0.1504 0.8807
x4 0.955572 1.13566 0.8414 0.4018
x5 0.314100 0.443267 0.7086 0.4799
x6 0.243707 0.497939 0.4894 0.6254
x7 0.503825 0.239370 2.1048 0.0374
R. Casarin (Universitá Ca’ Foscari) Introduction to Econometrics Practical exercise with GRETL 9th October 2012 5 / 18
Normality test for the residual
1 save the residuals (from the menu of the OLS estimation output select
save>residuals) with name uhat1
2 use the Jarque-Bera test on uhat1. From the main menu select
Variable>normality test.
3 The null of the JB test is normally distributed variables. If the p-value is less
than a given significance level (e.g. 5%) then we cannot accept the null.
Example
Test for normality of uhat1:
Doornik-Hansen test = 2.04534, with p-value 0.359633
Shapiro-Wilk W = 0.984102, with p-value 0.133669
Lilliefors test = 0.0577337, with p-value = 0.35
Jarque-Bera test = 1.92068, with p-value 0.382763
R. Casarin (Universitá Ca’ Foscari) Introduction to Econometrics Practical exercise with GRETL 9th October 2012 6 / 18
Significance of the regression (1)
Use the F-statistics (see boldface in the table of the previous slide) to test
the joint significance of regressors.
If the p-value is lower than the chosen significance level (e.g. 5%) we cannot
accept the null hypothesis (i.e., the coefficients are jointly different from 0).
In this example 0.536808 > 0.05 thus we accept the null.
R. Casarin (Universitá Ca’ Foscari) Introduction to Econometrics Practical exercise with GRETL 9th October 2012 7 / 18
Significance of the regression (2)
Model 1: OLS, using observations 1–130, Dependent variable: y
Coefficient Std. Error t-ratio p-value
const 111.592 40.5481 2.7521 0.0068
x1 2.87047 5.40126 0.5314 0.5961
x2 2.25649 4.43552 0.5087 0.6119
x3 −0.0742018 0.493227 −0.1504 0.8807
x4 0.955572 1.13566 0.8414 0.4018
x5 0.314100 0.443267 0.7086 0.4799
x6 0.243707 0.497939 0.4894 0.6254
x7 0.503825 0.239370 2.1048 0.0374
Mean dependent var 143.9530 S.D. dependent var 56.98997
Sum squared resid 399176.1 S.E. of regression 57.20083
R2 0.047252 Adjusted R 2 -0.007414
F(7, 122) 0.864383 P-value(F ) 0.536808
Log-likelihood −706.3875 Akaike criterion 1428.775
Schwarz criterion 1451.715 Hannan–Quinn 1438.096
ρ̂ −0.113820 Durbin–Watson 2.202721
R. Casarin (Universitá Ca’ Foscari) Introduction to Econometrics Practical exercise with GRETL 9th October 2012 8 / 18
Significant regressors and model selection
1 Use the t-statistics (t-ratio column of the OLS estimation output) and its
p-value to test the null hypothesis that a given coefficient is equal to zero.
2 Comment the results.
3 Drop the non-significant regressors from the model and re-estimate the
constrained model. Compare the general and the constrained models in terms
of adjusted-R 2 and choose the best model in terms of adjusted-R 2
R. Casarin (Universitá Ca’ Foscari) Introduction to Econometrics Practical exercise with GRETL 9th October 2012 9 / 18
Residual analysis - Heteroschedasticity
1 From the menu of the OLS estimate output select test>heteroskedasticity
2 then select a test: White or Breusch-Pagan and comment the results.
3 e.g., in the White’s test, find the value of Obs ∗ R 2 and its [Link] the
p-value is lower than the chosen significance level we cannot accept the null
hypothesis (i.e., there is heteroscedasticity).
Example White’s test for heteroskedasticity OLS, using observations 1-130 Dependent
coefficient std. error t-ratio p-value
const -24930.9 20474.6 -1.218 0.2264
x1 79.6790 3513.09 0.02268 0.9820
x2 6289.49 4115.87 1.528 0.1298
variable: uhat 2
x3 11.9410 418.071 0.02856 0.9773
...
X7 X8 -2.93748 2.15569 -1.363 0.1762
sq x7 -0.448519 0.732439 -0.6124 0.5418
Unadjusted R-squared = 0.184702
Test statistic: TR2 = 24.011265,with p-value = P(Chi-quare(35) > 24.011265) =
0.919422 then the errors are homoskedastic.
R. Casarin (Universitá Ca’ Foscari) Introduction to Econometrics Practical exercise with GRETL 9th October 2012 10 / 18
Residual analysis - Autocorrelation (1)
1 From the menu of the OLS estimate output select test>autocorrelation
2 then select 10 lags and comment the results.
3 e.g., in the Breusch-Godfrey’s test, find the value of Obs ∗ R 2 and its
[Link] the p-value is lower than the chosen significance level we cannot
accept the null hypothesis (i.e., there is autocorrelation).
R. Casarin (Universitá Ca’ Foscari) Introduction to Econometrics Practical exercise with GRETL 9th October 2012 11 / 18
Residual analysis - Autocorrelation (2)
Example Breusch-Godfrey test for autocorrelation up to order 10 OLS, using
observations 1-130 Dependent variable: uhat
coefficient std. error t-ratio p-value
const -13.1038 40.5470 -0.3232 0.7472
x1 2.37713 5.30276 0.4483 0.6548
...
x7 -0.168956 0.247141 -0.6836 0.4956
uhat 1 -0.136409 0.0982263 -1.389 0.1677
uhat 2 0.0222771 0.0988475 0.2254 0.8221
uhat 3 -0.0836637 0.100420 -0.8331 0.4065
uhat 4 -0.259291 0.0996482 -2.602 0.0105 **
uhat 5 -0.0144153 0.100014 -0.1441 0.8857
uhat 6 -0.197330 0.0997334 -1.979 0.0503 *
R. Casarin (Universitá Ca’ Foscari) Introduction to Econometrics Practical exercise with GRETL 9th October 2012 12 / 18
Residual analysis - Autocorrelation (3)
Unadjusted R-squared = 0.148758
Test statistic: LMF = 1.957244, with p-value = P(F(10,112) > 1.95724) =
0.0447
Alternative statistic: TR2 = 19.338531, with p-value = P(Chi-square(10) >
19.3385) = 0.0362 then there is autocorrelation. Moreover looking at the
significance of the coefficient in the above auxiliary regression, we find the
sixth lag coefficient is significant. Thus we should specify a dynamic
model, which accounts for the autocorrelation up to the sixth lag.
Ljung-Box Q = 24.6763, with p-value = P(Chi-square(10) > 24.6763) = 0.00599
R. Casarin (Universitá Ca’ Foscari) Introduction to Econometrics Practical exercise with GRETL 9th October 2012 13 / 18
Specify the dynamic model (1)
We would like to estimate the following model
X
J X
J
i .i .d.
yt = β0 + (β1j x1t−j + . . . + β7 x7t−j ) + γj yt−j εt , εt ∼ N (0, σ 2 ) (2)
j=0 j=1
In the dynamic model we need lagged dependent variable yt−j and lagged
independent variables xkt−j with j = 1, . . . , J.
The number of lags J is decided on the basis of the output of the autocorrelation
test
To generate the lagged variables use add>lags of selected variables or the the
option lags in the model>OLS window
R. Casarin (Universitá Ca’ Foscari) Introduction to Econometrics Practical exercise with GRETL 9th October 2012 14 / 18
Specify the dynamic model (2)
Example
Model 4: OLS, using observations 7–130 (T = 124)
Dependent variable: y
Coefficient Std. Error t-ratio p-value
const 34.5910 9.02121 3.8344 0.0003
x1 0.258108 0.272401 0.9475 0.3467
x1 1 −0.365666 0.301271 −1.2137 0.2290
x1 2 −0.274437 0.334169 −0.8212 0.4144
x1 3 0.206668 0.323942 0.6380 0.5256
x1 4 −0.504000 0.326513 −1.5436 0.1273
x1 5 0.163061 0.300759 0.5422 0.5895
x1 6 −0.299122 0.278917 −1.0724 0.2873
x2 1.22612 0.198373 6.1809 0.0000
x2 1 1.45437 0.249149 5.8374 0.0000
x2 2 −0.173879 0.318715 −0.5456 0.5872
x2 3 0.398436 0.276458 1.4412 0.1541
x2 4 0.149779 0.214955 0.6968 0.4883
x2 5 −0.0542050 0.204112 −0.2656 0.7914
x2 6 0.492662 0.195945 2.5143 0.0143
R. Casarin (Universitá Ca’ Foscari) Introduction to Econometrics Practical exercise with GRETL 9th October 2012 15 / 18
Specify the dynamic model (3)
Example
Coefficient Std. Error t-ratio p-value
x3 0.0202485 0.0233417 0.8675 0.3887
x3 1 −0.0160390 0.0227990 −0.7035 0.4841
x3 2 −0.0140241 0.0229348 −0.6115 0.5429
x3 3 −0.00761045 0.0231687 −0.3285 0.7436
x3 4 0.0165150 0.0253497 0.6515 0.5169
x3 5 0.00327501 0.0259259 0.1263 0.8998
x3 6 −0.00884341 0.0245963 −0.3595 0.7203
x4 0.00655567 0.0525373 0.1248 0.9011
x4 1 3.47326 0.0543391 63.9183 0.0000
x4 2 0.0701182 0.407798 0.1719 0.8640
x4 3 −0.657900 0.409221 −1.6077 0.1125
x4 4 −3.14153 0.0835012 −37.6225 0.0000
x4 5 −0.121407 0.377708 −0.3214 0.7489
x4 6 0.519575 0.370678 1.4017 0.1656
x5 0.0215762 0.0242322 0.8904 0.3764
x5 1 0.000675707 0.0281032 0.0240 0.9809
x5 2 −0.0434537 0.0274630 −1.5823 0.1182
x5 3 0.0279119 0.0283444 0.9847 0.3282
R. Casarin (Universitá Ca’ Foscari) Introduction to Econometrics Practical exercise with GRETL 9th October 2012 16 / 18
Specify the dynamic model (4)
Example
Coefficient Std. Error t-ratio p-value
x5 4 −0.0108096 0.0290899 −0.3716 0.7114
x5 5 0.00319353 0.0279492 0.1143 0.9094
x5 6 −0.0343586 0.0258165 −1.3309 0.1877
x6 0.0671131 0.0270379 2.4822 0.0155
x6 1 −4.47490 0.0257464 −173.8072 0.0000
x6 2 3.85153 0.519494 7.4140 0.0000
x6 3 1.35983 0.660633 2.0584 0.0434
x6 4 −0.695081 0.480264 −1.4473 0.1524
x6 5 −0.0963407 0.123815 −0.7781 0.4392
x6 6 0.0499940 0.0910266 0.5492 0.5847
x7 −0.00348536 0.0148676 −0.2344 0.8154
x7 1 −0.0112214 0.0186846 −0.6006 0.5501
x7 2 −0.0180657 0.0188160 −0.9601 0.3404
x7 3 −0.00785180 0.0187253 −0.4193 0.6763
x7 4 −0.0108345 0.0192826 −0.5619 0.5760
x7 5 −0.0135068 0.0192621 −0.7012 0.4856
x7 6 −0.0163645 0.0149922 −1.0915 0.2789
R. Casarin (Universitá Ca’ Foscari) Introduction to Econometrics Practical exercise with GRETL 9th October 2012 17 / 18
Specify the dynamic model (5)
Example
Coefficient Std. Error t-ratio p-value
y 1 0.466036 0.116059 4.0155 0.0002
y 2 0.201615 0.124174 1.6236 0.1091
y 3 −0.0885498 0.0610946 −1.4494 0.1518
y 4 0.00136484 0.0194745 0.0701 0.9443
y 5 0.0113215 0.0129956 0.8712 0.3867
y 6 0.000357190 0.00448029 0.0797 0.9367
Mean dependent var 143.9292 S.D. dependent var 56.94721
Sum squared resid 240.8233 S.E. of regression 1.881893
R2 0.999396 Adjusted R 2 0.998908
F (55, 68) 2046.612 P-value(F ) 3.67e–93
Log-likelihood −217.1029 Akaike criterion 546.2057
Schwarz criterion 704.1415 Hannan–Quinn 610.3629
ρ̂ 0.021946 Durbin–Watson 1.951320
R. Casarin (Universitá Ca’ Foscari) Introduction to Econometrics Practical exercise with GRETL 9th October 2012 18 / 18
Specify the dynamic model (6)
In order to complete the analysis you need:
1 to run the normality, heteroskedasticity and autocorrelation test on the
residuals.
2 to comment the significance of the regression with a F test
3 to select the regressors which are significant at a given level and find the best
model with a model selection criteria such as the adjusted-R 2 .
R. Casarin (Universitá Ca’ Foscari) Introduction to Econometrics Practical exercise with GRETL 9th October 2012 19 / 18