Skip to content
Prev 365767 / 398502 Next

Bootstrap using ARIMA model

Hi David,

here is my code including what i did for the tsboot:
rm(list = ls())
library(boot)
library(tseries)
library(TTR)
library(quantmod)
library(scales)
library(forecast)
library(zoo)
library(TSA)
security<-"NFLX"
startDate<-"2012-06-01"
endDate<-"2016-10-31"
qte_list<-c("AdjClose")

data=get.hist.quote(instrument = security, startDate, endDate, quote =
qte_list,   provider = "yahoo" )

func.ar<- ar(logret)
func.model<-list(order = c(func.ar$order,0,0),ar=func.ar$ar)
func.res<- func.ar$resid[!is.na(func.ar$resid)]
func.res<-func.res - mean()
func<- function(logret,formula){
  d = logret
  return(RSI(exp(logret)))
}
func.sim<-function(res,n.sim,ran.args){
  rg1<- function(n, res) sample(res, n, replace=TRUE)
  ts.orig<-ran.args$ts
  ts.mod<-ran.args$model
  mean(ts.orig)+ts(arima.sim(model=ts.mod,n=n.sim, ran.gen=rg1,
res=as.vestor(res)))
}
myboot<-tsboot(exp(logret),func,R=500,sim="model", ran.gen=func.sim,
ran.args = List(ts=log(data[,1],model=func.sim))


Best,
Ash
On Thu, Dec 1, 2016 at 1:50 PM, Bert Gunter <bgunter.4567 at gmail.com> wrote: