Introduction to Econometrics - (Gretl Lab 2) Roberto Casarin Ca Foscari Summer School Venice, July 11, 2012
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.
Eteroschedasticità Eteroschedasticità
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.
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 T 1 osservazioni ha varianza σ1 2 il secondo costituito dalle ultime T 2 osservazioni ha varianza σ2 2 ed il sottocampione rimanente di dimensione T 3 = T T 1 T 2 escluso dall analisi. H 0 : σ 2 2 = σ 2 1 (1) H 0 : σ 2 2 > σ 2 1 (2)
Eteroschedasticità-GQ Siano RSS 1 ed RSS 2 la somma del quadrato dei residui della regressione OLS rispettivamente nel primo e nel secondo sottocampione e s 2 1 = RSS 1/(T 1 k) ed s 2 2 = RSS 2/(T 2 k) le corrispondenti varianze. Allora la seguente statistica test F = RSS 2/((T 2 k)σ 2 2 ) RSS 1 /((T 1 k)σ 2 1 ) = s2 2 /σ2 2 s 2 1 /σ2 1 (3) sotto l ipotesi nulla H 0 (e sotto le ipotesi OLS) diventa F = s 2 2 /s2 1 e si distribuisce come una F T2 k,t 1 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 T 3 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 T 3 = 0. Se c e una variazione non improvvisa si esclude generalmente T 3 = n/5 per campioni piccoli e T 3 = n/3 per campioni grandi.
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 σ 2 j, e numerosità campionaria n j, con j = 1,...,G, sotto l ipotesi nulla con alternativa che la statistica test H 0 : σ 2 1 = σ2 2 =... = σ2 G (4) G LR = T log(sml 2 ) T j log(sj,ml 2 ) (5) si distribuisce asintoticamente come χ 2 (G 1), dove s 2 ML = u u/n è la varianza stimata su tutto il campione di dati e s 2 j,ml = u j u j/n j è la varianza stimata sul gruppo j-esimo. j=1
Eteroschedasticità-BP Breusch-Pagan (LM) test Il test Breusch-Pagan è basato su un modello di eteroschedasticità del tipo σ 2 t = h(z t γ) con z t = (1,z 2t,...,z pt ) 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 LM = con θ = (β,γ ) e ( ) L ( ( )) L 1 ( ) L E θ θ θ θ (6) L(β,γ) = n 2 log(2π) 1 2 T log(h(z tγ)) 1 2 t=1 T t=1 (y t x t β)2 h(z tγ) (7) (Nota 1: legame con ML, WLS e 2SFWLS o FWLS iterati. Nota 2: modelli moltiplicativi e additivi per σ 2 t).
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: û 2 t = γ 0 +γ 1 z 2t +...+γ p 1 z pt +e t e calcolo di R 2 3 : LM = TR 2. LM è distribuito asintoticamente come una χ 2 (p 1) sotto l ipotesi nulla di omoschedasticità
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 z t che influenzano la varianza. Se le variabili sono non note allora si possono utilizzare le variabili esplicative: x 2t,...,x kt e x2t 2,...,x2 kt, in tal caso 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: x jt x is con j i.
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 Heteroschedasticity di ordine q): σ 2 t = γ 0 +γ 1 u 2 t 1 +...+γ qu 2 t q. Il test LM si costruisce con i seguenti passi 1 : stima OLS: y = Xβ +u e calcolo dei residui û = y X ˆβ 2 : Regressione ausiliaria: û 2 t = γ 0 +γ 1 û 2 t 1 +...+γ qû 2 t q +e t e calcolo di R 2 3 : LM = TR 2. LM è distribuito asintoticamente come una χ 2 (q) sotto l ipotesi nulla di omoschedasticità
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 y i = β 1 +β 2 x 2i +β 3 x 3i +β 4 x 4i +β 5 D 2i +β 6 D 3i +u i (8) y i : log of the salary x 2i : education x 3i : gender (dummy, 1 se maschio, 0 femmina) x 4i : minority (dummy, 1 se minoranza e 0 altrimenti) D 2i : dummy (1 lavoro come custode, 0 altrimenti) D 3i : dummy (1 lavoro come manager, 0 altrimenti) con i = 1,...,n.
Eteroschedasticità - Esempio 1 Model 1: OLS, using observations 1 474 Dependent variable: LOGSALARY Coefficient Std. Error t-ratio p-value const 9.57469 0.0542179 176.5965 0.0000 EDUC 0.0441917 0.00428498 10.3132 0.0000 GENDER 0.178340 0.0209623 8.5077 0.0000 MINORITY 0.0748581 0.0224588 3.3331 0.0009 DUMJCAT2 0.170360 0.0434936 3.9169 0.0001 DUMJCAT3 0.539075 0.0302130 17.8425 0.0000 Mean dependent var 10.35679 S.D. dependent var 0.397334 Sum squared resid 17.86407 S.E. of regression 0.195374 R 2 0.760775 Adjusted R 2 0.758219 F(5, 468) 297.6627 P-value(F) 7.9e 143 Log-likelihood 104.4077 Akaike criterion 196.8154 Schwarz criterion 171.8481 Hannan Quinn 186.9961
Eteroschedasticità - Esempio 1 12 Y = 9.80 + 0.398X LOGSALARY versus JOBCAT (with least squares fit) 11.5 LOGSALARY 11 10.5 10 9.5 1 1.5 2 2.5 3 JOBCAT
Eteroschedasticità - Esempio 1 1 0.8 0.6 0.4 resid 0.2 0-0.2-0.4-0.6 1 1.5 2 2.5 3 JOBCAT
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 D 2i e D 3i. 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 σ1 2 = σ2 2 contro l alternativa σ2 2 > σ2 1 utilizzando la satistica F = (s2 2/s2 1 ) = (0.227476/0.188190)2 = 1.457 che ha distribuzione F 84 4,363 4. Il p-value è pari a 0.011186 quindi rifiutiamo l ipotesi nulla.
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
Eteroschedasticità - Esempio 1 Model 3: OLS, using observations 1 363 Dependent variable: LOGSALARY Coefficient Std. Error t-ratio p-value const 9.55642 0.0565441 169.0083 0.0000 EDUC 0.0463597 0.00449408 10.3157 0.0000 GENDER 0.169221 0.0212746 7.9541 0.0000 MINORITY 0.0985574 0.0233131 4.2276 0.0000 Mean dependent var 10.20254 S.D. dependent var 0.245863 Sum squared resid 12.71420 S.E. of regression 0.188190 R 2 0.418977 Adjusted R 2 0.414122 F(3, 359) 86.29199 P-value(F) 4.63e 42 Log-likelihood 93.25585 Akaike criterion 178.5117 Schwarz criterion 162.9341 Hannan Quinn 172.3197
Eteroschedasticità - Esempio 1 Model 4: OLS, using observations 1 27 Dependent variable: LOGSALARY Coefficient Std. Error t-ratio p-value const 10.3939 0.0677387 153.4409 0.0000 EDUC 0.00463417 0.00631878 0.7334 0.4704 MINORITY 0.0191656 0.0275429 0.6958 0.4932 Mean dependent var 10.33745 S.D. dependent var 0.070006 Sum squared resid 0.122445 S.E. of regression 0.071427 R 2 0.039055 Adjusted R 2-0.041024 F(2, 24) 0.487710 P-value(F) 0.619985 Log-likelihood 34.53372 Akaike criterion 63.06745 Schwarz criterion 59.17994 Hannan Quinn 61.91149
Eteroschedasticità - Esempio 1 Model 5: OLS, using observations 1 84 Dependent variable: LOGSALARY Coefficient Std. Error t-ratio p-value const 9.67598 0.274004 35.3133 0.0000 EDUC 0.0669673 0.0165246 4.0526 0.0001 GENDER 0.211185 0.0807968 2.6138 0.0107 MINORITY 0.260611 0.119540 2.1801 0.0322 Mean dependent var 11.02962 S.D. dependent var 0.268648 Sum squared resid 4.139612 S.E. of regression 0.227476 R 2 0.308942 Adjusted R 2 0.283028 F(3, 80) 11.92153 P-value(F) 1.56e 06 Log-likelihood 7.238179 Akaike criterion 6.476359 Schwarz criterion 3.246909 Hannan Quinn 2.567687
Eteroschedasticità - Esempio 1 Model 9: OLS, using observations 1 474 Dependent variable: sq resid Coefficient Std. Error t-ratio p-value const 0.0351658 0.00342653 10.2628 0.0000 DUMJCAT2 0.0182647 0.0130228 1.4025 0.1614 DUMJCAT3 0.0201025 0.00790440 2.5432 0.0113 Mean dependent var 0.037688 S.D. dependent var 0.065791 Sum squared resid 2.007417 S.E. of regression 0.065284 R 2 0.019507 Adjusted R 2 0.015343 F(2, 471) 4.685268 P-value(F) 0.009665 Log-likelihood 622.4761 Akaike criterion 1238.952 Schwarz criterion 1226.469 Hannan Quinn 1234.043
Eteroschedasticità - Esempio 1 Breusch-Pagan Vogliamo verificare la seguente struttura di eteroschedasticità (modello moltiplicativo): σ 2 i = e γ 0+γ 1 D 2i +γ 2 D 3i. 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.
Eteroschedasticità - Esempio 1 Test LR Dividendo il campione in tre gruppi in funzione del valore dalla variabile JOBCAT otteniamo per i tre sottocampioni: s1 2 = 0.1881902, s2 2 = 0.0714272 e s3 2 = 0.2274762. Da cui otteniamo s1,ml 2 = 0.1881902 363 4 363 = 0.0350, 27 3 = 0.0714272 s2,ml 2 s3,ml 2 27 = 0.0045 e 84 4 = 0.2274762 84 = 0.0493. Osserviamo inoltre che s 2 1 = 0.1953742 e quindi s 2 ML = 0.1953742 474 6 474 = 0.0377. La 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.
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).
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 sq EDUC 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
Eteroschedasticità - Esempio 1 Dependent variable: uhat 2 Omitted due to exact collinearity: X3 X5 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 sq EDUC 0.000884387 0.000491919 1.798 0.0729 X 2 X 3 0.00248857 0.00333562 0.7461 0.4560 X 2 X 4-0.00253195 0.00348105-0.7274 0.4674 X 2 X 5 0.00482944 0.00665341 0.7259 0.4683 X 2 X 6-0.0183418 0.00695796-2.636 0.0087 X 3 X 4-0.00282086 0.0166238-0.1697 0.8653 X 3 X 6 0.0215932 0.0262545 0.8225 0.4112 X 4 X 5 0.0224349 0.0298916 0.7505 0.4533 X 4 X 6 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
Eteroschedasticità - Esempio 2 Esempio 2 Sia y t il tasso di rendimento delle obbligazioni con rating AAA e sia x t il tasso di rendimento dei titoli di stato (Treasury Bill) a 3-mesi, rilevati mensilemente tra gennaio 1950 e dicembre 1999. Vogliamo stimare y t = α+β x t +u t (9)
Eteroschedasticità - Esempio 2 Model 1: OLS, using observations 1948:02 1999:12 (T = 623) Dependent variable: DAAA Coefficient Std. Error t-ratio p-value const 0.00565089 0.00672904 0.8398 0.4014 DUS3MT 0.274529 0.0143765 19.0957 0.0000 Mean dependent var 0.007528 S.D. dependent var 0.211405 Sum squared resid 17.51432 S.E. of regression 0.167939 R 2 0.369957 Adjusted R 2 0.368942 F(1, 621) 364.6465 P-value(F) 2.66e 64 Log-likelihood 228.5322 Akaike criterion 453.0644 Schwarz criterion 444.1953 Hannan Quinn 449.6177 ˆρ 0.276686 Durbin Watson 1.446100
Eteroschedasticità - Esempio 2 1.2 Regression residuals (= observed - fitted DAAA) 1 0.8 0.6 residual 0.4 0.2 0-0.2-0.4-0.6-0.8 1950 1960 1970 1980 1990 2000
Eteroschedasticità - Esempio 2 1.2 1 0.8 usq1 0.6 0.4 0.2 0 1950 1960 1970 1980 1990 2000
Eteroschedasticità - Esempio 2 1 DUS3MT versus DAAA (with least squares fit), sub-sample: 1948:01-1974:12 Y = -0.00294 + 1.19X 0.5 DUS3MT 0-0.5-1 -1.5-0.4-0.3-0.2-0.1 0 0.1 0.2 0.3 DAAA
Eteroschedasticità - Esempio 2 3 2 DUS3MT versus DAAA (with least squares fit), sub-sample 1975:01-1999:12 Y = -0.000394 + 1.37X 1 DUS3MT 0-1 -2-3 -4-5 -1-0.5 0 0.5 1 DAAA
Eteroschedasticità - Esempio 2 Vogliamo verificare l ipotesi di omoschedasticità, utilizzando i seguenti modelli di eteroschedasticità i σ 2 t = σ2 ( x t ) 2 (White) ii σ 2 t = γ 1 +γ 2 u 2 t (ARCH LM) iii σ 2 t = γ 1 +γ 2 x t (Breusch-Pagan LM) iv σ 2 t = γ 1 +γ 2 D t, (D t = 1 se t > 1974 : 12) (Breusch-Pagan LM)
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 sq DUS3MT 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
Eteroschedasticità - Esempio 2 Test for ARCH of order 2 Coefficient Std. Error t-ratio p-value alpha(0) 0.0171892 0.00325323 5.284 1.76e-07 alpha(1) 0.166183 0.0391886 4.241 2.57e-05 alpha(2) 0.225508 0.0391904 5.754 1.37e-08 Null hypothesis: no ARCH effect is present Test statistic: LM = 58.742 with p-value = P(Chi square(2) > 58.742) = 1.75523e-013
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
Eteroschedasticità - Esempio 2 Breusch-Pagan test for heteroskedasticity Model 2: OLS, using observations 1948:02 1999:12 (T = 623) Dependent variable: usq1a Coefficient Std. Error t-ratio p-value const 0.00912376 0.00413967 2.2040 0.0279 du74 0.0394340 0.00596553 6.6103 0.0000 Mean dependent var 0.028113 S.D. dependent var 0.076910 Sum squared resid 3.437360 S.E. of regression 0.074399 R 2 0.065739 Adjusted R 2 0.064234 F(1, 621) 43.69633 P-value(F) 8.27e 11 Log-likelihood 735.7523 Akaike criterion 1467.505 Schwarz criterion 1458.636 Hannan Quinn 1464.058 ˆρ 0.159407 Durbin Watson 1.681000
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.
Eteroschedasticità - Esempio 2 Esempio: regimi di volatilità (variabile dummy) e stima 2SFWLS stima OLS y t = α+β x t +u t generiamo la serie σ 2 t = û 2 t (denominata usq1) costruiamo il modello di regressione ausiliario: σ 2 t = γ 1 +γ 2 D t +ε t, (Add>time trend e poi Add>define new variable> du80=time>380) determiniamo i fitted ˆσ 2 t 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...
Eteroschedasticità - Esempio 2 Model 8: OLS, using observations 1948:02 1999:12 (T = 623) Dependent variable: usq1 Coefficient Std. Error t-ratio p-value const 0.00989738 0.00375262 2.6375 0.0086 du80 0.0472844 0.00604607 7.8207 0.0000 Mean dependent var 0.028113 S.D. dependent var 0.076910 Sum squared resid 3.349347 S.E. of regression 0.073440 R 2 0.089660 Adjusted R 2 0.088194 F(1, 621) 61.16299 P-value(F) 2.26e 14 Log-likelihood 743.8321 Akaike criterion 1483.664 Schwarz criterion 1474.795 Hannan Quinn 1480.217 ˆρ 0.138765 Durbin Watson 1.722141
Eteroschedasticità - Esempio 2 1.2 1 fitted actual Actual and fitted usq1 0.8 usq1 0.6 0.4 0.2 0 1950 1960 1970 1980 1990 2000
Eteroschedasticità - Esempio 2 Model 9: WLS, using observations 1948:02 1999:12 (T = 623) Dependent variable: DAAA Variable used as weight: sigmainv Coefficient Std. Error t-ratio p-value const 0.00931597 0.00561751 1.6584 0.0977 DUS3MT 0.248917 0.0140703 17.6910 0.0000 Statistics based on the weighted data: Sum squared resid 94.93639 S.E. of regression 0.390994 R 2 0.335097 Adjusted R 2 0.334026 F(1, 621) 312.9709 P-value(F) 5.10e 57 Log-likelihood 297.9615 Akaike criterion 599.9229 Schwarz criterion 608.7920 Hannan Quinn 603.3697 ˆρ 0.291173 Durbin Watson 1.417149 Statistics based on the original data:
Eteroschedasticità - Esempio 2 Confronto: WLS è più efficiente di OLS quando gli errori sono eteroschedastici. Si veda anche il p-value dell intercetta. WLS Coefficient Std. Error t-ratio p-value const 0.00931597 0.00561751 1.6584 0.0977 DUS3MT 0.248917 0.0140703 17.6910 0.0000 OLS Coefficient Std. Error t-ratio p-value const 0.00565089 0.00672904 0.8398 0.4014 DUS3MT 0.274529 0.0143765 19.0957 0.0000
Autocorrelazione Autocorrelazione
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 y t = x tβ +u t (10) sono serialmente correlati se esistono s t tali che E(u t,u s ) 0. In questo caso la matrice di varianza covarianze di u non è diagonale. Questo significa che y t ed y s 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.
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.
Autocorrelazione Tassi di Interesse Consideriamo il dataset xm722ibr.wk1 relativo a tassi su obbligazioni con rating AAA y t e dei tassi su obbligazioni pubbliche (Treasury Bill a 3 mesi), x t. Consideriamo le differenze prime di tali variabili: x t e y t. dal modello di regressione y t = α+β x t +u t 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 y t e x t l aggiustamento di y t non sia immediato, ma sia progressivo nel tempo. Per questo motivo una relazione statica tra y t e x t può non essere adeguata con conseguente evidenza di correlazione seriale nei residui.
Autocorrelazione uhat 1.2 1 0.8 0.6 0.4 0.2 0-0.2-0.4-0.6-0.8 uhat versus uhat 1 (with least squares fit) Y = 9.65e-005 + 0.277X -0.6-0.4-0.2 0 0.2 0.4 0.6 0.8 1 uhat 1
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 è r = T t=2ûtû t 1 T T 1 t=2û2 t t=1 û2 t di cui si utilizza una versione asintoticamente equivalente (11) r 1 = T t=2ûtû t 1 T t=1û2 t (12) Elevati valordi di r 1 possono indicare errata specificazioine nella dinamica per dati di tipo timeseries oppure errata forma funzionale per dati cross-section.
Autocorrelazione Si può costruire l autocorrelogramma valutando per ogni ritardo k con k =...,K il seguente coefficente di correlazione di ordine k r k = T t=k+1ûtû t k T t=1û2 t (13) Il grafico generato da (k,r k ) può dare un idea della presenza di autocorrelazione
Autocorrelazione Test Durbin-Watson Il test DW è basato sulla seguente idea. Siano σ 2 e la varianza dei termini di disturbo ed la correlazione tra u t e u t 1 allora E(u t u t 1 ) 2 = 2σ 2 (1 ). Così se i due termini di errore consecutivi sono correlati la differenza (u t u t 1 tenderà ad essere piccola. La statistica DW è definita come segue T (u t u t 1 ) 2 d = t=2 T ut 2 t=1 (14) La statistica soddisfa: 0 d 4 e d 2(1 r 1 ). 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
Autocorrelazione Test Breusch-Godfrey LM Il modello di riferimento è y t = x tβ +u t (15) u t = γ 1 u t 1 +...+γ p u t p +η t (16) con η t iid e gaussiano con varianza σ 2 η per ogni t. Considerando il caso AR(1), cioè p = 1 segue che y t = γ 1 y t 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.
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 H 0 = γ 1 =... = γ p = 0
Autocorrelazione Tests Box-Pierce e Ljiung-Box Le statistiche test sono BP = T LB = T p rk 2 (18) k=1 p k=1 T +2 T k r2 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).
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 y t = β 1 +β 2 x t +u t (20) la correlazione tra u t = y t β 1 β 2 x t e u t 1 = y t 1 β 1 β 2 x t 1 può essere dovuta al legame tra y t e x t 1 e y t 1 che può essere considerata con il modello y t = γ 1 +γ 2 x t +γ 3 x t 1 +γ 4 y t 1 +η t (21) con η t iid. (Si veda nota su modelli ADL).
Autocorrelazione Rimedi Possibili Modello di regressione con errori AR(1). da cui segue che corrisponde a u t = γu t 1 +η t (22) u t = y t β 1 β 2 x t (23) y t = β 1 (1 γ)+β 2 x t β 2 γx t 1 +γy t 1 +η t (24) y t = γ 1 +γ 2 x t +γ 3 x t 1 +γ 4 y t 1 +η t (25) con γ 1 = β 1 (1 γ), γ 2 = β 2, γ 3 = β 2 γ e γ 4 = γ e con il vincolo γ 2 γ 4 +γ 3 = 0 (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: da cui: y t γy t 1 = β 1 (1 γ)+β 2 (x t γx t 1 )+η t (27) Consideriamo γ = 0 e stimiamo con OLS β 1 e β 2 : y t = β 1 +β 2 x t +u t. Lo stimatore sarà consistente (se 1 < γ < 1) ma non efficiente. Regrediamo û t su û t 1 ottenendo ˆγ e y t ˆγy t 1 su x t ˆγx t 1 ottenendo dei nuovi residui η t. Una nuova stima di γ può essere ottenuta utilizzando i nuovi residui.
Autocorrelazione Esempio Consideriamo l esempio sui tassi di interesse La statistica DW = 1.446 quindi r 1 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
Autocorrelazione OLS, using observations 1948:02 1999:12 (T = 623) Dependent variable: DAAA Coefficient Std. Error t-ratio p-value const 0.00565089 0.00672904 0.8398 0.4014 DUS3MT 0.274529 0.0143765 19.0957 0.0000 Mean dependent var 0.007528 S.D. dependent var 0.211405 Sum squared resid 17.51432 S.E. of regression 0.167939 R 2 0.369957 Adjusted R 2 0.368942 F(1, 621) 364.6465 P-value(F) 2.66e 64 Log-likelihood 228.5322 Akaike criterion 453.0644 Schwarz criterion 444.1953 Hannan Quinn 449.6177 ˆρ 0.276686 Durbin Watson 1.446100
Autocorrelazione 0.3 0.2 0.1-0.1 0-0.2-0.3 0.3 0.2 0.1-0.1 0-0.2-0.3 Residual ACF 0 2 4 6 8 10 12 lag Residual PACF +- 1.96/T 0.5 0 2 4 6 8 10 12 lag +- 1.96/T 0.5
Autocorrelazione Residual autocorrelation function LAG ACF PACF Q-stat [p-value] 1 0.2764 0.2764 47.8159 [0.000] 2-0.0754-0.1643 51.3775 [0.000] 3 0.0086 0.0871 51.4240 [0.000] 4 0.0337-0.0087 52.1380 [0.000] 5 0.0546 0.0606 54.0139 [0.000] 6 0.1012 0.0785 60.4804 [0.000] 7 0.0354-0.0110 61.2716 [0.000] 8 0.0499 0.0705 62.8484 [0.000] 9 0.0449 0.0034 64.1241 [0.000] 10 0.0079 0.0011 64.1639 [0.000] 11 0.0329 0.0317 64.8526 [0.000] 12-0.0611-0.1074 67.2286 [0.000]
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 uhat 1 0.358428 0.0414183 8.654 4.44e-017 uhat 2-0.214417 0.0428149-5.008 7.21e-07 uhat 3 0.0900817 0.0435623 2.068 0.0391 uhat 4-0.00895890 0.0438469-0.2043 0.8382 uhat 5 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
Autocorrelazione Cochrane Orcutt, using observations 1948:03 1999:12 (T = 622) Dependent variable: DAAA ρ = 0.289012 ˆρ = 0.289012 Coefficient Std. Error t-ratio p-value const 0.00594436 0.00909245 0.6538 0.5135 DUS3MT 0.252253 0.0143429 17.5873 0.0000 Statistics based on the rho-differenced data: Mean dependent var 0.007556 S.D. dependent var 0.211574 Sum squared resid 16.11453 S.E. of regression 0.161218 R 2 0.420317 Adjusted R 2 0.419382 F(1, 620) 309.3128 P-value(F) 1.80e 56 ˆρ 0.050437 Durbin Watson 1.896534