# NOT RUN {
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)
# }
Run the code above in your browser using DataLab