I think my problem is easy, I just could not find a solution for it. So, I am trying to do bootstrapping in r and the results have been successful. However, I want to automate my code to make it run for 10000,15000, etc.. times without changing these variables every time.
My code is:
mydata #is a time series data
port<-as.xts(mydata, order.by = as.Date(dates, "%d-%b-%Y"))
# created a function for bootstrapping
sim<-function(nsim,series,size){
result<-replicate(nsim, Return.cumulative(sample(series,size,replace=F), geometric=TRUE))
return(result)
}
output<-sim<-(10000,port,12) # running the function
mean(output) # finding the mean of the bootstrap output
so instead of changing the nsim which is=10000 or the size =12 everytime I want to run the function, is there a way where I can loop the function to run lets say 10000, 150000,200000.
Thanks for your help!