futuretest <- function(data,ETFs){
if(dim(data)[1]> 5*52){
data.tmp <- data[(dim(data)[1]-5*52):dim(data)[1],]
data <- data.tmp
}
#Run tsboot on any series using the selected block size
R <- 200 # scenario
l <- 4 # block size
n.sim <- 52*5 # length of scenario path
# perform block bootstrapping
bootstrap <- tsboot(data,mean,R=R,l=l, n.sim=n.sim,sim="fixed")
ba <- boot.array(bootstrap)
#Use index from bootstrap output to reconstruct multivariate time series
port.scen <- array(0, dim=c(R,n.sim))
for(i in 1:R){
port.scen[i,] <- cumprod(1/length(ETFs)*apply(data[ba[i,],],1,sum))
}
quantiles <- cbind(c(100000,100000,100000,100000,100000),100000*apply(port.scen,2,quantile,probs=c(.05,0.25,0.5,0.75,0.95))-1)
return(quantiles)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.