เริ่มต้นใช้งานเริ่มต้นใช้งานได้ฟรี

Prediction errors

Under the GARCH model, the variance is driven by the square of the prediction errors \(e = R - \mu\). In order to calculate a GARCH variance, you thus need to first compute the prediction errors. For daily returns, it is common practice to set \(\mu\) equal to the sample average.

You're going to implement this and then verify that there is a large positive autocorrelation in the absolute value of the prediction errors. Positive autocorrelation reflects the presence of volatility clusters. When volatility is above average, it stays above average for some time. When volatility is low, it stays low for some time.

แบบฝึกหัดนี้เป็นส่วนหนึ่งของหลักสูตร

GARCH Models in R

ดูคอร์ส

คำแนะนำการฝึกหัด

  • Set m to the mean of the daily S&P 500 returns in sp500ret.
  • Compute the prediction errors.
  • Plot the time series of absolute value of the prediction errors.
  • Use the function acf to plot the autocorrelation function of the absolute value of the prediction errors.

แบบฝึกหัดเชิงโต้ตอบแบบลงมือทำ

ลองทำแบบฝึกหัดนี้โดยเติมโค้ดตัวอย่างนี้ให้สมบูรณ์

# Compute the mean daily return
m <- ___(___)

# Define the series of prediction errors
e <- ___ - ___

# Plot the absolute value of the prediction errors
par(mfrow = c(2,1),mar = c(3, 2, 2, 2))
___(___(___))

# Plot the acf of the absolute prediction errors
___
แก้ไขและรันโค้ด