Financial Econometric Models III
Upcoming SlideShare
Loading in...5
×
 

Like this? Share it with your network

Share

Financial Econometric Models III

on

  • 509 views

Third Session, MSc 5th Year

Third Session, MSc 5th Year

Statistics

Views

Total Views
509
Views on SlideShare
509
Embed Views
0

Actions

Likes
0
Downloads
4
Comments
0

0 Embeds 0

No embeds

Accessibility

Categories

Upload Details

Uploaded via as Adobe PDF

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

Financial Econometric Models III Presentation Transcript

  • 1. ESGF 5IFM Q1 2012Financial Econometric Models Vincent JEANNIN – ESGF 5IFM Q1 2012 vinzjeannin@hotmail.com 1
  • 2. ESGF 5IFM Q1 2012Summary of the session (Est. 3h)• Reminder of Last Session• Time Series Analysis Principles• Auto Regressive Process vinzjeannin@hotmail.com• Moving Average Process• ARMA• Conclusion 2
  • 3. Be logic! Reminder of Last Session vinzjeannin@hotmail.com ESGF 5IFM Q1 2012 3
  • 4. Differentiation possible ESGF 5IFM Q1 2012 vinzjeannin@hotmail.com = ln⁡ ) ( 4
  • 5. Time can be a factor of a regression vinzjeannin@hotmail.com ESGF 5IFM Q1 2012 5
  • 6. Differentiation can add value vinzjeannin@hotmail.com ESGF 5IFM Q1 2012 6
  • 7. Check ACF/PACF for autocorrelation vinzjeannin@hotmail.com ESGF 5IFM Q1 2012 7
  • 8. Time Series Analysis Principles ESGF 4IFM Q1 2012 Reminders of the 3 steps vinzjeannin@hotmail.com Identify Fit Forecast 8
  • 9. ESGF 4IFM Q1 2012Reminders of the 3 components vinzjeannin@hotmail.com Trend Seasonality Residual 9
  • 10. Lag = −1 ESGF 4IFM Q1 2012 Difference vinzjeannin@hotmail.com∆ = − −1 Seasonality Difference∆30 = − −30 10
  • 11. ESGF 4IFM Q1 2012Differentiate series to obtain stationary seriesTime series analysis and forecast simpler with stationary series vinzjeannin@hotmail.comDifferent models involved with stationary or heteroscedasticity 11
  • 12. Properties of stationary series Same distribution of the following ESGF 4IFM Q1 2012 (1 , 2 , 3 , … , ) (2 , 3 , 4 , … , +1 ) Distribution not time dependent vinzjeannin@hotmail.com Rare occurrence Stationarity accepted if ( ) = Constant in the time 12 ( , − ) Depends only on n
  • 13. Acceptable Shortcut ESGF 4IFM Q1 2012A series is stationary if the mean and the variance are stableWhich one is more likely to be stationary? vinzjeannin@hotmail.com 13
  • 14. About the residuals… White noise! ESGF 4IFM Q1 2012Normality test vinzjeannin@hotmail.com Have an idea with Skewness Kurtosis Proper tests: KS, Durbin Watson, Portmanteau,… 14
  • 15. Auto Regressive Process Main principle ESGF 4IFM Q1 2012 There is a correlation between current data and previous data = + 1 −1 + 2 −2 + ⋯ + − + vinzjeannin@hotmail.com Parameters of the model White noise AR(n) If the parameters are identified, the prediction will be easy 15
  • 16. Let’s upload some dataDATA<-read.csv(file="C:/Users/vin/Desktop/Series1.csv",header=T)plot(DATA$Val, type="l") ESGF 4IFM Q1 2012 vinzjeannin@hotmail.com 16
  • 17. Is this a white noise? hist(DATA$Val, breaks=20) ESGF 4IFM Q1 2012 vinzjeannin@hotmail.com 17
  • 18. Probably not… Portmanteau test ESGF 4IFM Q1 2012 Test the autocorrelation of a series If there is autocorrelation, data aren’t independently distributed vinzjeannin@hotmail.com Let’s use Ljung–Box statistics H0: Data are independently distributed H1: Data aren’t independently distributed 2 With α confidence interval rejection = ( + 2) following a Chi Square distribution − =1 18 Autocorrelation at the lag k > Χ 21−,ℎ
  • 19. > Box.test(DATA$Val) ESGF 4IFM Q1 2012 Box-Pierce testdata: DATA$ValX-squared = 188.3263, df = 1, p-value < 2.2e-16 vinzjeannin@hotmail.com H0 is rejected, the data aren’t independently distributed 19
  • 20. Let’s try a regression and analyse residuals TReg<-lm(DATA$Val~DATA$t) plot(DATA$Val, type="l") ESGF 4IFM Q1 2012 abline(TReg, col="blue") vinzjeannin@hotmail.com 20
  • 21. eps<-resid(TReg)ks.test(eps, "pnorm")layout(matrix(1:4,2,2))plot(TReg) ESGF 4IFM Q1 2012 vinzjeannin@hotmail.com 21
  • 22. Box-Pierce test ESGF 4IFM Q1 2012data: epsX-squared = 187.6299, df = 1, p-value < 2.2e-16Residuals aren’t a white noise vinzjeannin@hotmail.comRegression rejected Not a surprise, did the series look stationary? 22 What next then?
  • 23. lag.plot(DATA$Val, 9, do.lines=FALSE) ESGF 4IFM Q1 2012 vinzjeannin@hotmail.com 23Differentiation seems to be interesting
  • 24. Does the differentiation create a stationary series? plot(diff(DATA$Val), type="l") ESGF 4IFM Q1 2012 vinzjeannin@hotmail.com 24
  • 25. ACF & PACF par(mfrow=c(2,1)) acf(diff(DATA$Val),20) ESGF 4IFM Q1 2012 pacf(diff(DATA$Val),20) vinzjeannin@hotmail.com ACF decreasing PACF cancelling after order 1 25
  • 26. Decreasing ACF ESGF 4IFM Q1 2012PACF cancel after order 1 vinzjeannin@hotmail.com Typically an Autoregressive Process AR(1) ? 26
  • 27. Let’s try to fit an AR(1) model Modl<-ar(diff(DATA$Val),order.max=20) plot(Modl$aic) ESGF 4IFM Q1 2012 vinzjeannin@hotmail.com 27The likelihood for the order 1 is significant
  • 28. > ar(diff(DATA$Val),order.max=20) Call: ar(x = diff(DATA$Val), order.max = 20) Coefficients: 1 2 3 ESGF 4IFM Q1 2012 0.5925 -0.1669 0.1385 Order selected 3 sigma^2 estimated as 0.8514 vinzjeannin@hotmail.comWe have our coefficient and standard deviation > ARDif<-diff(DATA$Val) > ARDif[1] [1] 0.3757723We know the first term of our series = 0.3757723 + 0.5925. −1 + 28Here is our model
  • 29. Need to test the residuals ESGF 4IFM Q1 2012Box.test(Modl$resid) Box-Pierce test vinzjeannin@hotmail.comdata: Modl$residX-squared = 7e-04, df = 1, p-value = 0.9789 H0 accepted, residuals are independently distributed (white noise) The differentiated series is a AR(1) 29
  • 30. > predict(arima(diff(DATA$Val), order = c(1,0,0)), n.ahead = 7) $pred Time Series: Start = 193 End = 199 Frequency = 1 [1] -0.81359048 -0.43300609 -0.22850452 -0.11861853 -0.05957287 - ESGF 4IFM Q1 2012 0.02784553 -0.01079729 $se Time Series: Start = 193 End = 199 Frequency = 1 vinzjeannin@hotmail.com [1] 0.923352 1.048210 1.081582 1.091027 1.093739 1.094521 1.0947471201151101051009590 308580 1 6 11 16 21 26 31 36 41 46 51 56 61 66 71 76 81 86 91 96 101106111116121126131136141146151156161166171176181186191196
  • 31. ESGF 4IFM Q1 2012Another typical example? vinzjeannin@hotmail.com You make the comments! 31
  • 32. DATA<-read.csv(file="C:/Users/vin/Desktop/Series2.csv",header=T)plot(DATA$Ser2, type="l")hist(DATA$Ser2, breaks=20) ESGF 4IFM Q1 2012 vinzjeannin@hotmail.com 32
  • 33. > Box.test(DATA$Ser2) Box-Pierce testdata: DATA$Ser2X-squared = 149.9227, df = 1, p-value < 2.2e-16 ESGF 4IFM Q1 2012 vinzjeannin@hotmail.com TReg<-lm(DATA$Ser2~DATA$t) plot(DATA$Ser2, type="l") abline(TReg, col="blue") 33
  • 34. > eps<-resid(TReg)> Box.test(eps) Box-Pierce testdata: epsX-squared = 148.5669, df = 1, p-value < 2.2e-16 ESGF 4IFM Q1 2012 > layout(matrix(1:4,2,2)) > plot(TReg) vinzjeannin@hotmail.com 34
  • 35. > lag.plot(DATA$Ser2, 9, do.lines=FALSE) ESGF 4IFM Q1 2012 vinzjeannin@hotmail.com 35Much less obvious but clues of autoregression
  • 36. par(mfrow=c(2,1))plot(diff(DATA$Ser2), type="l")plot(diff(DATA$Ser2, lag=2), type="l") ESGF 4IFM Q1 2012 vinzjeannin@hotmail.com 36
  • 37. par(mfrow=c(2,1))plot(diff(DATA$Ser2), type="l")plot(diff(DATA$Ser2, lag=2), type="l") ESGF 4IFM Q1 2012 ACF decreases 2 by 2 vinzjeannin@hotmail.com PACF cancelling after order 2 37
  • 38. First order differentiation, strong AR(2) clues par(mfrow=c(1,1)) ESGF 4IFM Q1 2012 Modl<-ar(diff(DATA$Ser2),order.max=20) plot(Modl$aic) vinzjeannin@hotmail.com 38
  • 39. Parameters estimation> ar(diff(DATA$Ser2),order.max=20) ESGF 4IFM Q1 2012Call:ar(x = diff(DATA$Ser2), order.max = 20)Coefficients: 1 2 3 vinzjeannin@hotmail.com 0.5919 -0.8326 0.1086Order selected 3 sigma^2 estimated as 0.877> ARDif<-diff(DATA$Ser2)> ARDif[1][1] 0.3757723 39
  • 40. > predict(arima(diff(DATA$Ser2), order = c(2,0,0)), n.ahead = 7)$predTime Series:Start = 193End = 199Frequency = 1[1] 0.4505213 2.0075741 0.6639701 -1.2321156 -1.1409989 0.38667451.0879588 ESGF 4IFM Q1 2012$seTime Series:Start = 193End = 199Frequency = 1[1] 0.9220713 1.0332515 1.1413067 1.2938326 1.2957576 1.3932158 1.4080266 vinzjeannin@hotmail.com1151101051009590 408580 101 106 111 116 121 126 131 136 141 146 151 156 161 166 171 176 181 186 191 196 1 6 11 16 21 26 31 36 41 46 51 56 61 66 71 76 81 86 91 96
  • 41. > Box.test(Modl$resid) Box-Pierce test ESGF 4IFM Q1 2012data: Modl$residX-squared = 0.0023, df = 1, p-value = 0.9619 vinzjeannin@hotmail.com Model accepted The more factors the harder the prediction is The more factors there are the more stationary need to be the series for a good prediction 41
  • 42. Moving Average Process Main principle ESGF 4IFM Q1 2012 Stationary series with auto correlation of errors = + + 1 −1 + 2 −2 + ⋯ + − vinzjeannin@hotmail.com Parameters of the model White noise MA(n) More difficult to estimate than a AR(n) 42
  • 43. plot(Data, type="l")hist(Data, breaks=20) ESGF 4IFM Q1 2012 vinzjeannin@hotmail.com 43
  • 44. acf(Data,20)pacf(Data,20) ESGF 4IFM Q1 2012 ACF cancels after order 1 vinzjeannin@hotmail.com PACF decays to 0 44 ACF & PACF suggest MA(1)
  • 45. > arima(Data, order = c(0, 0, 1),include.mean = FALSE)Call:arima(x = Data, order = c(0, 0, 1), include.mean = FALSE)Coefficients: ma1 ESGF 4IFM Q1 2012 -0.4621s.e. 0.0903sigma^2 estimated as 0.937: log likelihood = -138.76, aic = 281.52 vinzjeannin@hotmail.com > Box.test(Rslt$residuals) Box-Pierce test data: Rslt$residuals X-squared = 0, df = 1, p-value = 0.9967 45 It works, MA(1), 0 mean, parameter -0.4621
  • 46. Fore<-predict(Rslt, n.ahead=5)U = Fore$pred + 2*Fore$seL = Fore$pred - 2*Fore$seminx=min(Data,L)maxx=max(Data,U)ts.plot(Data,Fore$pred,col=1:2,ylim=c(minx,maxx))lines(U, col="blue", lty="dashed") ESGF 4IFM Q1 2012lines(L, col="blue", lty="dashed") vinzjeannin@hotmail.com 46
  • 47. ESGF 4IFM Q1 2012Another typical example? vinzjeannin@hotmail.com You make the comments! 47
  • 48. plot(Data, type="l")hist(Data, breaks=20) ESGF 4IFM Q1 2012 vinzjeannin@hotmail.com 48
  • 49. vinzjeannin@hotmail.com ESGF 4IFM Q1 201249
  • 50. > arima(Data, order = c(0, 0, 2),include.mean = FALSE)Call: ESGF 4IFM Q1 2012arima(x = Data, order = c(0, 0, 2), include.mean = FALSE)Coefficients: ma1 ma2 -0.5365 0.6489s.e. 0.0701 0.1044 vinzjeannin@hotmail.comsigma^2 estimated as 1.005: log likelihood = -142.74, aic = 291.48> Box.test(Rslt$residuals) Box-Pierce testdata: Rslt$residualsX-squared = 0.0283, df = 1, p-value = 0.8664 50 MA(2)
  • 51. Fore<-predict(Rslt, n.ahead=5)U = Fore$pred + 2*Fore$seL = Fore$pred - 2*Fore$seminx=min(Data,L)maxx=max(Data,U)ts.plot(Data,Fore$pred,col=1:2,ylim=c(minx,maxx)) ESGF 4IFM Q1 2012lines(U, col="blue", lty="dashed")lines(L, col="blue", lty="dashed") vinzjeannin@hotmail.com 51
  • 52. ARMA Main principle ESGF 4IFM Q1 2012 The series is a function of past values plus current and past values of the noise vinzjeannin@hotmail.com ARMA(p,q) Combines AR(p) & MA(q) 52
  • 53. plot(Data, type="l")hist(Data, breaks=20) ESGF 4IFM Q1 2012 vinzjeannin@hotmail.com 53
  • 54. ESGF 4IFM Q1 2012 vinzjeannin@hotmail.com 54Both ACF and PACF decreases exponentially after order 1
  • 55. > Rslt<-arima(Data, order = c(1, 0, 1),include.mean = FALSE)> RsltCall:arima(x = Data, order = c(1, 0, 1), include.mean = FALSE) ESGF 4IFM Q1 2012Coefficients: ar1 ma1 0.7214 0.7563s.e. 0.0716 0.0721sigma^2 estimated as 0.961: log likelihood = -141.13, aic = 288.27 vinzjeannin@hotmail.com> Box.test(Rslt$residuals) Box-Pierce testdata: Rslt$residualsX-squared = 0.0098, df = 1, p-value = 0.9213 ARMA(1,1) fits 55
  • 56. > par(mfrow=c(1,1))> Fore<-predict(Rslt, n.ahead=5)> U = Fore$pred + 2*Fore$se> L = Fore$pred - 2*Fore$se> minx=min(Data,L)> maxx=max(Data,U) ESGF 4IFM Q1 2012 vinzjeannin@hotmail.com 56
  • 57. Identification can get tricky at this stage ESGF 4IFM Q1 2012 vinzjeannin@hotmail.com 57
  • 58. What do you think? vinzjeannin@hotmail.com ESGF 4IFM Q1 201258
  • 59. > Rslt<-arima(Data, order = c(4, 0, 3),include.mean = FALSE)> RsltCall:arima(x = Data, order = c(4, 0, 3), include.mean = FALSE)Coefficients: ESGF 4IFM Q1 2012 ar1 ar2 ar3 ar4 ma1 ma2 ma3 0.2722 -0.5276 0.0202 -0.2663 0.8765 -0.4672 -0.5248s.e. 0.2018 0.2308 0.1968 0.1546 0.1992 0.1690 0.1882sigma^2 estimated as 1.140: log likelihood = -151.19, aic = 318.38> Box.test(Rslt$residuals) vinzjeannin@hotmail.com Box-Pierce testdata: Rslt$residualsX-squared = 0.2953, df = 1, p-value = 0.5869 Was supposed to fit pretty wel…. Data<-arima.sim(model=list(ar=c(0.5,-0.5,0.3,- 59 0.3),ma=c(0.75,-0.5,-0.5)),n=100)
  • 60. Identification can be difficult ESGF 4IFM Q1 2012Easiest model is ARImagine when the series is not stationary… vinzjeannin@hotmail.comStep by step approach, exploration, tries,… Sometimes you find a satisfying model 60 Sometimes you don’t!
  • 61. Conclusion AR MA ARMA Times series vinzjeannin@hotmail.com ESGF 5IFM Q1 201261