Pilliat_test_calibrate {HDCD}R Documentation

Generates detection thresholds for the Pilliat algorithm for testing for a single change-point using Monte Carlo simulation

Description

R wrapper for function choosing detection thresholds for the Dense, Partial sum and Berk-Jones statistics in the multiple change-point detection algorithm of Pilliat et al. (2023) for single change-point testing using Monte Carlo simulation. When Bonferroni==TRUE, the detection thresholds are chosen by simulating the leading constant in the theoretical detection thresholds given in Pilliat et al. (2023), similarly as described in Appendix B in Moen et al. (2023) for ESAC. When Bonferroni==TRUE, the thresholds for the Berk-Jones statistic are theoretical and not chosen by Monte Carlo simulation.

Usage

Pilliat_test_calibrate(
  n,
  p,
  N = 100,
  tol = 1/100,
  threshold_bj_const = 6,
  bonferroni = TRUE,
  rescale_variance = TRUE,
  fast = FALSE,
  debug = FALSE
)

Arguments

n

Number of observations

p

Number time series

N

Number of Monte Carlo samples used

tol

False error probability tolerance

threshold_bj_const

Leading constant for p_0 for the Berk-Jones statistic

bonferroni

If TRUE, a Bonferroni correction applied and the detection thresholds for each statistic is chosen by simulating the leading constant in the theoretical detection thresholds

rescale_variance

If TRUE, each row of the data is rescaled by a MAD estimate

fast

If FALSE, a change-point test is applied to each candidate change-point position in each interval. If FALSE, only the mid-point of each interval is considered

debug

If TRUE, diagnostic prints are provided during execution

Value

A list containing

thresholds_partial

vector of thresholds for the Partial Sum statistic (respectively for t=1,2,4,\ldots,2^{\lfloor\log_2(p)\rfloor} number of terms in the partial sum)

threshold_dense

threshold for the dense statistic

thresholds_bj

vector of thresholds for the Berk-Jones static (respectively for x=1,2,\ldots,x_0)

Examples

library(HDCD)
n = 50
p = 50

set.seed(100)
thresholds_test_emp = Pilliat_test_calibrate(n,p, bonferroni=TRUE,N=100, tol=1/100)
set.seed(100)
thresholds_test_emp_without_bonferroni = Pilliat_test_calibrate(n,p, 
                                         bonferroni=FALSE,N=100, tol=1/100)
thresholds_test_emp # thresholds with bonferroni correction
thresholds_test_emp_without_bonferroni # thresholds without bonferroni correction

# Generating data
X = matrix(rnorm(n*p), ncol = n, nrow=p)
Y = matrix(rnorm(n*p), ncol = n, nrow=p)

# Adding a single sparse change-point to X (and not Y):
X[1:5, 25:50] = X[1:5, 25:50] +2
resX = Pilliat_test(X, 
                    threshold_dense=thresholds_test_emp$threshold_dense, 
                    thresholds_bj = thresholds_test_emp$thresholds_bj, 
                    thresholds_partial = thresholds_test_emp$thresholds_partial
)
resX
resY = Pilliat_test(Y, 
                    threshold_dense=thresholds_test_emp$threshold_dense, 
                    thresholds_bj = thresholds_test_emp$thresholds_bj, 
                    thresholds_partial = thresholds_test_emp$thresholds_partial
)
resY

[Package HDCD version 1.1 Index]