Il test di Ljung-Box

Gestione del rischio quantitativa in R

Alexander McNeil

Professor, University of York

Verificare l’ipotesi iid con il test di Ljung-Box

  • Test numerico calcolato dalle autocorrelazioni campionarie al quadrato fino a un certo ritardo
  • Confrontato con la distribuzione chi-quadro con gradi di libertà (df)
  • Da eseguire anche sui valori assoluti

$$

$$X^2 = n(n+2) \sum_{j=1}^k{{\hat{\rho}(j)^2} \over {n-j}}$$

Gestione del rischio quantitativa in R

Esempio di test di Ljung-Box

Box.test(ftse, lag = 10, type = "Ljung")
    Box-Ljung test

dati: ftse
X-squared = 41.602, df = 10, p-value = 8.827e-06
Box.test(abs(ftse), lag = 10, type = "Ljung")
    Box-Ljung test

dati: abs(ftse)
X-squared = 314.62, df = 10, p-value < 2.2e-16
Gestione del rischio quantitativa in R

Applicare Ljung-Box a rendimenti su intervalli più lunghi

ftse_w <- apply.weekly(ftse, FUN = sum)
head(ftse_w, n = 3)
                 ^FTSE
2008-01-04 -0.01693075
2008-01-11 -0.02334674
2008-01-18 -0.04963134
Box.test(ftse_w, lag = 10, type = "Ljung")
    Box-Ljung test

dati: ftse_w
X-squared = 18.11, df = 10, p-value = 0.05314

$$$$$$$$$$$$$$$$

Box.test(abs(ftse_w), lag = 10, type = "Ljung")
    Box-Ljung test

dati: abs(ftse_w)
X-squared = 34.307, df = 10, p-value = 0.0001638
Gestione del rischio quantitativa in R

Facciamo pratica!

Gestione del rischio quantitativa in R

Preparing Video For Download...