Learn R Programming

fChange (version 2.1.0)

confidence_interval: Change Point Confidence Intervals

Description

Compute confidence intervals for the data based on some changes. The current version is tuned to mean changes.

Usage

confidence_interval(
  X,
  changes,
  K = bartlett_kernel,
  h = 2 * ncol(X)^(1/5),
  weighting = 0.5,
  M = 5000,
  alpha = 0.1,
  method = "distribution"
)

Value

Data.frame with the first column for the changes, second for the lower bounds of confidence intervals, and the third for the upper bounds of confidence intervals.

Arguments

X

A dfts object or data which can be automatically converted to that format. See dfts().

changes

Numeric vector for detected change points.

K

Function for the Kernel. Default is bartlett_kernel.

h

Numeric for bandwidth in computation of long run variance. The default is \(2N^{1/5}\).

weighting

Weighting for the interval computation, value in [0,1]. Default is 0.5.

M

Numeric for the number of Brownian motion simulations in computation of the confidence interval. Default is 1000.

alpha

Numeric for the significance level, in [0,1]. Default is 0.1.

method

String to indicate the method for computing the percentiles used in the confidence intervals. The options are 'distribution' and 'simulation'. Default is 'distribution'.

References

Horvath, L., & Rice, G. (2024). Change Point Analysis for Time Series (First edition.). Springer.

Aue, A., Rice, G., & Sonmez, O. (2018). Detecting and dating structural breaks in functional data without dimension reduction. Journal of the Royal Statistical Society. Series B, Statistical Methodology, 80(3), 509-529.

Examples

Run this code
X <- cbind(
  generate_brownian_motion(100, v = seq(0, 1, 0.05))$data,
  generate_brownian_motion(100, v = seq(0, 1, 0.05))$data + 0.5
)
confidence_interval(X, 100, alpha = 0.1)
confidence_interval(X, changes = 100, alpha = 0.1, method = "simulation")

X <- generate_brownian_motion(200, v = seq(0, 1, 0.05))
confidence_interval(X, 100)
confidence_interval(X, 100, method = "simulation")

X <- cbind(
  generate_brownian_motion(200, v = seq(0, 1, 0.05))$data,
  generate_brownian_motion(100, v = seq(0, 1, 0.05))$data + 0.1,
  generate_brownian_motion(150, v = seq(0, 1, 0.05))$data - 0.05
)
confidence_interval(X, c(200, 300))

confidence_interval(X = electricity, changes = c(64, 120), alpha = 0.1)

Run the code above in your browser using DataLab