  Change point analysis is concerned with detecting and locating structure
breaks in the underlying model of a sequence of observations ordered by time,
space or other variables. A widely adopted approach for change point analysis
is to minimize an objective function with a penalty term on the number of
change points. This framework includes several well-established procedures,
such as the penalized log-likelihood using the (modified) Bayesian information
criterion (BIC) or the minimum description length (MDL). The resulting
optimization problem can be solved in polynomial time by dynamic programming or
its improved version, such as the Pruned Exact Linear Time (PELT) algorithm
(Killick, Fearnhead, and Eckley 2012). However, existing computational methods
often suffer from two primary limitations: (1) methods based on direct
implementation of dynamic programming or PELT are often time-consuming for long
data sequences due to repeated computation of the cost value over different
segments of the data sequence; (2) state-of-the-art R packages do not provide
enough flexibility for users to handle different change point settings and
models. In this work, we present the fastcpd package, aiming to provide an
efficient and versatile framework for change point detection in several
commonly encountered settings. The core of our algorithm is built upon PELT and
the sequential gradient descent method recently proposed by Zhang and Dawn
(2023). We illustrate the usage of the fastcpd package through several
examples, including mean/variance changes in a (multivariate) Gaussian
sequence, parameter changes in regression models, structural breaks in
ARMA/GARCH/VAR models, and changes in user-specified models.
