ESAC_calibrate {HDCD}R Documentation

Generates empirical penalty function \gamma(t) for the ESAC algorithm using Monte Carlo simulation

Description

R wrapper for C function choosing the penalty function \gamma(t) by Monte Carlo simulation, as described in Appendix B in Moen et al. (2023).

Usage

ESAC_calibrate(
  n,
  p,
  alpha = 1.5,
  K = 5,
  N = 1000,
  tol = 0.001,
  bonferroni = TRUE,
  fast = FALSE,
  rescale_variance = TRUE,
  tdf = NULL,
  debug = FALSE
)

Arguments

n

Number of observations

p

Number time series

alpha

Parameter for generating seeded intervals

K

Parameter for generating seeded intervals

N

Number of Monte Carlo samples used

tol

False error probability tolerance

bonferroni

If TRUE, a Bonferroni correction applied and the empirical penalty function \gamma(t) is chosen by simulating leading constants of r(t) through Monte Carlo simulation.

fast

If TRUE, ESAC only tests for a change-point at the midpoint of each seeded interval

rescale_variance

If TRUE, each row of the data is re-scaled by a MAD estimate using rescale_variance

tdf

If NULL, samples are drawn from a Gaussian distribution. Otherwise, they are drawn from a t distribution with tdf degrees of freedom.

debug

If TRUE, diagnostic prints are provided during execution

Value

A list containing

without_partial

a vector of values of \gamma(t) for t \in \mathcal{T} decreasing in t

with_partial

same as without_partial

as

vector of threshold values a(t) for t \in \mathcal{T} decreasing in t

nu_as

vector of conditional expectations \nu_{a(t)} of a thresholded Gaussian, for t \in \mathcal{T} decreasing in t

#'

References

Moen PAJ, Glad IK, Tveten M (2023). “Efficient sparsity adaptive changepoint estimation.” Arxiv preprint, 2306.04702, https://doi.org/10.48550/arXiv.2306.04702.

Examples

library(HDCD)
n = 50
p = 50

set.seed(100)
thresholds_emp = ESAC_calibrate(n,p, N=100, tol=1/100)
set.seed(100)
thresholds_emp_without_bonferroni = ESAC_calibrate(n,p, N=100, tol=1/100,bonferroni=FALSE)
thresholds_emp[[1]] # vector of \gamma(t) for t = p,...,1
thresholds_emp_without_bonferroni[[1]] # vector of \gamma(t) for t = p,...,1

# Generating data
X = matrix(rnorm(n*p), ncol = n, nrow=p)
# Adding a single sparse change-point:
X[1:5, 26:n] = X[1:5, 26:n] +2

res = ESAC(X, thresholds_test = thresholds_emp[[1]])
res$changepoints

[Package HDCD version 1.1 Index]