This function estimates changepoints for each target_id. The assumed
trajectory type for this modelling stage is initially constant followed by
a changepoint into thin-plate smoothing spline.
By default, candidate time points are limited to the discrete observed values
in the series, since, despite the use of smoothing constraints,
there is generally insufficient information to infer the timing of
changepoints beyond the temporal resolution of the data. In any case, the
candidate points can be set manually using the cps argument.
To estimate changepoints, a model is fit for each candidate changepoint and
generalised cross-validation (GCV, default) or the Akaike Information
Criterion (AIC) are used to select among them. Model-selection uncertainty
is dealt with by computing the one-standard-error rule, which identifies the
least complex model within one standard error of the best scoring model.
Both the minimum and the one-standard-error (default) models are stored in the returned
slot "changepoints" so that either can be used. In addition to these, this function also computes the
probability (denoted p_mvn) that the null model is the best scoring model, using a simulation
based approach based on the multivariate normal model of the pointwise
model scores.
Given the computational cost of fitting a separate model for each candidate
changepoint, cpam only estimates changepoints for targets associated with
'significant' genes at the chosen threshold deg_threshold.