Showing posts with label How to expect the log returns to be serially uncorrelated. Show all posts
Showing posts with label How to expect the log returns to be serially uncorrelated. Show all posts

Wednesday, August 7, 2019

How to expect the log returns to be serially uncorrelated,but,the squared or absolute log returns to show significant autocorrelations

The squared or absolute log returns to show significant autocorrelations

getSymbols("BMW.DE", from="2004-01-01", to=Sys.Date())

[1] "BMW.DE"
chartSeries(Cl(chartSeries(BMW.DE)))
return,logreturns,dj gig log,log return,log,tutorial,gig log,geometric return,mobile dj setup,arithmetic return,log returns,lighting,wedding,log returns excel,event log,return js,total return,daily return,logarithmic returns,stock returns,average return,how to be a dj,p5.js return,portfolio return,cumulative return,log charts,logarithm


 ret <- dailyReturn(Cl(BMW.DE), type='log')
> par(mfrow=c(2,2))
> acf(ret, main="Return ACF");
> pacf(ret, main="Return PACF");
> acf(ret^2, main="Squared return ACF");
> pacf(ret^2, main="Squared return PACF")
www.r-languagestatistics.co

> par(mfrow=c(1,1))
> m=mean(ret);s=sd(ret);
> par(mfrow=c(1,2))
> hist(ret, nclass=40, freq=FALSE, main='Return histogram');curve(dnorm(x,
+  mean=m,sd=s), from = -0.3, to = 0.2, add=TRUE, col="red")
www.r-languagestatistics.co

> plot(density(ret), main='Return empirical distribution');curve(dnorm(x,
+     mean=m,sd=s), from = -0.3, to = 0.2, add=TRUE, col="red")
> plot(density(ret), main='Return empirical distribution');curve(dnorm(x,
+ mean=m,sd=s), from = -0.3, to = 0.2, add=TRUE, col="red")
www.r-languagestatistics.co

 plot(density(ret), main='Return EDF - upper tail', xlim = c(0.1, 0.2),
+      ylim=c(0,2));
> curve(dnorm(x, mean=m,sd=s), from = -0.3, to = 0.2, add=TRUE, col="red")
> plot(density(ret), xlim=c(-5*s,5*s),log='y', main='Density on log-scale')
> curve(dnorm(x, mean=m,sd=s), from=-5*s, to=5*s, log="y", add=TRUE,col="red")
> qqnorm(ret);qqline(ret)
www.r-languagestatistics.co

ret.bmw <- dailyReturn(Cl(BMW.DE), type='log')
> chartSeries(ret.bmw)
www.r-languagestatistics.co

SGARCH

garch11.spec = ugarchspec(variance.model = list(model="sGARCH",
+ garchOrder=c(1,1)), mean.model = list(armaOrder=c(0,0)))
> bmw.garch11.fit = ugarchfit(spec=garch11.spec, data=ret.bmw)
> coef(bmw.garch11.fit)
          mu        omega       alpha1
2.919136e-04 1.435439e-06 3.742065e-02
       beta1
9.581990e-01
coef(bmw.garch11.fit)
          mu        omega       alpha1
2.919136e-04 1.435439e-06 3.742065e-02
       beta1
9.581990e-01
> coef(bmw.garch11.fit)
          mu        omega       alpha1
2.919136e-04 1.435439e-06 3.742065e-02
       beta1
9.581990e-01
> vcov(bmw.garch11.fit)
              [,1]          [,2]
[1,]  5.403545e-08  1.557122e-12
[2,]  1.557122e-12  3.924937e-13
[3,]  1.025510e-08  3.723824e-10
[4,] -1.119054e-08 -7.019947e-10
              [,3]          [,4]
[1,]  1.025510e-08 -1.119054e-08
[2,]  3.723824e-10 -7.019947e-10
[3,]  4.843506e-06 -3.916215e-06
[4,] -3.916215e-06  4.268876e-06
infocriteria(bmw.garch11.fit)
                   
Akaike       -5.385802
Bayes        -5.379472
Shibata      -5.385804
Hannan-Quinn -5.383558
 newsimpact(bmw.garch11.fit)
$zy
  [1] 0.0036832952 0.0035485946
  [3] 0.0034166430 0.0032874403
  [5] 0.0031609867 0.0030372821
  [7] 0.0029163264 0.0027981197
  [9] 0.0026826621 0.0025699534
 [11] 0.0024599937 0.0023527830
 [13] 0.0022483213 0.0021466086
 [15] 0.0020476449 0.0019514302
 [17] 0.0018579645 0.0017672477
 [19] 0.0016792800 0.0015940612
 [21] 0.0015115915 0.0014318707
 [23] 0.0013548989 0.0012806761
 [25] 0.0012092023 0.0011404775
 [27] 0.0010745017 0.0010112749
 [29] 0.0009507971 0.0008930683
 [31] 0.0008380884 0.0007858576
 [33] 0.0007363757 0.0006896429
 [35] 0.0006456590 0.0006044241
 [37] 0.0005659382 0.0005302013
 [39] 0.0004972134 0.0004669745
 [41] 0.0004394846 0.0004147436
 [43] 0.0003927517 0.0003735088
 [45] 0.0003570148 0.0003432699
 [47] 0.0003322739 0.0003240269
 [49] 0.0003185289 0.0003157799
 [51] 0.0003157799 0.0003185289
 [53] 0.0003240269 0.0003322739
 [55] 0.0003432699 0.0003570148
 [57] 0.0003735088 0.0003927517
 [59] 0.0004147436 0.0004394846
 [61] 0.0004669745 0.0004972134
 [63] 0.0005302013 0.0005659382
 [65] 0.0006044241 0.0006456590
 [67] 0.0006896429 0.0007363757
 [69] 0.0007858576 0.0008380884
 [71] 0.0008930683 0.0009507971
 [73] 0.0010112749 0.0010745017
 [75] 0.0011404775 0.0012092023
 [77] 0.0012806761 0.0013548989
 [79] 0.0014318707 0.0015115915
 [81] 0.0015940612 0.0016792800
 [83] 0.0017672477 0.0018579645
 [85] 0.0019514302 0.0020476449
 [87] 0.0021466086 0.0022483213
 [89] 0.0023527830 0.0024599937
 [91] 0.0025699534 0.0026826621
 [93] 0.0027981197 0.0029163264
 [95] 0.0030372821 0.0031609867
 [97] 0.0032874403 0.0034166430
 [99] 0.0035485946 0.0036832952

$zx
  [1] -0.300000000 -0.293939394
  [3] -0.287878788 -0.281818182
  [5] -0.275757576 -0.269696970
  [7] -0.263636364 -0.257575758
  [9] -0.251515152 -0.245454545
 [11] -0.239393939 -0.233333333
 [13] -0.227272727 -0.221212121
 [15] -0.215151515 -0.209090909
 [17] -0.203030303 -0.196969697
 [19] -0.190909091 -0.184848485
 [21] -0.178787879 -0.172727273
 [23] -0.166666667 -0.160606061
 [25] -0.154545455 -0.148484848
 [27] -0.142424242 -0.136363636
 [29] -0.130303030 -0.124242424
 [31] -0.118181818 -0.112121212
 [33] -0.106060606 -0.100000000
 [35] -0.093939394 -0.087878788
 [37] -0.081818182 -0.075757576
 [39] -0.069696970 -0.063636364
 [41] -0.057575758 -0.051515152
 [43] -0.045454545 -0.039393939
 [45] -0.033333333 -0.027272727
 [47] -0.021212121 -0.015151515
 [49] -0.009090909 -0.003030303
 [51]  0.003030303  0.009090909
 [53]  0.015151515  0.021212121
 [55]  0.027272727  0.033333333
 [57]  0.039393939  0.045454545
 [59]  0.051515152  0.057575758
 [61]  0.063636364  0.069696970
 [63]  0.075757576  0.081818182
 [65]  0.087878788  0.093939394
 [67]  0.100000000  0.106060606
 [69]  0.112121212  0.118181818
 [71]  0.124242424  0.130303030
 [73]  0.136363636  0.142424242
 [75]  0.148484848  0.154545455
 [77]  0.160606061  0.166666667
 [79]  0.172727273  0.178787879
 [81]  0.184848485  0.190909091
 [83]  0.196969697  0.203030303
 [85]  0.209090909  0.215151515
 [87]  0.221212121  0.227272727
 [89]  0.233333333  0.239393939
 [91]  0.245454545  0.251515152
 [93]  0.257575758  0.263636364
 [95]  0.269696970  0.275757576
 [97]  0.281818182  0.287878788
 [99]  0.293939394  0.300000000

$yexpr
expression(sigma[t]^2)

$xexpr
expression(epsilon[t - 1])
signbias(bmw.garch11.fit)
                    t-value      prob
Sign Bias          1.022889 0.3064225
Negative Sign Bias 1.459623 0.1444730
Positive Sign Bias 1.379381 0.1678550
Joint Effect       4.337643 0.2272374
                   sig

Sign Bias             

Negative Sign Bias 
Positive Sign Bias 
Joint Effect
uncvariance(bmw.garch11.fit)
[1] 0.000327699
> uncmean(bmw.garch11.fit)
[1] 0.0002919136
plot(ni.garch11$zx, ni.garch11$zy, type="l",lwd=2, col="blue",main="GARCH(1,1) - News Impact", ylab=ni.garch11$yexpr, xlab=ni.garch11$xexpr)

www.r-languagestatistics.coEgarch

egarch11.spec = ugarchspec(variance.model = list(model="eGARCH",
+ garchOrder=c(1,1)), mean.model = list(armaOrder=c(0,0)))
> bmw.egarch11.fit = ugarchfit(spec=egarch11.spec, data=ret.bmw)
> coef(bmw.egarch11.fit)
           mu         omega
 5.037116e-05 -5.327172e-02
       alpha1         beta1
-2.258236e-02  9.930783e-01
       gamma1
 8.932355e-02
> ni.egarch11 <- newsimpact(bmw.egarch11.fit)
> plot(ni.egarch11$zx, ni.egarch11$zy, type="l", lwd=2, col="blue",
+      main="EGARCH(1,1) - News Impact",
+      ylab=ni.egarch11$yexpr, xlab=ni.egarch11$xexpr)
www.r-languagestatistics.co