BinSegBstrap {BinSegBstrap}R Documentation

Estimates a piecewise smooth signal

Description

A piecewise smooth signal is estimated by applying BstrapTest recursively (binary segmentation approach). The final estimator is estimated by kernel smoothing on each segment separately; a joint bandwidth is selected by crossvalidation. More details can be found in the vignette.

Usage

BinSegBstrap(y, bandwidth, nbandwidth = 30L, B = 500L, alpha = 0.05,
             kernel = c("epanechnikov", "gaussian", "rectangular",
                        "triangular", "biweight", "silverman"))

Arguments

y

a numeric vector containing the data points

bandwidth

the bandwidth, i.e. a numeric with values between 1 / length(y) and 0.5. If missing exp(seq(log(10 / length(y)), log(0.25), length.out = nbandwidth)) will be used. Crossvalidation will be performed if it is not a single numeric. Note that the test has almost no power when the bandwidth for the kernel smoother is too small, since then a change-point can be approximated well by a quickly changing smooth function.

nbandwidth

a single integer giving the number of bandwidths (see above) if bandwidth is missing

B

a single integer giving the number of bootstrap samples

alpha

a probability, i.e. a single numeric between 0 and 1, giving the significance level of the test

kernel

the kernel function, i.e. either a string or a function that takes a single numeric vector and returns the values of the kernel at those locations

Value

a list with the following components:
- est: the estimated signal
- cps: the estimated change-point locations
- bandwidth: the selected bandwidth

Examples

n <- 200
signal <- sin(2 * pi * 1:n / n)
signal[51:100] <- signal[51:100] + 5
signal[151:200] <- signal[151:200] + 5

y <- rnorm(n) + signal

# default bandwidth and kernel
est <- BinSegBstrap(y = y)

plot(y)
lines(signal)
lines(est$est, col = "red")

# fixed bandwidth
est <- BinSegBstrap(y = y, bandwidth = 0.1)

# user specified kernel
kernel <- function(x) 1 - abs(x) # triangular kernel
est <- BinSegBstrap(y = y, kernel = kernel)

[Package BinSegBstrap version 1.0-1 Index]