In this tutorial, we demonstrate basic use of the ChangepointInference package.
Installation instructions are provided here.
First load the package:
To illustrate the software, we generate a synthetic dataset according to
and assume that $\mu_1,\ldots,\mu_T$ is piecewise constant, in the sense that $\mu_{\tau_j+1}=\mu_{\tau_j + 2 } = \ldots = \mu_{\tau_{j+1}}$, $\mu_{\tau_{j+1}} \neq \mu_{\tau_{j+1}+1}$, for $j=0,\ldots,K-1$, where $0 = \tau_{0} < \tau_{1} < \ldots < \tau_{K} < \tau_{K+1} = T$, and where $\tau_1,\ldots,\tau_K$ represent the true changepoints.
Changepoint estimation
Estimate changepoints using $\ell_0$ segmentation and with tuning parameter $\lambda = 4$:
The fit object contains model fit information:
Importantly, the estimated changepoints are
Estimate changepoints using binary segmentation with $K = 2$ changepoints:
The fit object contains model fit information:
Importantly the sorted changepoints, the order changepoints were estimated, and the sign of the change in mean due to a changepoint (in same order as fit$ordered_change_pts) are:
In particular, we note that in this example, the first changepoint is estimated at time point $200$ and at this point the sign of the change in mean is negative. This is expected as the mean of $y_{201:300}$ is less than the mean of $y_{1:200}$.
Changepoint Inference
In this section we demonstrate how to use our software to obtain $p$-values for the following test statistics and conditioning sets. For the fixed window tests, we take the window size $h = 10$.