...

Gretl Lab2 - Ca` Foscari

by user

on
Category: Documents
29

views

Report

Comments

Transcript

Gretl Lab2 - Ca` Foscari
Introduction to Econometrics - (Gretl Lab 2)
Roberto Casarin
Ca’ Foscari Summer School
Venice, July 11, 2012
Roberto Casarin
Introduction to Econometrics - (Gretl Lab 2)
Introduzione
Analisi dei residui
Abbiamo discusso delle assunzioni alla base del modello di
regressione e delle proprietà di cui godono gli stimatori OLS sotto
queste assunzioni. In questa lezione vediamo come verificare che le
ipotesi sui termini di errore siano rispettate nel campione di dati in
esame.
◮
Normalità dei residui (test JB)
◮
Eteroschedasticità (Goldfeld-Quandt, Breusch-Pagan, White,
ARCH-LM)
◮
Autocorrelazione (Breusch-Godfrey, Durbin-Watson,
Box-Pierce, Lijung-Box)
◮
Corretta specificazione (AIC, BIC, RESET)
◮
Stabilità del modello (Chow, CUSUM)
Capitoli 6 ed 8.
Roberto Casarin
Introduction to Econometrics - (Gretl Lab 2)
Eteroschedasticità
Eteroschedasticità
Roberto Casarin
Introduction to Econometrics - (Gretl Lab 2)
Eteroschedasticità
Motivazioni
• Quando è presente eteroschedasticità nelle serie gli stimatori ML
e FWLS sono più efficienti rispetto allo stimatore OLS. Ma si
perde efficienza se applichiamo ML e FWLS quando in realtà la
serie è omoschedastica.
• Vediamo quindi alcuni test diagnostici per verficare l’ipotesi di
omoschedasticità: Goldfeld-Quandt, ARCH, Breusch-Pagan e
White.
Roberto Casarin
Introduction to Econometrics - (Gretl Lab 2)
Eteroschedasticità-GQ
Goldfeld-Quandt test
Richiede che i dati siano ordinati in modo che la varianza dei
termini di errore sia non descrescente. L’ipotesi nulla è varianza
costante per tutte le osservazioni contro l’alternativa che la
varianza cresca. Per verificare questa ipotesi il campione ordinato è
diviso in tree gruppi. Il primo costitutito dalla prime T1
osservazioni ha varianza σ12 il secondo costituito dalle ultime T2
osservazioni ha varianza σ22 ed il sottocampione rimanente di
dimensione T3 = T − T1 − T2 escluso dall’analisi.
H0 : σ22 = σ12
(1)
σ22
(2)
H0 :
Roberto Casarin
>
σ12
Introduction to Econometrics - (Gretl Lab 2)
Eteroschedasticità-GQ
Siano RSS1 ed RSS2 la somma del quadrato dei residui della
regressione OLS rispettivamente nel primo e nel secondo
sottocampione e s12 = RSS1 /(T1 − k) ed s22 = RSS2 /(T2 − k) le
corrispondenti varianze. Allora la seguente statistica test
F =
s22 /σ22
RSS2 /((T2 − k)σ22 )
=
RSS1 /((T1 − k)σ12 )
s12 /σ12
(3)
sotto l’ipotesi nulla H0 (e sotto le ipotesi OLS) diventa F = s22 /s12
e si distribuisce come una FT2 −k,T1 −k . L’ipotesi nulla è rifiutata in
favore dell’alternativa per valori elevati di F. Non esiste una regola
generale per la scelta del numero di osservazioni T3 da escludere,
ma osserviamo che se il cambiamento di varianza è in
corrispondenza di una punto di rottura strutturale allora è ottimale
scegliere due sottocampioni e quindi T3 = 0. Se c’e’ una variazione
non improvvisa si esclude generalmente T3 = n/5 per campioni
piccoli e T3 = n/3 per campioni grandi.
Roberto Casarin
Introduction to Econometrics - (Gretl Lab 2)
Eteroschedasticità-LR
Likelihood-ratio test
Alcune volte i dati possono essere separati in più gruppi dove la
varianza è assunta costante nei gruppi e diversa tra gruppi distinti.
Se ci sono G gruppi con varianza σj2 , e numerosità campionaria nj ,
con j = 1, . . . , G , sotto l’ipotesi nulla
H0 : σ12 = σ22 = . . . = σG2
(4)
con alternativa che la statistica test
LR = T
2
)
log(sML
−
G
X
2
)
Tj log(sj,ML
(5)
j=1
2 = u′ u/n
si distribuisce asintoticamente come χ2 (G − 1), dove sML
2
è la varianza stimata su tutto il campione di dati e sj,ML = u′j uj /nj
è la varianza stimata sul gruppo j-esimo.
Roberto Casarin
Introduction to Econometrics - (Gretl Lab 2)
Eteroschedasticità-BP
Breusch-Pagan (LM) test
Il test Breusch-Pagan è basato su un modello di eteroschedasticità
del tipo σt2 = h(z′t γ) con zt = (1, z2t , . . . , zpt )′ set di variabili che
spiegano le differenze di varianza tra le osservazioni. L’ipotesi nulla
di varianza costante corrisponde a p − 1 restrizioni sui parametri, il
test corrisponde al test LM
−1 ′ ∂L
∂L
∂L
−E
(6)
LM =
′
∂θ
∂θ∂θ
∂θ
con θ = (β, γ ′ )′ e
T
T
t=1
t=1
1 X (yt − x′t β)2
1X
n
log(h(z′t γ))−
(7)
L(β, γ) = − log(2π)−
2
2
2
h(z′t γ)
(Nota 1: legame con ML, WLS e 2SFWLS o FWLS iterati. Nota
2: modelli moltiplicativi e additivi per σt2 ).
Roberto Casarin
Introduction to Econometrics - (Gretl Lab 2)
Eteroschedasticità-BP
Per valutare il test dovremmo calcolare il gradiente e l’Hessiano
della verosimiglianza del modello senza vincoli e poi valutare la
statistica LM in corrispondenza dei parametri stimati sotto l’ipotesi
nulla. Si può dimostrare che questo equivale alla seguente
costruzione del test
1 : stima OLS: y = X β + u e calcolo dei residui û = y − X β̂
2 : Regressione ausiliaria: ût2 = γ0 + γ1 z2t + . . . + γp−1 zpt + et
e calcolo di R 2
3 : LM = TR 2 . LM è distribuito asintoticamente come una
χ2 (p − 1) sotto l’ipotesi nulla di omoschedasticità
Roberto Casarin
Introduction to Econometrics - (Gretl Lab 2)
Eteroschedasticità-W
White test
Il vantaggio del test Breusch-Pagan è che la funzione h sulla forma
funzionale della varianza può essere non specificata. Comunque è
necessario conoscere quali sono le variabili zt che influenzano la
varianza. Se le variabili sono non note allora si possono utilizzare le
2 , . . . , x 2 , in tal caso
variabili esplicative: x2t , . . . , xkt e x2t
kt
p = 2k − 2. Il test LM con questa particolare scelta delle variabili
esplicative è detto test di White (senza ”cross term”). Una
estensione è il test di White con termini incrociati: xjt xis con j 6= i .
Roberto Casarin
Introduction to Econometrics - (Gretl Lab 2)
Eteroschedasticità-ARCH
Test ARCH LM
Anche il test ARCH è un test LM che è fondato su una struttura di
eteroschedasticità del tipo ARCH(q) (Autoregressive Conditional
2
2 .
+ . . . + γq ut−q
Heteroschedasticity di ordine q): σt2 = γ0 + γ1 ut−1
Il test LM si costruisce con i seguenti passi
1 : stima OLS: y = X β + u e calcolo dei residui û = y − X β̂
2
2
2 : Regressione ausiliaria: ût2 = γ0 + γ1 ût−1
+ . . . + γq ût−q
+ et
2
e calcolo di R
3 : LM = TR 2 . LM è distribuito asintoticamente come una
χ2 (q) sotto l’ipotesi nulla di omoschedasticità
Roberto Casarin
Introduction to Econometrics - (Gretl Lab 2)
Eteroschedasticità - Esempio 1
Esempio 1
Consideriamo dati cross section sul salario dei dipendenti di 474
banche. Ci sono tre categorie di lavoratori: custodi, manager e
amministrativi. Consideriamo il seguente modello di regressione
yi = β1 + β2 x2i + β3 x3i + β4 x4i + β5 D2i + β6 D3i + ui
yi : log of the salary
x2i : education
x3i : gender (dummy, 1 se maschio, 0 femmina)
x4i : minority (dummy, 1 se minoranza e 0 altrimenti)
D2i : dummy (1 lavoro come custode, 0 altrimenti)
D3i : dummy (1 lavoro come manager, 0 altrimenti)
con i = 1, . . . , n.
Roberto Casarin
Introduction to Econometrics - (Gretl Lab 2)
(8)
Eteroschedasticità - Esempio 1
Model 1: OLS, using observations 1–474
Dependent variable: LOGSALARY
const
EDUC
GENDER
MINORITY
DUMJCAT2
DUMJCAT3
Coefficient
Std. Error
t-ratio
p-value
9.57469
0.0441917
0.178340
−0.0748581
0.170360
0.539075
0.0542179
0.00428498
0.0209623
0.0224588
0.0434936
0.0302130
176.5965
10.3132
8.5077
−3.3331
3.9169
17.8425
0.0000
0.0000
0.0000
0.0009
0.0001
0.0000
Mean dependent var
Sum squared resid
R2
F (5, 468)
Log-likelihood
Schwarz criterion
10.35679
17.86407
0.760775
297.6627
104.4077
−171.8481
Roberto Casarin
S.D. dependent var
S.E. of regression
Adjusted R 2
P-value(F )
Akaike criterion
Hannan–Quinn
0.397334
0.195374
0.758219
7.9e–143
−196.8154
−186.9961
Introduction to Econometrics - (Gretl Lab 2)
Eteroschedasticità - Esempio 1
LOGSALARY versus JOBCAT (with least squares fit)
12
Y = 9.80 + 0.398X
LOGSALARY
11.5
11
10.5
10
9.5
1
1.5
Roberto Casarin
2
JOBCAT
2.5
Introduction to Econometrics - (Gretl Lab 2)
3
Eteroschedasticità - Esempio 1
1
0.8
0.6
resid
0.4
0.2
0
-0.2
-0.4
-0.6
1
1.5
Roberto Casarin
2
JOBCAT
2.5
Introduction to Econometrics - (Gretl Lab 2)
3
Eteroschedasticità - Esempio 1
Test Goldfeld-Quandt
• Dallo scatter plot dei residui contro la variabile di comodo
JOBCAT osserviamo che la varianza dei residui varia a seconda
della categoria. Osserviamo che i tre sottocampioni sono: 363
JOBCAT=1, 27 JOBCAT=2 e 84 JOBCAT=3. Ora consideriamo
tre modelli di regressione distinti per i tre sottocampioni.
Ovviamente esclusiamo le due varibili dummy D2i e D3i . Per il
sottocampione in cui JOBCAT=2 escludiamo GENDER dato che
nel sottocampione ci sono solo maschi. Osserviamo dai seguenti
risultati che la seconda regressione non è significativa (test F),
probabilmente anche a causa dei pochi dati.
• Quindi escludiamo il secondo sottocampione e testiamo l’ipotesi
che σ12 = σ22 contro l’alternativa σ22 > σ12 utilizzando la satistica
F = (s22 /s12 ) = (0.227476/0.188190)2 = 1.457 che ha distribuzione
F84−4,363−4 . Il p-value è pari a 0.011186 quindi rifiutiamo l’ipotesi
nulla.
Roberto Casarin
Introduction to Econometrics - (Gretl Lab 2)
Eteroschedasticità - Esempio 1
Test Goldfeld-Quandt
◮
Utilizziamo Sample>Restrict, based on criterion...
per determinare i diversi sottocampioni
◮
Utilizziamo Tools>p-value finder>F... per trovare il
p-value associato al valore della statistica test
Roberto Casarin
Introduction to Econometrics - (Gretl Lab 2)
Eteroschedasticità - Esempio 1
Model 3: OLS, using observations 1–363
Dependent variable: LOGSALARY
const
EDUC
GENDER
MINORITY
Coefficient
Std. Error
t-ratio
p-value
9.55642
0.0463597
0.169221
−0.0985574
0.0565441
0.00449408
0.0212746
0.0233131
169.0083
10.3157
7.9541
−4.2276
0.0000
0.0000
0.0000
0.0000
Mean dependent var
Sum squared resid
R2
F (3, 359)
Log-likelihood
Schwarz criterion
10.20254
12.71420
0.418977
86.29199
93.25585
−162.9341
Roberto Casarin
S.D. dependent var
S.E. of regression
Adjusted R 2
P-value(F )
Akaike criterion
Hannan–Quinn
0.245863
0.188190
0.414122
4.63e–42
−178.5117
−172.3197
Introduction to Econometrics - (Gretl Lab 2)
Eteroschedasticità - Esempio 1
Model 4: OLS, using observations 1–27
Dependent variable: LOGSALARY
const
EDUC
MINORITY
Coefficient
Std. Error
t-ratio
p-value
10.3939
−0.00463417
−0.0191656
0.0677387
0.00631878
0.0275429
153.4409
−0.7334
−0.6958
0.0000
0.4704
0.4932
Mean dependent var
Sum squared resid
R2
F (2, 24)
Log-likelihood
Schwarz criterion
10.33745
0.122445
0.039055
0.487710
34.53372
−59.17994
Roberto Casarin
S.D. dependent var
S.E. of regression
Adjusted R 2
P-value(F )
Akaike criterion
Hannan–Quinn
0.070006
0.071427
-0.041024
0.619985
−63.06745
−61.91149
Introduction to Econometrics - (Gretl Lab 2)
Eteroschedasticità - Esempio 1
Model 5: OLS, using observations 1–84
Dependent variable: LOGSALARY
const
EDUC
GENDER
MINORITY
Coefficient
Std. Error
t-ratio
p-value
9.67598
0.0669673
0.211185
0.260611
0.274004
0.0165246
0.0807968
0.119540
35.3133
4.0526
2.6138
2.1801
0.0000
0.0001
0.0107
0.0322
Mean dependent var
Sum squared resid
R2
F (3, 80)
Log-likelihood
Schwarz criterion
11.02962
4.139612
0.308942
11.92153
7.238179
3.246909
Roberto Casarin
S.D. dependent var
S.E. of regression
Adjusted R 2
P-value(F )
Akaike criterion
Hannan–Quinn
0.268648
0.227476
0.283028
1.56e–06
−6.476359
−2.567687
Introduction to Econometrics - (Gretl Lab 2)
Eteroschedasticità - Esempio 1
Model 9: OLS, using observations 1–474
Dependent variable: sq resid
const
DUMJCAT2
DUMJCAT3
Coefficient
Std. Error
t-ratio
p-value
0.0351658
−0.0182647
0.0201025
0.00342653
0.0130228
0.00790440
10.2628
−1.4025
2.5432
0.0000
0.1614
0.0113
Mean dependent var
Sum squared resid
R2
F (2, 471)
Log-likelihood
Schwarz criterion
0.037688
2.007417
0.019507
4.685268
622.4761
−1226.469
Roberto Casarin
S.D. dependent var
S.E. of regression
Adjusted R 2
P-value(F )
Akaike criterion
Hannan–Quinn
0.065791
0.065284
0.015343
0.009665
−1238.952
−1234.043
Introduction to Econometrics - (Gretl Lab 2)
Eteroschedasticità - Esempio 1
Breusch-Pagan
Vogliamo verificare la seguente struttura di eteroschedasticità
(modello moltiplicativo): σi2 = e γ0 +γ1 D2i +γ2 D3i . Il primo passo della
procedura consiste nel regredire il guadrato dei residui (attenzione
non il logaritmo del quadrato!) sulle due varibili dummy ottenendo
R 2 = 0.021333 (vedi figura pagina precedente). Da cui
LM = 474 · 0.021333 = 10.111 che sotto l’ipotesi nulla
γ1 = γ2 = 0 ha distribuzione χ2 (3 − 1). Il p-value è pari a 0.006.
Quindi rifiutiamo l’ipotesi nulla.
Roberto Casarin
Introduction to Econometrics - (Gretl Lab 2)
Eteroschedasticità - Esempio 1
Test LR
Dividendo il campione in tre gruppi in funzione del valore dalla
variabile JOBCAT otteniamo per i tre sottocampioni:
s12 = 0.1881902 , s22 = 0.0714272 e s32 = 0.2274762 . Da cui
2
= 0.1881902 · 363−4
otteniamo s1,ML
363 = 0.0350,
27−3
2
2
s2,ML = 0.071427 27 = 0.0045 e
2
s3,ML
= 0.2274762 84−4
84 = 0.0493. Osserviamo inoltre che
2
2
2 = 0.1953742 · 474−6 = 0.0377. La
s1 = 0.195374 e quindi sML
474
statistica test: LR = 474 log(0.0377) − 363 log(0.0350) −
27 log(0.0045) − 84 log(0.0493) = 61.2, sotto l’ipotesi nulla, ha
distribuzione asintotica χ2 (3 − 1). Il p-value è pari a 0. Quindi
l’ipotesi di omoschedasticità è rifiutata.
Roberto Casarin
Introduction to Econometrics - (Gretl Lab 2)
Eteroschedasticità - Esempio 1
White
Il test di White senza cross-products e con cross-products porta a
rifiutare l’ipotesi nulla di omoschedasticità con p-values pari a
0.041678 e 0.011285 rispettivamente (vedi figure seguenti).
Roberto Casarin
Introduction to Econometrics - (Gretl Lab 2)
Eteroschedasticità - Esempio 1
Dependent variable: uhat 2
Coefficient
Std. Error
t-ratio
p-value
const
0.0169722
0.0534069
0.3178
0.7508
EDUC
0.000632237 0.00835041
0.07571 0.9397
GENDER
-0.00104331 0.00704285
-0.1481 0.8823
MINORITY -0.00674886 0.00750964
-0.8987 0.3693
DUMJCAT2 -0.00991070 0.0145921
-0.6792 0.4974
DUMJCAT3 0.00734671
0.0116268
0.6319
0.5278
sqEDUC
7.09153e-05 0.000326738 0.2170
0.8283
Unadjusted R-squared = 0.027609 Test statistic: TR 2 =
13.086833, with p-value = P(Chi − square(6) > 13.086833) =
0.041678
Roberto Casarin
Introduction to Econometrics - (Gretl Lab 2)
Eteroschedasticità - Esempio 1
Dependent variable: uhat 2 Omitted due to exact collinearity: X 3 − X 5
Coefficient
Std. Error
t-ratio p-value
const
0.131454
0.0718267
1.830
0.0679
EDUC
-0.0188857
0.0118901
-1.588
0.1129
GENDER
-0.0374905
0.0448115
-0.8366 0.4032
MINORITY 0.0215931
0.0448275
0.4817
0.6303
DUMJCAT2 -0.0627389
0.0746543
-0.8404 0.4011
DUMJCAT3 0.273542
0.109895
2.489
0.0132
sqEDUC
0.000884387 0.000491919 1.798
0.0729
X2 − X3
0.00248857
0.00333562
0.7461
0.4560
X2 − X4
-0.00253195 0.00348105
-0.7274 0.4674
X2 − X5
0.00482944
0.00665341
0.7259
0.4683
X2 − X6
-0.0183418
0.00695796
-2.636
0.0087
X3 − X4
-0.00282086 0.0166238
-0.1697 0.8653
X3 − X6
0.0215932
0.0262545
0.8225
0.4112
X4 − X5
0.0224349
0.0298916
0.7505
0.4533
X4 − X6
0.0812140
0.0370309
2.193
0.0288
Unadjusted R-squared = 0.060660 Test statistic: TR 2 = 28.752679, with
p-value = P(Chi − square(14) > 28.752679) = 0.011285
Roberto Casarin
Introduction to Econometrics - (Gretl Lab 2)
Eteroschedasticità - Esempio 2
Esempio 2
Sia yt il tasso di rendimento delle obbligazioni con rating AAA e
sia xt il tasso di rendimento dei titoli di stato (Treasury Bill) a
3-mesi, rilevati mensilemente tra gennaio 1950 e dicembre 1999.
Vogliamo stimare
∆yt = α + β∆xt + ut
(9)
Roberto Casarin
Introduction to Econometrics - (Gretl Lab 2)
Eteroschedasticità - Esempio 2
Model 1: OLS, using observations 1948:02–1999:12 (T = 623)
Dependent variable: DAAA
const
DUS3MT
Coefficient
Std. Error
t-ratio
p-value
0.00565089
0.274529
0.00672904
0.0143765
0.8398
19.0957
0.4014
0.0000
Mean dependent var
Sum squared resid
R2
F (1, 621)
Log-likelihood
Schwarz criterion
ρ̂
0.007528
17.51432
0.369957
364.6465
228.5322
−444.1953
0.276686
Roberto Casarin
S.D. dependent var
S.E. of regression
Adjusted R 2
P-value(F )
Akaike criterion
Hannan–Quinn
Durbin–Watson
0.211405
0.167939
0.368942
2.66e–64
−453.0644
−449.6177
1.446100
Introduction to Econometrics - (Gretl Lab 2)
Eteroschedasticità - Esempio 2
Regression residuals (= observed - fitted DAAA)
1.2
1
0.8
residual
0.6
0.4
0.2
0
-0.2
-0.4
-0.6
-0.8
1950
1960
1970
Roberto Casarin
1980
1990
2000
Introduction to Econometrics - (Gretl Lab 2)
Eteroschedasticità - Esempio 2
1.2
1
usq1
0.8
0.6
0.4
0.2
0
1950
1960
1970
Roberto Casarin
1980
1990
2000
Introduction to Econometrics - (Gretl Lab 2)
Eteroschedasticità - Esempio 2
DUS3MT versus DAAA (with least squares fit), sub-sample: 1948:01-1974:12
1
Y = -0.00294 + 1.19X
DUS3MT
0.5
0
-0.5
-1
-1.5
-0.4
-0.3
-0.2
-0.1
Roberto Casarin
0
DAAA
0.1
0.2
0.3
Introduction to Econometrics - (Gretl Lab 2)
Eteroschedasticità - Esempio 2
DUS3MT versus DAAA (with least squares fit), sub-sample 1975:01-1999:12
3
Y = -0.000394 + 1.37X
2
DUS3MT
1
0
-1
-2
-3
-4
-5
-1
-0.5
Roberto Casarin
0
DAAA
0.5
1
Introduction to Econometrics - (Gretl Lab 2)
Eteroschedasticità - Esempio 2
Vogliamo verificare l’ipotesi di omoschedasticità, utilizzando i
seguenti modelli di eteroschedasticità
i σt2 = σ 2 (∆xt )2
(White)
ii σt2 = γ1 + γ2 ut2
(ARCH LM)
iii σt2 = γ1 + γ2 ∆xt
(Breusch-Pagan LM)
iv σt2 = γ1 + γ2 Dt , (Dt = 1 se t > 1974 : 12)
(Breusch-Pagan LM)
Roberto Casarin
Introduction to Econometrics - (Gretl Lab 2)
Eteroschedasticità - Esempio 2
White’s test for heteroskedasticity OLS, using observations
1948:02-1999:12 (T = 623)
Dependent variable: uhat 2
Coefficient
Std. Error
t-ratio
p-value
const
0.0266391
0.00313198 8.506
1.36e-016
DUS3MT -7.22712e-05 0.00695667 -0.01039 0.9917
sqDUS3MT 0.00672943
0.00275691 2.441
0.0149
Unadjusted R-squared = 0.010725
Test statistic: TR 2 = 6.681598,
with p-value = P(Chi − square(2) > 6.681598) = 0.035409
Roberto Casarin
Introduction to Econometrics - (Gretl Lab 2)
Eteroschedasticità - Esempio 2
Test for ARCH of order 2
Coefficient Std. Error
t-ratio
alpha(0) 0.0171892 0.00325323 5.284
alpha(1) 0.166183
0.0391886
4.241
alpha(2) 0.225508
0.0391904
5.754
Null hypothesis: no ARCH effect is present
Test statistic: LM = 58.742
with p-value = P(Chi − square(2) > 58.742) =
Roberto Casarin
p-value
1.76e-07
2.57e-05
1.37e-08
1.75523e-013
Introduction to Econometrics - (Gretl Lab 2)
Eteroschedasticità - Esempio 2
Breusch-Pagan test for heteroskedasticity OLS, using observations
1948:02-1999:12 (T = 623)
Dependent variable: scaled uhat 2
Coefficient Std. Error t-ratio
p-value
const
1.00139
0.109639 9.134
9.25e-019
DUS3MT -0.203847 0.234242 -0.8702 0.3845
Explained sum of squares = 5.67032
Test statistic: LM = 2.835158,
with p-value = P(Chi − square(1) > 2.835158) = 0.092222
Roberto Casarin
Introduction to Econometrics - (Gretl Lab 2)
Eteroschedasticità - Esempio 2
Breusch-Pagan test for heteroskedasticity
Model 2: OLS, using observations 1948:02–1999:12 (T = 623)
Dependent variable: usq1a
const
du74
Coefficient
Std. Error
t-ratio
p-value
0.00912376
0.0394340
0.00413967
0.00596553
2.2040
6.6103
0.0279
0.0000
Mean dependent var
Sum squared resid
R2
F (1, 621)
Log-likelihood
Schwarz criterion
ρ̂
0.028113
3.437360
0.065739
43.69633
735.7523
−1458.636
0.159407
Roberto Casarin
S.D. dependent var
S.E. of regression
Adjusted R 2
P-value(F )
Akaike criterion
Hannan–Quinn
Durbin–Watson
0.076910
0.074399
0.064234
8.27e–11
−1467.505
−1464.058
1.681000
Introduction to Econometrics - (Gretl Lab 2)
Eteroschedasticità - Esempio 2
• Il test White, ARCH-LM e Breusch-Pagan (iii) portanto a
rigettare l’ipotesi nulla di omoschedasticità (vedi p-value). Per il
test di Breusch-Pagan (iv) osserviamo che
LM = nR 2 = 623 · 0.065739 = 40.95539 che sotto l’ipotesi nulla si
distribuisce come una χ2 (1). Il p-value è pari a 0. Quindi
rigettiamo l’ipotesi nulla di omoschedasticità.
• Confrontiamo ora gli effetti dei tre modelli di eteroschedasticità
sui residui e vediamo come utilizzare uno dei modelli di
eteroschedasticità per ottenere una stima 2SFWLS.
Roberto Casarin
Introduction to Econometrics - (Gretl Lab 2)
Eteroschedasticità - Esempio 2
Esempio: regimi di volatilità (variabile dummy) e stima
2SFWLS
◮
stima OLS ∆yt = α + β∆xt + ut
◮
generiamo la serie σt2 = ût2 (denominata usq1)
◮
◮
costruiamo il modello di regressione ausiliario:
σt2 = γ1 + γ2 Dt + εt , (Add>time trend e poi Add>define
new variable> du80=time>380)
determiniamo i fitted σ̂t2 e li salviamo con nome yhat8
◮
Definiamo i pesi 1/σ̂t
Add>define new variable> sigmainv=1/sqrt(yhat8)
◮
stima WLS con pesi 1/σ̂t
Models>Other Linear Models>Weighted Least
Squares...
Roberto Casarin
Introduction to Econometrics - (Gretl Lab 2)
Eteroschedasticità - Esempio 2
Model 8: OLS, using observations 1948:02–1999:12 (T = 623)
Dependent variable: usq1
const
du80
Coefficient
Std. Error
t-ratio
p-value
0.00989738
0.0472844
0.00375262
0.00604607
2.6375
7.8207
0.0086
0.0000
Mean dependent var
Sum squared resid
R2
F (1, 621)
Log-likelihood
Schwarz criterion
ρ̂
0.028113
3.349347
0.089660
61.16299
743.8321
−1474.795
0.138765
Roberto Casarin
S.D. dependent var
S.E. of regression
Adjusted R 2
P-value(F )
Akaike criterion
Hannan–Quinn
Durbin–Watson
0.076910
0.073440
0.088194
2.26e–14
−1483.664
−1480.217
1.722141
Introduction to Econometrics - (Gretl Lab 2)
Eteroschedasticità - Esempio 2
Actual and fitted usq1
1.2
fitted
actual
1
usq1
0.8
0.6
0.4
0.2
0
1950
1960
1970
Roberto Casarin
1980
1990
2000
Introduction to Econometrics - (Gretl Lab 2)
Eteroschedasticità - Esempio 2
Model 9: WLS, using observations 1948:02–1999:12 (T = 623)
Dependent variable: DAAA
Variable used as weight: sigmainv
const
DUS3MT
Coefficient
Std. Error
t-ratio
p-value
0.00931597
0.248917
0.00561751
0.0140703
1.6584
17.6910
0.0977
0.0000
Statistics based on the weighted data:
Sum squared resid
R2
F (1, 621)
Log-likelihood
Schwarz criterion
ρ̂
94.93639
0.335097
312.9709
−297.9615
608.7920
0.291173
S.E. of regression
Adjusted R 2
P-value(F )
Akaike criterion
Hannan–Quinn
Durbin–Watson
0.390994
0.334026
5.10e–57
599.9229
603.3697
1.417149
Statistics
based
original
data: - (Gretl Lab 2)
Roberto
Casarinon the
Introduction
to Econometrics
Eteroschedasticità - Esempio 2
Confronto: WLS è più efficiente di OLS quando gli errori sono
eteroschedastici. Si veda anche il p-value dell’intercetta.
WLS
const
DUS3MT
Coefficient
Std. Error
t-ratio
p-value
0.00931597
0.248917
0.00561751
0.0140703
1.6584
17.6910
0.0977
0.0000
OLS
const
DUS3MT
Coefficient
Std. Error
t-ratio
p-value
0.00565089
0.274529
0.00672904
0.0143765
0.8398
19.0957
0.4014
0.0000
Roberto Casarin
Introduction to Econometrics - (Gretl Lab 2)
Autocorrelazione
Autocorrelazione
Roberto Casarin
Introduction to Econometrics - (Gretl Lab 2)
Autocorrelazione
• Una delle assunzioni del modello di regressione è che i termini di
errore siano indipendenti. E’quindi necessario verificare che i
residui di una regressione siano indipendenti attraverso dei test
(Durbin-Watson, Bresusch-Godfrey, Box-Pierce e Ljiung-Box).
• In particolare diremo che i termini di disturbo del modello di
regressione
yt = x′t β + ut
(10)
sono serialmente correlati se esistono s 6= t tali che E(ut , us ) 6= 0.
In questo caso la matrice di varianza covarianze di u non è
diagonale. Questo significa che yt ed ys oltre ai regressori hanno in
comune altri elementi e che il modello di regressione dato sopra
con le ipotesi OLS viste a lezione non è soddisfacente.
Roberto Casarin
Introduction to Econometrics - (Gretl Lab 2)
Autocorrelazione
• Potrebbe trattarsi di problemi di omissione di variabili, non
corretta specificazione della forma funzionale, mancata inclusione
di variabili dipendenti (o indipedenti) ritardate.
• Primi a di presentare questi test vediamo se è possibile intuire
anche graficamente la presenza di correlazione seriale
(autocorrelazione) e che in alcuni casi è possibile dare un
interpretazione economica.
Roberto Casarin
Introduction to Econometrics - (Gretl Lab 2)
Autocorrelazione
Tassi di Interesse
• Consideriamo il dataset xm722ibr.wk1 relativo a tassi su
obbligazioni con rating AAA yt e dei tassi su obbligazioni
pubbliche (Treasury Bill a 3 mesi), xt . Consideriamo le differenze
prime di tali variabili: ∆xt e ∆yt .
• dal modello di regressione ∆yt = α + β∆xt + ut otteniamo i
residui ût . Il coefficiente di correlazione tra ût e ût−1 è pari a
0.276543. Dal diagramma di dispersione si può osservare la
presenza di una relazione lineare tra le due variabili.
• E’ ragionevole pensare che a seguito di una deviazione da una
relazione di equilibrio tra yt e xt l’aggiustamento di yt non sia
immediato, ma sia progressivo nel tempo. Per questo motivo una
relazione statica tra ∆yt e ∆xt può non essere adeguata con
conseguente evidenza di correlazione seriale nei residui.
Roberto Casarin
Introduction to Econometrics - (Gretl Lab 2)
Autocorrelazione
uhat versus uhat1 (with least squares fit)
1.2
Y = 9.65e-005 + 0.277X
1
0.8
0.6
uhat
0.4
0.2
0
-0.2
-0.4
-0.6
-0.8
-0.6
-0.4
-0.2
0
Roberto Casarin
0.2
uhat1
0.4
0.6
0.8
1
Introduction to Econometrics - (Gretl Lab 2)
Autocorrelazione
Coefficienti di autocorrelazione
Test sulla correlazione seriale richiedono che le osservazioni
possano essere naturalmente ordinate. Per series storiche l’ordine è
dato dall’indice temporale. Nei dati cross-section le osservazioni
possono essere ordinate in base ad una delle variabili esplicative.
L’indice di correlazione è
PT
ût ût−1
(11)
r = qP t=2 P
T −1 2
T
2
û
û
t=1 t
t=2 t
di cui si utilizza una versione asintoticamente equivalente
PT
t=2 ût ût−1
r1 = P
T
2
t=1 ût
(12)
Elevati valordi di r1 possono indicare errata specificazioine nella
dinamica per dati di tipo timeseries oppure errata forma funzionale
per dati cross-section.
Roberto Casarin
Introduction to Econometrics - (Gretl Lab 2)
Autocorrelazione
Si può costruire l’autocorrelogramma valutando per ogni ritardo
k con k = . . . , K il seguente coefficente di correlazione di ordine k
rk =
PT
t=k+1 ût ût−k
PT
2
t=1 ût
(13)
Il grafico generato da (k, rk ) può dare un’idea della presenza di
autocorrelazione
Roberto Casarin
Introduction to Econometrics - (Gretl Lab 2)
Autocorrelazione
Test Durbin-Watson Il test DW è basato sulla seguente idea.
Siano σ 2 e ̺ la varianza dei termini di disturbo ed la correlazione
tra ut e ut−1 allora E(ut − ut−1 )2 = 2σ 2 (1 − ̺). Cosı̀ se i due
termini di errore consecutivi sono correlati la differenza (ut − ut−1
tenderà ad essere piccola. La statistica DW è definita come segue
d=
T
P
(ut − ut−1 )2
t=2
T
P
t=1
(14)
ut2
La statistica soddisfa: 0 ≤ d ≤ 4 e d ≈ 2(1 − r1 ). Valori di d vicini
allo zero indicano autocorrelazione positiva mentre valori prossimi
a 4 indicano autocorrelazione negativa. I valori critici della
statistica test dipendono dalla matrice X di regressori. Le bande di
confidenza esistono per regressori deterministici e termini di errore
gaussiani. DW è utilizzata in modo informale come strumento di
diagnosi per indicare la presenza di autocorrelazione
Roberto Casarin
Introduction to Econometrics - (Gretl Lab 2)
Autocorrelazione
Test Breusch-Godfrey LM Il modello di riferimento è
yt = x′t β + ut
(15)
ut = γ1 ut−1 + . . . + γp ut−p + ηt
(16)
con ηt iid e gaussiano con varianza ση2 per ogni t. Considerando il
caso AR(1), cioè p = 1 segue che
yt = γ1 yt−1 + x′t β − γx′t−1 β + ηt
(17)
in cui si vuole valutare l’ipotesi che γ1 = 0. Si può dimostrare che
il test è equivalente alla seguente procedura a due passi in cui si
utilizza un modello di regressione ausiliario.
Roberto Casarin
Introduction to Econometrics - (Gretl Lab 2)
Autocorrelazione
◮
stima OLS y = X β + u
◮
generiamo i residui û = y − X β̂
◮
regressione ausiliaria (stima OLS):
ût = x′t δ + γ1 ût−1 + . . . + γp ût−p + ωt
◮
determinare LM = TR 2 che è distribuita asintoticamente
come χ2 (p) sotto l’ipotesi nulla di assenza di correlazione
seriale H0 = γ1 = . . . = γp = 0
Roberto Casarin
Introduction to Econometrics - (Gretl Lab 2)
Autocorrelazione
Tests Box-Pierce e Ljiung-Box Le statistiche test sono
BP = T
LB = T
p
X
k=1
p
X
k=1
rk2
(18)
T +2 2
r
T −k k
(19)
Sotto l’ipotesi nulla di assenza di autocorrelazione la statistica BP
ha distribuzione asintotica χ2 (p) mentre la statistica LB (detta
anche Q-test) ha distribuzione asintotica χ2 (p) (sotto l’ipotesi
aggiuntiva che i regressori siano deterministici, nel caso siano
stocastici è consigliabile utilizzare il test Breusch-Godfrey).
Roberto Casarin
Introduction to Econometrics - (Gretl Lab 2)
Autocorrelazione
Rimedi Possibili
• Per dati cross-section è necessario variare le forma funzionale.
• Per dati timeseries è necessario considerare le proprietà
dinamiche dei dati. Per esempio considerando
yt = β1 + β2 xt + ut
(20)
la correlazione tra ut = yt − β1 − β2 xt e
ut−1 = yt−1 − β1 − β2 xt−1 può essere dovuta al legame tra yt e
xt−1 e yt−1 che può essere considerata con il modello
yt = γ1 + γ2 xt + γ3 xt−1 + γ4 yt−1 + ηt
con ηt iid. (Si veda nota su modelli ADL).
Roberto Casarin
Introduction to Econometrics - (Gretl Lab 2)
(21)
Autocorrelazione
Rimedi Possibili
• Modello di regressione con errori AR(1).
ut = γut−1 + ηt
(22)
ut = yt − β1 − β2 xt
(23)
da cui segue
yt = β1 (1 − γ) + β2 xt − β2 γxt−1 + γyt−1 + ηt
(24)
che corrisponde a
yt = γ1 + γ2 xt + γ3 xt−1 + γ4 yt−1 + ηt
(25)
con γ1 = β1 (1 − γ), γ2 = β2 , γ3 = −β2 γ e γ4 = γ e con il vincolo
γ2 γ4 + γ3 = 0
Roberto Casarin
Introduction to Econometrics - (Gretl Lab 2)
(26)
Autocorrelazione
Rimedi Possibili
• Se i termini di errore ηt sono distribuiti normalmente è possibile
stimare i parametri γ e β1 e β2 utilizzando NLS (nonlinear least
square) altrimenti si può utilizzare una procedura a due passi
(procedura di Cochrane-Orcutt). Si osserva che:
yt − γyt−1 = β1 (1 − γ) + β2 (xt − γxt−1 ) + ηt
(27)
da cui:
◮
Consideriamo γ = 0 e stimiamo con OLS β1 e β2 :
yt = β1 + β2 xt + ut . Lo stimatore sarà consistente (se
−1 < γ < 1) ma non efficiente.
◮
Regrediamo ût su ût−1 ottenendo γ̂
◮
e yt − γ̂yt−1 su xt − γ̂xt−1 ottenendo dei nuovi residui η̃t .
Una nuova stima di γ può essere ottenuta utilizzando i nuovi
residui.
Roberto Casarin
Introduction to Econometrics - (Gretl Lab 2)
Autocorrelazione
Esempio
Consideriamo l’esempio sui tassi di interesse
• La statistica DW = 1.446 quindi r1 ≈ 0.277
• Il coefficiente di autocorrelazione del primo ordine è significativo
(Q-test)
• Il test Breusch-Godfrey con p = 1 e p = 2 ritardi indica la
presenza di autocorrelazione
Roberto Casarin
Introduction to Econometrics - (Gretl Lab 2)
Autocorrelazione
OLS, using observations 1948:02–1999:12 (T = 623)
Dependent variable: DAAA
const
DUS3MT
Coefficient
Std. Error
t-ratio
p-value
0.00565089
0.274529
0.00672904
0.0143765
0.8398
19.0957
0.4014
0.0000
Mean dependent var
Sum squared resid
R2
F (1, 621)
Log-likelihood
Schwarz criterion
ρ̂
0.007528
17.51432
0.369957
364.6465
228.5322
−444.1953
0.276686
Roberto Casarin
S.D. dependent var
S.E. of regression
Adjusted R 2
P-value(F )
Akaike criterion
Hannan–Quinn
Durbin–Watson
0.211405
0.167939
0.368942
2.66e–64
−453.0644
−449.6177
1.446100
Introduction to Econometrics - (Gretl Lab 2)
Autocorrelazione
Residual ACF
0.3
0.2
0.1
0
-0.1
-0.2
-0.3
+- 1.96/T0.5
0
2
4
6
8
10
12
lag
Residual PACF
0.3
0.2
0.1
0
-0.1
-0.2
-0.3
0
+- 1.96/T .5
0
2
4
6
8
10
12
lag
Roberto Casarin
Introduction to Econometrics - (Gretl Lab 2)
Autocorrelazione
Residual autocorrelation function
LAG
ACF
PACF
Q-stat
1
2
3
4
5
6
7
8
9
10
11
12
0.2764
-0.0754
0.0086
0.0337
0.0546
0.1012
0.0354
0.0499
0.0449
0.0079
0.0329
-0.0611
0.2764
-0.1643
0.0871
-0.0087
0.0606
0.0785
-0.0110
0.0705
0.0034
0.0011
0.0317
-0.1074
47.8159
51.3775
51.4240
52.1380
54.0139
60.4804
61.2716
62.8484
64.1241
64.1639
64.8526
67.2286
Roberto Casarin
[p-value]
[0.000]
[0.000]
[0.000]
[0.000]
[0.000]
[0.000]
[0.000]
[0.000]
[0.000]
[0.000]
[0.000]
[0.000]
Introduction to Econometrics - (Gretl Lab 2)
Autocorrelazione
Breusch-Godfrey test for autocorrelation up to order 12 OLS, using
observations 1948:02-1999:12 (T = 623) Dependent variable: uhat
Coefficient
Std. Error
t-ratio
p-value
const
0.000292938 0.00630670 0.04645 0.9630
DUS3MT -0.0279546
0.0143213
-1.952
0.0514
uhat1
0.358428
0.0414183
8.654
4.44e-017
uhat2
-0.214417
0.0428149
-5.008
7.21e-07
uhat3
0.0900817
0.0435623
2.068
0.0391
uhat4
-0.00895890 0.0438469
-0.2043 0.8382
uhat5
0.0232144
0.0438376
0.5296
0.5966
Unadjusted R-squared = 0.138853, Test statistic: LMF =
8.182996, with p-value = P(F (12, 609) > 8.183) = 2.24e-014
Alternative statistic: TR 2 = 86.505134, with p-value =
P(Chi − square(12) > 86.5051) = 2.34e-013
Ljung-Box Q’ = 67.2286, with p-value =
P(Chi − square(12) > 67.2286) = 1.05e-009
Roberto Casarin
Introduction to Econometrics - (Gretl Lab 2)
Autocorrelazione
Cochrane–Orcutt, using observations 1948:03–1999:12 (T = 622)
Dependent variable: DAAA
ρ = 0.289012
ρ̂ = 0.289012
const
DUS3MT
Coefficient
Std. Error
t-ratio
p-value
0.00594436
0.252253
0.00909245
0.0143429
0.6538
17.5873
0.5135
0.0000
Statistics based on the
Mean dependent var 0.007556
Sum squared resid
16.11453
2
R
0.420317
F (1, 620)
309.3128
ρ̂
0.050437
Roberto Casarin
rho-differenced data:
S.D. dependent var
S.E. of regression
Adjusted R 2
P-value(F )
Durbin–Watson
0.211574
0.161218
0.419382
1.80e–56
1.896534
Introduction to Econometrics - (Gretl Lab 2)
Fly UP