Description Usage Arguments Value Author(s) See Also Examples
Simulate a realization from a fitted AR model. This is useful in the parametric bootstrap. Generic function for "Boot" method.
1 2 |
obj |
the output from FitAR |
R |
number of bootstrap replications |
... |
optional arguments |
A simulated time series with the same length as the original fitted time series is produced when R=1. When R>1, a matrix with R columns is produced with each column a separate bootstrap realization.
A.I. McLeod and Y. Zhang
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 | #Plot log(lynx) time series and simulation
#
ans <- FitAR(log(lynx), 8)
z<-Boot.FitAR(ans)
par(mfrow=c(2,1))
TimeSeriesPlot(log(lynx))
title(main="log(lynx) time series")
TimeSeriesPlot(z)
title(main="Simulated AR(8), fitted to log lynx")
#par(mfrow=c(1,1)
#
#Use bootstrap to compute standard errors of parameters
#takes about 18 seconds on a 3.6 GHz PC
## Not run:
ptm <- proc.time() #user time
R<-100 #number of bootstrap iterations
p<-c(1,2,4,7,10,11)
ans<-FitAR(log(lynx),p)
out<-Boot(ans, R)
fn<-function(z) GetFitARz(z,p)$zetaHat
sdBoot<-sqrt(diag(var(t(apply(out,fn,MARGIN=2)))))
sdLargeSample<-coef(ans)[,2][1:6]
sd<-matrix(c(sdBoot,sdLargeSample),ncol=2)
dimnames(sd)<-list(names(sdLargeSample),c("Bootstrap","LargeSample"))
ptm<-(proc.time()-ptm)[1]
sd
## End(Not run)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.