Zeitreihenanalyse - Übung 8

From StatWiki
Jump to: navigation, search

SP500

Critical value for sum of top 6 and sum of top 3

Convert.php: convert: unable to open image `/var/www/localhost/htdocs/StatWiki/Rfiles/R/0eae485868a5bc2eac2b34bcd36813a443dd6eb8_0.pdf': No such file or directory @ error/blob.c/OpenBlob/2701.
convert: no images defined `/var/www/localhost/htdocs/StatWiki/Rfiles/R/0eae485868a5bc2eac2b34bcd36813a443dd6eb8_0.pdf.png' @ error/convert.c/ConvertImageCommand/3210.
in

SP500 =readdataSK("SP500.csv", "csv") N <- length(SP500$Date); SP500[1:N,] <- SP500[N:1,] y <- ts(data=SP500[,7]); r <- diff(log(y),k=-1) n <- length(r); n.12 <- n - n%%12; r.diff.12 <- r[1:n.12] m.12 <- floor(n.12/2); f.12 <- (2*pi/n.12)*(1:m.12) r.dft.12 <- fft(r.diff.12); r.dft.12 <- r.dft.12[2:(m.12+1)] r.p.12 <- (1/(2*pi*n))*(Mod(r.dft.12))^2 plot(f.12,r.p.12,"l",xlab="",ylab="") n.years <- n.12/12 # number of full years s <- n.years*(1:6) # indices of seasonal frequencies

print(c("critical value", qchisq(0.95,12)*var(r.diff.12)/(4*pi))) print(c("sum of top 6", sum(r.p.12[s])))

print(c("critical value", qchisq(0.95,6)*var(r.diff.12)/(4*pi))) print(c("sum of top 3", sum(sort(r.p.12[s])[4:6])))

GDPC1