tsboot2: Internal 'LFL' function.

Description Usage Arguments Details Value Note Author(s) References Examples

Description

Generate R bootstrap replicates of a statistic applied to a time series. The replicate time series can be generated using fixed lengths replicates.

Usage

1
2
3
4
tsboot2(tseries, statistic, R = 100, l = NULL, n.sim = NROW(tseries),
  ran.gen = function(tser, n.sim, args) tser, ran.args = NULL,
  allow.parallel = TRUE, seed = 123, packages = NULL, export = NULL,
  ...)

Arguments

tseries

A univariate or multivariate time series.

statistic

A function which when applied to tseries returns a vector containing the statistic(s) of interest. Each time statistic is called it is passed a time series of length n.sim which is of the same class as the original tseries. Any other arguments which statistic takes must remain constant for each bootstrap replicate and should be supplied through the ... argument to tsboot2.

R

A positive integer giving the number of bootstrap replicates required.

l

l is the fixed block length used in generating the replicate time series

n.sim

The length of the simulated series.

ran.gen

This is a function of three arguments. The first argument is a time series, it is the result of selecting n.sim observations from tseries by some scheme and converting the result back into a time series of the same form as tseries (with length n.sim). The second argument to ran.gen is always the value n.sim, and the third argument is ran.args, which is used to supply any other objects needed by ran.gen.

ran.args

This will be supplied to ran.gen each time it is called. If ran.gen needs any extra arguments then they should be supplied as components of ran.args. Multiple arguments may be passed by making ran.args a list. If ran.args is NULL then it should not be used within ran.gen but note that ran.gen must still have its third argument.

allow.parallel

Logical TRUE/FALSE indicating whether parallel computation via the foreach package should be used. The default value is TRUE. OBS:paralllel backend must be registered prior to calling tsboot2.

seed

The used seed in the bootstrap replication.

packages

If allow.parallel = TRUE. A character vector with the lisf of packages required by statisitc.

export

If allow.parallel = TRUE. A character vector with the lisf of objects (functions, etc...) required by statisitc.

...

Extra argumetns to statistic may be supplied here. Beware of partial matching to the arguments of tsboot2 listed above.

seed

Numeric, the seed to set.seed() for replicable examples.

Details

This is a modified version of the tsboot of the boot package. Here, only Moving Block Bootstrap is implemented, the function is modified to return the resampled blocks and some unecessary arguments were deleted. Additionaly, the parallel option is through the doParallel package.

Value

An object of class "boot" with similar components as tsboot

Note

For bugs and further requests please refer to https://github.com/matheusbarroso/dboot

Author(s)

Matheus de Vasconcellos Barroso, matheus.vb@gmail.com

References

Angelo Canty and Brian Ripley (2017). boot: Bootstrap R (S-Plus) Functions. R package version 1.3-19.

Davison, A. C. & Hinkley, D. V. (1997) Bootstrap Methods and Their Applications. Cambridge University Press, Cambridge. ISBN 0-521-57391-2

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
## Not run: 
library(dboot)
library(gamlss)
library(doParallel)
no_cores <- if(detectCores()==1) 1 else detectCores() -1
registerDoParallel(no_cores)
bootf <- function (db,ord,fam) {
 fit2 <- garmaFit2(yt~x-1,data=db,order=ord,family=fam,tail=0,control=list(iter.max=1000))
 return(fit2$coef)}
ord <- c(1,1) ; fam="GA"
db <- example_LFL
tsboot2(db, statistic=bootf, R = 10, l = 100,ord=ord,fam=fam,export=c("garmaFit2"),package=c("gamlss"))

## End(Not run)

matheusbarroso/dboot documentation built on May 16, 2019, 8:13 p.m.