BstrapTest {BinSegBstrap} | R Documentation |

## Bootstrap test for a single change-point

### Description

Tests whether the underlying signal is smooth or contains at least one change-point. The smooth alternative is estimated by a (crossvalidated) kernel smoother. The single change-point alternative is estimated by `estimateSingleCp`

. Its estimated jump size is used as a test statistic and the critical value is obtained by bootstrapping. More details can be found in the vignette.

### Usage

```
BstrapTest(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 |

`nbandwidth` |
a single integer giving the number of bandwidths (see above) if |

`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:

- piecewiseSignal: the estimated signal with a single change-point

- cp: the estimated change-point location

- size: the estimated jump size

- bandwidth: the selected bandwidth for the piecewise signal

- bandwidthSmooth: the selected bandwidth for the smooth signal

- smoothSignal: the estimated smooth signal

- critVal: the by bootstrapping obtained critical value

- pValue: the p-Value of the test

- outcome: a boolean saying whether the test rejects the hypothesis of a smooth signal

### Examples

```
n <- 100
signal <- sin(2 * pi * 1:n / n)
signal[51:100] <- signal[51:100] + 5
y <- rnorm(n) + signal
# default bandwidth and kernel
test <- BstrapTest(y = y)
if (test$outcome) {
# null hypothesis of a smooth signal is rejected
estimatedSignal <- test$piecewiseSignal
} else {
# null hypothesis of a smooth signal is accepted
estimatedSignal <- test$smoothSignal
}
plot(y)
lines(signal)
lines(estimatedSignal, col = "red")
# fixed bandwidth
test <- BstrapTest(y = y, bandwidth = 0.1)
# user specified kernel
kernel <- function(x) 1 - abs(x) # triangular kernel
test <- BstrapTest(y = y, kernel = kernel)
```

*BinSegBstrap*version 1.0-1 Index]