n <- 1000; time <- 1:n eps <- rnorm(n) plot(time, eps, type="l", col=2)
February 17, 2015
n <- 1000; time <- 1:n eps <- rnorm(n) plot(time, eps, type="l", col=2)
beta <- 0.1 x <- filter(eps, c(1, beta), method="convolution", sides=1) plot(time, x, type="l", col=2)
alpha <- 0.5 x <- filter(eps, alpha, method="recursive") plot(time, x, type="l", col=2)
alpha <- 1 x <- filter(eps, alpha, method="recursive") plot(time, x, type="l", col=2)
eps <- rnorm(n); beta <- 0.2 ret.today <- filter(eps, c(1, beta), method="convolution", sides=1) plot(time, ret.today, type="l", col=2)
ret.yesterday <- c(NA, ret.today[-length(ret.today)]) plot(ret.yesterday, ret.today, col=2) abline(lm(ret.today ~ ret.yesterday), col=1, lty=2)
ret.lag2 <- c(NA, ret.yesterday[-length(ret.yesterday)]) plot(ret.lag2, ret.today, col=2) abline(lm(ret.today ~ ret.lag2), col=1, lty=2)
mean(ret.today[ret.yesterday > 0], na.rm=TRUE)
[1] 0.06567127