Boot.FitAR: Simulate a Fitted AR

Description Usage Arguments Value Author(s) See Also Examples

Description

Simulate a realization from a fitted AR model. This is useful in the parametric bootstrap. Generic function for "Boot" method.

Usage

1
2
## S3 method for class 'FitAR'
Boot(obj, R=1, ...)

Arguments

obj

the output from FitAR

R

number of bootstrap replications

...

optional arguments

Value

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.

Author(s)

A.I. McLeod and Y. Zhang

See Also

Boot SimulateGaussianAR

Examples

 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)

FitAR documentation built on May 2, 2019, 3:22 a.m.