i have a problem. I hope that you will understand me. My english is not very good. I need to repeat B times (where B is at least one thousand) a R code that i write and collect the 1000 final results. I report the code:
phi=0.5
p=1
n=100
M=1000
serie1=arima.sim(model=list(ar =phi ,order=c(p,0,0)),n = n,innov=rnorm(100,0,1))
stima<-arima(serie1,order=c(p,0,0),include.mean=F)
phi.stima=stima$coef
res=stima$residual
ress=res[2:n]
res.c=ress-mean(ress)
serie.b=vector("numeric",length=n+M)
ps=round(runif(1,1,n-1))
serie.b[1]=ps
for(i in (2):(n+M))
serie.b[i]=phi.stima*serie.b[i-1]+res.c[round(runif(1,1,n-1))]
serie.bb=serie.b[(M+1):(n+M)]
serie.bb=ts(serie.bb)
stima.boot<-arima(serie.bb,order=c(1,0,0),include.mean=F)
phi.stima.boot=stima.boot$coef
phi.res.boot=stima.boot$residual
serie.bb[100]=serie1[100]
previsioni.boot=vector("numeric",length=6)
previsioni.boot[1]=serie1[100]
for(i in (2):(6))
previsioni.boot[i]=phi.stima.boot*previsioni.boot[i-1]
for(i in (2):(100+1000))
serie.b[i]=phi.stima*serie.b[i-1]+res.c[round(runif(1,1,100))]
future_obs_boot=vector("numeric",length=6)
future_obs_boot[1]=serie1[100]
for(i in (2):(6))
future_obs_boot[i]=phi.stima*future_obs_boot[i-1]+res.c[round(runif(1,1,100))]
errore.prev.boot=future_obs_boot[6]-previsioni.boot[6]
errore.prev.boot
I need to collect B values of "errore.prev.boot". How can i do it.. Please can you help me?? Greetings. Mario