Exercise: Get the mothly S&P 500 idex (^GSPC) ad plot the periodogram of the returs. Mae sure that the umber of returs is divisible by. Y <- read.csv("^gspc.csv",a.strigs"ull") Y <- a.omit(y) # rows with missig values are omitted N <- row(y) # umber of rows d <- as.date(y[,]) # dates i colum y <- log(y[,6]) # adjusted close prices i colum 6 r <- y[:n]-y[:(n-)] ; <- N- # log returs <- -%% # 9%%9 modulo 5 r <- r[(-+):] # r cotais the last obs. m <- floor(/); f <- (*pi/)*(:m) ft <- fft(r) # Fourier trasform ft <- ft[:(m+)] # oly frequecies,,m pg <- (/(*pi*))*(mod(ft))^ # periodogram par(marc(,,,)); plot(f,pg,type"l").years <- / # umber of full years s <-.years*(:6) # idices of seasoal frequecies lies(f[s],pg[s],type"p",pch0,col"red") Sice the periodogram ordiates at the first four seasoal frequecies are relatively large, the returs could possibly cotai a small seasoal compoet.
Exercise: Show that AC Cov(α x+β y,γ u+δ v) αγ Cov(x,u) + αδ Cov(x,v) + βγ Cov(y,u) + βδ Cov(y,v). Suppose that x is white oise with mea µ ad variace π ad ω, 0<<. The E E x t  E cos(ωt) E( x 3 t ) cos(ωt) μ µ Bˆ E cos( ω t) 0, 3 0 x t μ si(ωt) si( ω t) 0, 3 0 Var(  ) Var x t cos ( Var( Bˆ ) Cov( Â, Bˆ ) Similarly, Cov( j ( ) cos (ωt) 3 ω t ) 3, si ( ω t ) 3 s  j,, Cov( x s, x t ) cos(ωjs)si(ωt) Var( xt ) cos(ωjt)si(ωt) cos( ω t)si( ωt) 0. 3 0  )Cov( Bˆ, Bˆ )0 if j. AM j
Suppose that x,,x are i.i.d. N(µ, ). The  x t π cos( t), Bˆ x t π si( are for m[ ] ormally distributed with mea zero ad variace. This implies that Â, have a stadard ormal distributio. Because of the joit ormality of Â, Bˆ it follows already from that  ad Bˆ Cov( Â, Bˆ )0 Bˆ are idepedet. Whe the sample size is large, this assumptio is ot critical. Because of the cetral limit theorem, the distributios of (weighted) averages of the observatios ca still be regarded as approximately ormal eve if the observatios themselves are ot ormally distributed. t), For each m, the radom variable ( A ˆ + B ˆ 8π ) ˆ ˆ ( A ) 3 8 π + B π I(ω) I ( ω ) is therefore the sum of the squares of two idepedet stadard ormal radom variables, i.e., it has a chi-squared distributio with degrees of freedom, deoted π I(ω)~χ (). The radom variables I(ω) are ot oly idetically distributed, they are also idepedet. This follows from the idepedece of the pairs ( Â, Bˆ ),,,m, ad the fact that each I(ω) is a fuctio of Exercise: Show that if, the  ad Bˆ. AD π I(ω) π I(π)~χ (). A 3
If x,,x are i.i.d. N(µ, ), the are i.i.d. χ (). π I(ω), <, Sice the χ () distributio is idetical to the expoetial distributio with mea, are i.i.d. Exp(). Hece, π I(ω), <, P( π I(ω) c) λ e dλ e if c log(α). c 0 λ c 0 e c α, Whe is large, we ca approximate the uow parameter by the sample variace s. The ull hypothesis of Gaussia white oise ca be rejected at the approximate 5% level, if for a specified or for specified,...,j, (i) π I(ω) > log(0.05), s π or (iii) or (ii) max( 0.95 I ( ω ) + + π s π I ( ω ),..., I( ω ) > χ ( ), AT π s j 0.95 0.95 j I( ω ) ) > log( j 0. 95 ), where χ ( ) ~5.99, χ ( ) ~9.88, are the 0.95- quatiles of the χ ( j) distributio, j,, Exercise: Show that Ex if x~χ (). A Exercise: Suppose that x,...,x are i.i.d. N(µ, ). Show that E I(ω) π for all <. AW Exercise: Suppose that J, J are i.i.d. Exp(). Show that P(max(J,J) log( 0.95 ))0.95. Hit: P(max(J,J) c)p(j c J c) P(J c)p(j c) AL j
Exercise: Add a horizotal lie to the S&P 500 periodogram, which represets the critical value (α0.05) for a test based o the periodogram value at a fixed frequecy. s <- var(r) ablie(h-log(0.05)*s/(*pi),col"gree") Exercise: Add further horizotal lies to the S&P 500 periodogram, which represet the critical values (α0.05) for tests based o the maximum of 3 or 5 periodogram values at 3 or 5 fixed frequecies. ablie(h-log(-0.95^(/3))*s/(*pi),col"blue") ablie(h-log(-0.95^(/5))*s/(*pi),col"violet") 5
Exercise: Use the sum of j periodogram values at fixed frequecies as test statistic. (i) j3: First three seasoal frequecies sum(pg[s[:3]])**pi/s # test statistic 9.355 qchisq(0.95,6) # 0.95-quatile of a chi(6) distr..5959 9.6937>.5959 H0 is rejected. (ii) j6: All seasoal frequecies s <-.years*(:6) # idices of seasoal frequecies sum(pg[s[:5]])**pi/s+pg[s[6]]**pi/s 3.038 qchisq(0.95,) # 0.95-quatile of a chi() distr. 9.675 h <- sum(pg[s[:5]])**pi/s+pg[s[6]]**pi/s -pchisq(h,) 0.076099 Note: The periodogram at frequecy π, which is the 6 th seasoal frequecy, has a differet distributio uder H0, i.e., π I(ω)~χ () if ωπ ad π I(ω)~χ () if ω π. 6