1 / 47

STAT 497 LECTURE NOTE 10

STAT 497 LECTURE NOTE 10. DIAGNOSTIC CHECKS. DIAGNOSTIC CHECKS. After identifying and estimating a time series model, the goodness-of-fit of the model and validity of the assumptions should be checked. If we have a perfect model fit, then we can construct the ARIMA forecasts.

arbogast
Download Presentation

STAT 497 LECTURE NOTE 10

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. STAT 497LECTURE NOTE 10 DIAGNOSTIC CHECKS

  2. DIAGNOSTIC CHECKS • After identifying and estimating a time series model, the goodness-of-fit of the model and validity of the assumptions should be checked. If we have a perfect model fit, then we can construct the ARIMA forecasts.

  3. 1. NORMALITY OF ERRORS • Check the histogram of the standardized residuals, . • Draw Normal QQ-plot of the standardized residuals (should be a straight line on 450 line). • Look at Tukey’s simple 5-number summary + skewness(should be 0 for normal)+ kurtosis (should be 3 for normal) or excess kurtosis (should be 0 for normal)

  4. 1. NORMALITY OF ERRORS • Jarque-Bera Normality Test: Skewness and kurtosis are used for constructing this test statistic. JB (1981) tests whether the coefficients of skewness and excess kurtosis are jointly 0.

  5. 1. NORMALITY OF ERRORS • JB test statistic • JB> , then reject the null hypothesis that residuals are normally distributed.

  6. 1. NORMALITY OF ERRORS • The chi-square approximation, however, is overly sensitive for small samples, rejecting the null hypothesis often when it is in fact true. Furthermore, the distribution of p-values departs from a uniform distribution and becomes a right-skewed uni-modal distribution, especially for small p-values. This leads to a large Type I error rate. The table below shows some p-values approximated by a chi-square distribution that differ from their true alpha levels for very small samples. • You can also use Shapiro-Wilk test.

  7. 1. NORMALITY OF ERRORS

  8. 2. DETECTION OF THE SERIAL CORRELATION • In OLS regression, time residuals are often found to be serially correlated with their own lagged values. • Serial correlation means • OLS is no longer an efficient linear estimator. • Standard errors are incorrect and generally overstated. • OLS estimates are biased and inconsistent if a lagged dependent variable is used as a regressor.

  9. 2. DETECTION OF THE SERIAL CORRELATION • Durbin-Watson test is for regular regression with independent variables. It is not appropriate for time series models with lagged dependent variables. It only tests for AR(1) errors. There should be a constant term and deterministic independent variables in the model.

  10. 2. DETECTION OF THE SERIAL CORRELATION • Serial Correlation Lagrange Multiplier (Breusch-Godfrey) Test is valid in the presence of lagged dependent variables. It tests for AR(p) errors.

  11. 2. DETECTION OF THE SERIAL CORRELATION • The test hypothesis: • Test statistic: Obtained from the auxiliary regression

  12. 2. DETECTION OF THE SERIAL CORRELATION • Determination of r: No obvious answer exists. In empirical studies • for AR, ARMA: r=p+1 lags • For seasonal, r=s.

  13. 2. DETECTION OF THE SERIAL CORRELATION • Ljung-Box (Modified Box-Pierce) or Portmanteau Lack-of-Fit Test: Box and Pierce (1970) have developed a test to check the autocorrelation structure of the residuals. Then, it is modified by Ljung and Box. • The null hypothesis to be tested:

  14. 2. DETECTION OF THE SERIAL CORRELATION • The test statistic:

  15. 2. DETECTION OF THE SERIAL CORRELATION • If the correct model is estimated, • If , reject H0. This means that the autocorrelation exists in residuals. Assumption is violated. Check the model again. It is better to add another lag in AR or MA part of the model.

  16. 3. DETECTING HETEROSCEDASTICITY • Heteroskedasticity is a violation of the constant error variance assumption. It occurs if variance of error changing by time.

  17. 3. DETECTING HETEROSCEDASTICITY • ACF-PACF PLOT OF SQUARED RESIDUALS: Since {at} is a zero mean process, the variance of at is defined by the expected value of squared at’s. So, if at’sare homoscedastic, the variance will be constant (not change over time) and when we look at the ACF and PACF plots of squared residuals, they should be in 95% WN limits. If not, this is a sign of heteroscedasticity.

  18. 3. DETECTING HETEROSCEDASTICITY • Let rt be the log return of an asset at time t. We are going to look at the study of volatility: the series is either serially uncorrelated or with minor lower order serial correlations, but it is a dependent series. • Examine the ACF for the residuals and squared residuals for the calamari catch data. The catch data had a definite seasonality, which was removed. Then, the remaining series was modelled with an AR(5) model and the residuals of this model are obtained. • There are various definitions of what constitutes weak dependence of a time series. However, the operational definition of independence here will be that both the autocorrelation functions of the series and the squared series show no autocorrelation. If there is no serial correlation of the series but there is of the squared series, then we will say there is weak dependence. This will lead us to examine the volatility of the series, since that is exemplified by the squared terms.

  19. 3. DETECTING HETEROSCEDASTICITY Figure 1: Residuals after AR(5) fitted to the deseasoned calamari data Figure 2: Autocorrelation of the squared residuals

  20. 3. DETECTING HETEROSCEDASTICITY Figure 3: Autocorrelation for the log returns for the Intel series

  21. 3. DETECTING HETEROSCEDASTICITY Figure 4: ACF of the squared returns Figure 5: PACF for squared returns Combining these three plots, it appears that this series is serially uncorrelated but dependent. Volatility models attempt to capture such dependence in the return series

  22. 3. DETECTING HETEROSCEDASTICITY • If we ignore heterocedasticity: • The OLS estimator is unbiased but not efficient. The GLS or WLS is the Gauss-Markov estimator. • The estimate of the variance of the OLS estimator is a biased estimator of the true variance. The classical testing procedures are invalidated. • Now, the question is how we can detect heteroscedasticity?

  23. 3. DETECTING HETEROSCEDASTICITY • White’s General Test for Heteroscedasticity: • After identified model is estimated, we obtain the residuals, . Then, can be written as

  24. 3. DETECTING HETEROSCEDASTICITY • Then, construct the following artificial regression • The homocedastic case implies that 1 = 2 = ... = 1 = 2=…= 1= 2=…= 0, therefore

  25. 3. DETECTING HETEROSCEDASTICITY • Then, the test statistics is given by under the null hypothesis of homoscedasticity where m is the number of variables in artificial regression except the constant term.

  26. 3. DETECTING HETEROSCEDASTICITY • The Breush-Pagan Test: It is a Lagrange-Multiplier test for heteroscedasticity. Consider the IF of a time series. Let’s assume that we can write our model in AR(m). • Then, consider testing

  27. 3. DETECTING HETEROSCEDASTICITY • Note that we need to evaluate the conditional (on the independent variables) expectation of the squared of the error term, • The homocedastic case implies that 1 = 2 = ... = m = 0.

  28. 3. DETECTING HETEROSCEDASTICITY • The problem, however, is that we do not know the error term , but it can be replaced by an estimate . A simple approach is to run a regression, and test if the slope coefficients are all equal to zero.

  29. 3. DETECTING HETEROSCEDASTICITY • The test statistic under the null hypothesis of homoscedasticity where m is the number of variables in artificial regression except the constant term.

  30. 3. DETECTING HETEROSCEDASTICITY • If we reject the null hypothesis, this means that the error variance is not constant. It is changing over time. Therefore, we need to model the volatility. ARCH (Autoregressive Conditional Heteroskedasticity) or GARCH (Generalized Autoregressive Conditional Heteroskedasticity) modeling helps us to model the error variance.

  31. EXAMPLE (BEER)

  32. > HEGY.test (beer, itsd=c(1,0,0),regvar=0, selectlags=list(mode="bic", Pmax=12)) Stat. p-value tpi_1 -3.420 0.01 tpi_2 -3.389 0.01 Fpi_3:4 7.440 0.01 Fpi_5:6 6.225 0.01 Fpi_7:8 16.306 0.01 Fpi_9:10 1.011 0.10 Fpi_11:12 0.254 0.10 Fpi_2:12 8.326 NA Fpi_1:12 8.716 NA

  33. > HEGY.test (diff(beer,12), itsd=c(0,0,0),regvar=0, selectlags=list(mode="bic", Pmax=12)) Stat. p-value tpi_1 -1.515 0.10 tpi_2 -6.638 0.01 Fpi_3:4 28.446 0.01 Fpi_5:6 21.073 0.01 Fpi_7:8 32.810 0.01 Fpi_9:10 31.148 0.01 Fpi_11:12 16.261 0.01 Fpi_2:12 22.315 NA Fpi_1:12 20.719 NA

  34. > HEGY.test (diff(diff(beer,12)), itsd=c(0,0,0),regvar=0, selectlags=list(mode="bic", Pmax=12)) Stat. p-value tpi_1 -4.860 0.01 tpi_2 -5.189 0.01 Fpi_3:4 32.538 0.01 Fpi_5:6 18.720 0.01 Fpi_7:8 35.147 0.01 Fpi_9:10 22.507 0.01 Fpi_11:12 15.338 0.01 Fpi_2:12 29.240 NA Fpi_1:12 45.752 NA

  35. fit=arima(beer,order=c(2,1,4),seasonal=list(order=c(3,1,3), period=12)) Coefficients: ar1 ar2 ma1 ma2 ma3 ma4 sar1 sar2 sar3 0.3337 -0.486 -0.8695 0.4540 -0.0712 -0.3666 1.054 -1.1337 0.1774 s.e. 0.2441 0.223 0.2388 0.3277 0.1622 0.0805 0.281 0.2148 0.2569 sma1 sma2 sma3 -1.6633 1.6535 -0.6396 s.e. 0.2656 0.3063 0.2274 sigma^2 estimated as 0.2231: log likelihood = -142.47, aic = 308.95 fit2=arima(beer,order=c(2,1,4),seasonal=list(order=c(2,1,2), period=12)) Coefficients: ar1 ar2 ma1 ma2 ma3 ma4 sar1 sar2 -0.2283 -0.2633 -0.4838 0.0159 -0.0800 -0.3017 -0.5909 0.3491 s.e. 0.3500 0.2204 0.3384 0.3717 0.1834 0.0759 0.3603 0.1548 sma1 sma2 0.0782 -0.8204 s.e. 0.3641 0.3062 sigma^2 estimated as 0.3067: log likelihood = -154.03, aic = 328.06

  36. fit3=arima(beer,order=c(0,1,4),seasonal=list(order=c(1,1,3), period=12)) Coefficients: ma1 ma2 ma3 ma4 sar1 sma1 sma2 sma3 -0.6444 -0.0807 0.1126 -0.2889 -0.7777 0.3264 -0.6059 -0.3268 s.e. 0.0731 0.0943 0.0858 0.0880 0.1953 0.2081 0.1337 0.0982 sigma^2 estimated as 0.3028: log likelihood = -153.39, aic = 322.78

  37. plot(window(rstandard(fit3),start=c(1975,1)), ylab='Standardized Residuals',type='o') abline(h=0) acf(as.vector(window(rstandard(fit3),start=c(1975,1))), lag.max=36) pacf(as.vector(window(rstandard(fit3),start=c(1975,1))), lag.max=36)

  38. EXAMPLE (BEER) > hist(rstandard(fit3), xlab='Standardized Residuals')

  39. EXAMPLE (BEER) > qqnorm(rstandard(fit2)) > qqline(rstandard(fit2))

  40. EXAMPLE (BEER) > shapiro.test(window(rstandard(fit3),start=c(1975,1))) Shapiro-Wilk normality test data: window(rstandard(fit3), start = c(1975, 1)) W = 0.92709, p-value = 3.361e-08 > jarque.bera.test(resid(fit3)) Jarque Bera Test data: resid(fit3) X-squared = 441.11, df = 2, p-value < 2.2e-16

  41. EXAMPLE (BEER) par(mfrow=c(1,1)) BoxCox.ar(y=beer)

  42. > beert=beer**1.7 > fit3=arima(beert,order=c(0,1,4),seasonal=list(order=c(1,1,3), period=12)) > fit3 Coefficients: ma1 ma2 ma3 ma4 sar1 sma1 sma2 sma3 -0.6214 -0.1011 0.1307 -0.3103 -0.7888 0.3320 -0.6399 -0.3405 s.e. 0.0730 0.0922 0.0868 0.0843 0.1890 0.2039 0.1358 0.1010 sigma^2 estimated as 34.96: log likelihood = -579.04, aic = 1174.09 shapiro.test(window(rstandard(fit3),start=c(1975,1))) Shapiro-Wilk normality test W = 0.94415, p-value = 8.482e-07 jarque.bera.test(resid(fit3)) Jarque Bera Test X-squared = 235.55, df = 2, p-value < 2.2e-16

  43. EXAMPLE (BEER) > Box.test(resid(fit3),lag=15,type = c("Ljung-Box")) Box-Ljung test data: resid(fit3) X-squared = 23.747, df = 15, p-value = 0.06952 > Box.test(resid(fit3),lag=15,type = c("Box-Pierce")) Box-Pierce test data: resid(fit3) X-squared = 22.507, df = 15, p-value = 0.09518

  44. EXAMPLE (BEER) rr=resid(fit3)^2 par(mfrow=c(1,2)) acf(rr) pacf(rr)

  45. EXAMPLE (BEER) > arch.test(fit3) Portmanteau-Q test: order PQ p.value [1,] 4 0.514 0.972 [2,] 8 0.609 1.000 [3,] 12 1.740 1.000 [4,] 16 4.616 0.997 [5,] 20 5.554 0.999 [6,] 24 5.786 1.000 Lagrange-Multiplier test: order LM p.value [1,] 4 339.0 0.00e+00 [2,] 8 156.5 0.00e+00 [3,] 12 92.5 5.44e-15 [4,] 16 60.0 2.51e-07 [5,] 20 42.4 1.56e-03 [6,] 24 33.3 7.61e-02

  46. EXAMPLE (BEER) > par(mfrow=c(1,1)) > result=plot(fit3,n.ahead=12,ylab='Series & Forecasts',col=NULL,pch=19) > abline(h=coef(fit2)) > forecast=result$pred > cbind(beer,forecast) > plot(fit3,n1=1975,n.ahead=12,ylab='Series, Forecasts, Actuals & Limits', pch=19)

More Related