Title: | Moving Sum Based Procedures for Changes in the Mean |
---|---|
Description: | Implementations of MOSUM-based statistical procedures and algorithms for detecting multiple changes in the mean. This comprises the MOSUM procedure for estimating multiple mean changes from Eichinger and Kirch (2018) <doi:10.3150/16-BEJ887> and the multiscale algorithmic extension from Cho and Kirch (2022) <doi:10.1007/s10463-021-00811-5>, as well as the bootstrap procedure for generating confidence intervals about the locations of change points as proposed in Cho and Kirch (2022) <doi:10.1016/j.csda.2022.107552>. See also Meier, Kirch and Cho (2021) <doi:10.18637/jss.v097.i08> which accompanies the R package. |
Authors: | Alexander Meier [aut], Haeran Cho [aut, cre], Claudia Kirch [aut] |
Maintainer: | Haeran Cho <[email protected]> |
License: | GPL (>= 3) |
Version: | 1.2.7 |
Built: | 2025-02-05 03:09:38 UTC |
Source: | https://github.com/cran/mosum |
Create bandwidths according to a default function of the sample size
bandwidths.default(n, d.min = 10, G.min = 10, G.max = min(n/2, n^(2/3)))
bandwidths.default(n, d.min = 10, G.min = 10, G.max = min(n/2, n^(2/3)))
n |
integer representing the sample size |
d.min |
integer for the minimal mutual distance of change points that can be expected |
G.min |
integer for the minimal allowed bandwidth |
G.max |
integer for the maximal allowed bandwidth |
Returns an integer vector of bandwidths (G_1,...,G_m),
with G_0 = G_1 = max(G.min
, 2/3*d.min
), G_j+1 = G_j-1 + G_j (for j = 1, ..., m-1)
and m satisfying G_m <= G.max
while G_m+1 > G.max
.
an integer vector of bandwidths
A. Meier, C. Kirch and H. Cho (2021) mosum: A Package for Moving Sums in Change-point Analysis. Journal of Statistical Software, Volume 97, Number 8, pp. 1-42. <doi:10.18637/jss.v097.i08>.
H. Cho and C. Kirch (2022) Two-stage data segmentation permitting multiscale change points, heavy tails and dependence. Annals of the Institute of Statistical Mathematics, Volume 74, Number 4, pp. 653-684.
bandwidths.default(1000, 10, 10, 200)
bandwidths.default(1000, 10, 10, 200)
Generate bootstrap confidence intervals for change points.
## S3 method for class 'mosum.cpts' confint(object, parm = "cpts", level = 0.05, N_reps = 1000, ...)
## S3 method for class 'mosum.cpts' confint(object, parm = "cpts", level = 0.05, N_reps = 1000, ...)
object |
an object of class |
parm |
specification of which parameters are to be given confidence intervals; |
level |
numeric value in (0, 1), such that the |
N_reps |
number of bootstrap replications |
... |
not in use |
See the referenced literature for further details
S3 object of class cpts.ci
, containing the following fields:
level , N_reps
|
input parameters |
CI |
data frame of five columns,
containing the estimated change points (column |
A. Meier, C. Kirch and H. Cho (2021) mosum: A Package for Moving Sums in Change-point Analysis. Journal of Statistical Software, Volume 97, Number 8, pp. 1-42. <doi:10.18637/jss.v097.i08>.
H. Cho and C. Kirch (2022) Bootstrap confidence intervals for multiple change points based on moving sum procedures. Computational Statistics & Data Analysis, Volume 175, pp. 107552.
x <- testData(lengths = rep(100, 3), means = c(0, 3, 1), sds = rep(1, 3), seed = 1337)$x m <- mosum(x, G = 40) ci <- confint(m, N_reps = 5000) print(ci$CI)
x <- testData(lengths = rep(100, 3), means = c(0, 3, 1), sds = rep(1, 3), seed = 1337)$x m <- mosum(x, G = 40) ci <- confint(m, N_reps = 5000) print(ci$CI)
Generate bootstrap confidence intervals for change points.
## S3 method for class 'multiscale.cpts' confint(object, parm = "cpts", level = 0.05, N_reps = 1000, ...)
## S3 method for class 'multiscale.cpts' confint(object, parm = "cpts", level = 0.05, N_reps = 1000, ...)
object |
an object of class |
parm |
specification of which parameters are to be given confidence intervals; |
level |
numeric value in (0, 1), such that the |
N_reps |
number of bootstrap replications |
... |
not in use |
See the referenced literature for further details
S3 object of class cpts.ci
, containing the following fields:
level , N_reps
|
input parameters |
CI |
data frame of five columns,
containing the estimated change points (column |
A. Meier, C. Kirch and H. Cho (2021) mosum: A Package for Moving Sums in Change-point Analysis. Journal of Statistical Software, Volume 97, Number 8, pp. 1-42. <doi:10.18637/jss.v097.i08>.
H. Cho and C. Kirch (2022) Bootstrap confidence intervals for multiple change points based on moving sum procedures. Computational Statistics & Data Analysis, Volume 175, pp. 107552.
x <- testData(lengths = rep(100, 3), means = c(0, 3, 1), sds = rep(1, 3), seed = 1337)$x mlp <- multiscale.localPrune(x, G = c(8, 15, 30, 70)) ci <- confint(mlp, N_reps = 5000) print(ci$CI)
x <- testData(lengths = rep(100, 3), means = c(0, 3, 1), sds = rep(1, 3), seed = 1337)$x mlp <- multiscale.localPrune(x, G = c(8, 15, 30, 70)) ci <- confint(mlp, N_reps = 5000) print(ci$CI)
Computes the MOSUM detector, detects (multiple) change points and estimates their locations.
mosum( x, G, G.right = G, var.est.method = c("mosum", "mosum.min", "mosum.max", "custom")[1], var.custom = NULL, boundary.extension = TRUE, threshold = c("critical.value", "custom")[1], alpha = 0.1, threshold.custom = NULL, criterion = c("eta", "epsilon")[1], eta = 0.4, epsilon = 0.2, do.confint = FALSE, level = 0.05, N_reps = 1000 )
mosum( x, G, G.right = G, var.est.method = c("mosum", "mosum.min", "mosum.max", "custom")[1], var.custom = NULL, boundary.extension = TRUE, threshold = c("critical.value", "custom")[1], alpha = 0.1, threshold.custom = NULL, criterion = c("eta", "epsilon")[1], eta = 0.4, epsilon = 0.2, do.confint = FALSE, level = 0.05, N_reps = 1000 )
x |
input data (a |
G |
an integer value for the moving sum bandwidth;
|
G.right |
if |
var.est.method |
how the variance is estimated; possible values are
|
var.custom |
a numeric vector (of the same length as |
boundary.extension |
a logical value indicating whether the boundary values should be filled-up with CUSUM values |
threshold |
string indicating which threshold should be used to determine significance.
By default, it is chosen from the asymptotic distribution at the given significance level |
alpha |
a numeric value for the significance level with
|
threshold.custom |
a numeric value greater than 0 for the threshold of significance;
use iff |
criterion |
string indicating how to determine whether each point
|
eta |
a positive numeric value for the minimal mutual distance of
changes, relative to moving sum bandwidth (iff |
epsilon |
a numeric value in (0,1] for the minimal size of exceeding
environments, relative to moving sum bandwidth (iff |
do.confint |
flag indicating whether to compute the confidence intervals for change points |
level |
use iff |
N_reps |
use iff |
S3 object of class mosum.cpts
, which contains the following fields:
x |
input data |
G.left , G.right
|
left and right summation bandwidths |
var.est.method , var.custom , boundary.extension
|
input parameters |
stat |
a series of MOSUM statistic values; the first |
rollsums |
a series of MOSUM detector values; equals |
var.estimation |
the local variance estimated according to |
threshold , alpha , threshold.custom
|
input parameters |
threshold.value |
threshold value of the corresponding MOSUM test |
criterion , eta , epsilon
|
input parameters |
cpts |
a vector containing the estimated change point locations |
cpts.info |
data frame containing information about change point estimators including detection bandwidths, asymptotic p-values for the corresponding MOSUM statistics and (scaled) size of jumps |
do.confint |
input parameter |
ci |
S3 object of class |
A. Meier, C. Kirch and H. Cho (2021) mosum: A Package for Moving Sums in Change-point Analysis. Journal of Statistical Software, Volume 97, Number 8, pp. 1-42. <doi:10.18637/jss.v097.i08>.
B. Eichinger and C. Kirch (2018) A MOSUM procedure for the estimation of multiple random change-points. Bernoulli, Volume 24, Number 1, pp. 526-564.
H. Cho and C. Kirch (2022) Bootstrap confidence intervals for multiple change points based on moving sum procedures. Computational Statistics & Data Analysis, Volume 175, pp. 107552.
x <- testData(lengths = rep(100, 3), means = c(0, 5, -2), sds = rep(1, 3), seed = 1234)$x m <- mosum(x, G = 40) plot(m) summary(m)
x <- testData(lengths = rep(100, 3), means = c(0, 5, -2), sds = rep(1, 3), seed = 1234)$x m <- mosum(x, G = 40) plot(m) summary(m)
Computes the asymptotic critical value for the MOSUM test.
mosum.criticalValue(n, G.left, G.right, alpha)
mosum.criticalValue(n, G.left, G.right, alpha)
n |
an integer value for the length of the input data |
G.left , G.right
|
integer values for the left and right moving sum bandwidth (G.left, G.right) |
alpha |
a numeric value for the significance level with
|
a numeric value for the asymptotic critical value for the MOSUM test
x <- testData(lengths = rep(100, 3), means = c(0, 5, -2), sds = rep(1, 3), seed = 1234)$x m <- mosum(x, G = 40) par(mfrow = c(2, 1)) plot(m$stat, type = "l", xlab = "Time", ylab = "", main = "mosum") abline(h = mosum.criticalValue(300, 40, 40, .1), col = 4) abline(v = m$cpts, col = 2) plot(m, display = "mosum") # identical plot is produced
x <- testData(lengths = rep(100, 3), means = c(0, 5, -2), sds = rep(1, 3), seed = 1234)$x m <- mosum(x, G = 40) par(mfrow = c(2, 1)) plot(m$stat, type = "l", xlab = "Time", ylab = "", main = "mosum") abline(h = mosum.criticalValue(300, 40, 40, .1), col = 4) abline(v = m$cpts, col = 2) plot(m, display = "mosum") # identical plot is produced
Multiscale MOSUM procedure with symmetric bandwidths combined with bottom-up bandwidth-based merging.
multiscale.bottomUp( x, G = bandwidths.default(length(x), G.min = max(20, ceiling(0.05 * length(x)))), threshold = c("critical.value", "custom")[1], alpha = 0.1, threshold.function = NULL, eta = 0.4, do.confint = FALSE, level = 0.05, N_reps = 1000, ... )
multiscale.bottomUp( x, G = bandwidths.default(length(x), G.min = max(20, ceiling(0.05 * length(x)))), threshold = c("critical.value", "custom")[1], alpha = 0.1, threshold.function = NULL, eta = 0.4, do.confint = FALSE, level = 0.05, N_reps = 1000, ... )
x |
input data (a |
G |
a vector of (symmetric) bandwidths, given as either integers less than |
threshold |
string indicating which threshold should be used to determine significance.
By default, it is chosen from the asymptotic distribution at the given significance level |
alpha |
a numeric value for the significance level with
|
threshold.function |
function object of form |
eta |
see mosum |
do.confint |
flag indicating whether to compute the confidence intervals for change points |
level |
use iff |
N_reps |
use iff |
... |
further arguments to be passed to the mosum calls |
See Algorithm 1 in the first referenced paper for a comprehensive description of the procedure and further details.
S3 object of class multiscale.cpts
, which contains the following fields:
x |
input data |
cpts |
estimated change points |
cpts.info |
data frame containing information about estimated change points |
pooled.cpts |
set of change point candidates that have been considered by the algorithm |
G |
bandwidths |
threshold , alpha , threshold.function
|
input parameters |
eta |
input parameters |
do.confint |
input parameter |
ci |
object of class |
A. Meier, C. Kirch and H. Cho (2021) mosum: A Package for Moving Sums in Change-point Analysis. Journal of Statistical Software, Volume 97, Number 8, pp. 1-42. <doi:10.18637/jss.v097.i08>.
M. Messer et al. (2014) A multiple filter test for the detection of rate changes in renewal processes with varying variance. The Annals of Applied Statistics, Volume 8, Number 4, pp. 2027-2067.
H. Cho and C. Kirch (2022) Bootstrap confidence intervals for multiple change points based on moving sum procedures. Computational Statistics & Data Analysis, Volume 175, pp. 107552.
x1 <- testData(lengths = c(100, 200, 300, 300), means = c(0, 1, 2, 2.7), sds = rep(1, 4), seed = 123)$x mbu1 <- multiscale.bottomUp(x1) plot(mbu1) summary(mbu1) x2 <- testData(model = "mix", seed = 1234)$x threshold.custom <- function(G, n, alpha) { mosum.criticalValue(n, G, G, alpha) * log(n/G)^0.1 } mbu2 <- multiscale.bottomUp(x2, G = 10:40, threshold = "custom", threshold.function = threshold.custom) plot(mbu2) summary(mbu2)
x1 <- testData(lengths = c(100, 200, 300, 300), means = c(0, 1, 2, 2.7), sds = rep(1, 4), seed = 123)$x mbu1 <- multiscale.bottomUp(x1) plot(mbu1) summary(mbu1) x2 <- testData(model = "mix", seed = 1234)$x threshold.custom <- function(G, n, alpha) { mosum.criticalValue(n, G, G, alpha) * log(n/G)^0.1 } mbu2 <- multiscale.bottomUp(x2, G = 10:40, threshold = "custom", threshold.function = threshold.custom) plot(mbu2) summary(mbu2)
Multiscale MOSUM procedure with (possibly) assymetric bandwidths and localised pruning based on Schwarz criterion.
multiscale.localPrune( x, G = bandwidths.default(length(x)), max.unbalance = 4, threshold = c("critical.value", "custom")[1], alpha = 0.1, threshold.function = NULL, criterion = c("eta", "epsilon")[1], eta = 0.4, epsilon = 0.2, rule = c("pval", "jump")[1], penalty = c("log", "polynomial")[1], pen.exp = 1.01, do.confint = FALSE, level = 0.05, N_reps = 1000, ... )
multiscale.localPrune( x, G = bandwidths.default(length(x)), max.unbalance = 4, threshold = c("critical.value", "custom")[1], alpha = 0.1, threshold.function = NULL, criterion = c("eta", "epsilon")[1], eta = 0.4, epsilon = 0.2, rule = c("pval", "jump")[1], penalty = c("log", "polynomial")[1], pen.exp = 1.01, do.confint = FALSE, level = 0.05, N_reps = 1000, ... )
x |
input data (a |
G |
a vector of bandwidths, given as either integers less than |
max.unbalance |
a numeric value for the maximal ratio between maximal and minimal bandwidths to be used for candidate generation,
|
threshold |
string indicating which threshold should be used to determine significance.
By default, it is chosen from the asymptotic distribution at the significance level |
alpha |
a numeric value for the significance level with
|
threshold.function |
function object of form |
criterion |
how to determine whether an exceeding point is a change point; to be parsed to mosum |
eta , epsilon
|
see mosum |
rule |
string for the choice of sorting criterion for change point candidates in merging step. Possible values are:
|
penalty |
string specifying the type of penalty term to be used in Schwarz criterion; possible values are:
|
pen.exp |
exponent for the penalty term (see |
do.confint |
flag indicating whether confidence intervals for change points should be computed |
level |
use iff |
N_reps |
use iff |
... |
further arguments to be parsed to mosum calls |
See Algorithm 2 in the first referenced paper for a comprehensive description of the procedure and further details.
S3 object of class multiscale.cpts
, which contains the following fields:
x |
input data |
cpts |
estimated change points |
cpts.info |
data frame containing information about estimated change points |
sc |
Schwarz criterion values of the estimated change point set |
pooled.cpts |
set of change point candidates that have been considered by the algorithm |
G |
input parameter |
threshold , alpha , threshold.function
|
input parameters |
criterion , eta , epsilon
|
input parameters |
rule , penalty , pen.exp
|
input parameters |
do.confint |
input parameter |
ci |
object of class |
A. Meier, C. Kirch and H. Cho (2021) mosum: A Package for Moving Sums in Change-point Analysis. Journal of Statistical Software, Volume 97, Number 8, pp. 1-42. <doi:10.18637/jss.v097.i08>.
H. Cho and C. Kirch (2022) Two-stage data segmentation permitting multiscale change points, heavy tails and dependence. Annals of the Institute of Statistical Mathematics, Volume 74, Number 4, pp. 653-684.
H. Cho and C. Kirch (2022) Bootstrap confidence intervals for multiple change points based on moving sum procedures. Computational Statistics & Data Analysis, Volume 175, pp. 107552.
x <- testData(model = "mix", seed = 123)$x mlp <- multiscale.localPrune(x, G = c(8, 15, 30, 70), do.confint = TRUE) print(mlp) summary(mlp) par(mfcol=c(2, 1), mar = c(2, 4, 2, 2)) plot(mlp, display = "data", shaded = "none") plot(mlp, display = "significance", shaded = "CI", CI = "unif")
x <- testData(model = "mix", seed = 123)$x mlp <- multiscale.localPrune(x, G = c(8, 15, 30, 70), do.confint = TRUE) print(mlp) summary(mlp) par(mfcol=c(2, 1), mar = c(2, 4, 2, 2)) plot(mlp, display = "data", shaded = "none") plot(mlp, display = "significance", shaded = "CI", CI = "unif")
3D Visualisation of multiscale MOSUM statistics.
persp3D.multiscaleMosum( x, mosum.args = list(), threshold = c("critical.value", "custom")[1], alpha = 0.1, threshold.function = NULL, pal.name = "YlOrRd", expand = 0.2, theta = 120, phi = 20, xlab = "G", ylab = "time", zlab = "MOSUM", ticktype = "detailed", NAcol = "#800000FF", ... )
persp3D.multiscaleMosum( x, mosum.args = list(), threshold = c("critical.value", "custom")[1], alpha = 0.1, threshold.function = NULL, pal.name = "YlOrRd", expand = 0.2, theta = 120, phi = 20, xlab = "G", ylab = "time", zlab = "MOSUM", ticktype = "detailed", NAcol = "#800000FF", ... )
x |
a numeric input data vector |
mosum.args |
a named list containing further arguments
to be parsed to the respective |
threshold |
string indicating which threshold should be used for normalisation of
MOSUM statistics computed with different bandwidths.
By default, it is chosen from the asymptotic distribution at the given significance level |
alpha |
a numeric value for the significance level with
|
threshold.function |
function object of form |
pal.name |
a string containing the name of the ColorBrewer palette to be used;
sequential palettes are recommended.
See |
expand |
expansion factor applied to the z coordinates |
theta |
azimuthal angle defining the viewing direction |
phi |
colatitude angle defining the viewing direction |
xlab , ylab , zlab , ticktype
|
graphical parameters |
NAcol |
coloring parameter |
... |
further arguments to be passed to function call of persp3D |
The visualisation is based on persp3D.
MOSUM statistics computed with different bandwidths are rescaled
for making them visually comparable.
Rescaling is done either by dividing by their respective critical value at the significance level alpha
(iff threshold = "critical.value"
) or by a custom value given by threshold.function
(iff threshold = "custom"
).
By default, clim
argument of persp3D is given so that the three lightest
(for sequential palettes) hues indicate insignificance of the corresponding MOSUM statistics,
while darker hues indicate the presence of significant changes.
see persp3D
## Not run: # If you run the example be aware that this may take some time print("example may take some time to run") x <- testData(model = "blocks", seed = 1234)$x persp3D.multiscaleMosum(x, mosum.args = list(boundary.extension = FALSE)) ## End(Not run)
## Not run: # If you run the example be aware that this may take some time print("example may take some time to run") x <- testData(model = "blocks", seed = 1234)$x persp3D.multiscaleMosum(x, mosum.args = list(boundary.extension = FALSE)) ## End(Not run)
Plotting method for S3 objects of class mosum.cpts
## S3 method for class 'mosum.cpts' plot( x, display = c("data", "mosum")[1], cpts.col = "red", critical.value.col = "blue", xlab = "Time", ... )
## S3 method for class 'mosum.cpts' plot( x, display = c("data", "mosum")[1], cpts.col = "red", critical.value.col = "blue", xlab = "Time", ... )
x |
a |
display |
which to be plotted against the change point estimators; possible values are
|
cpts.col |
a specification for the color of the vertical lines at the change point estimators, see par |
critical.value.col |
a specification for the color of the horizontal line
indicating the critical value, see par; use iff |
xlab |
graphical parameter |
... |
The location of each change point estimator is plotted as a vertical line
against the input time series and the estimated piecewise constant signal (display = "data"
)
or MOSUM detector values (display = "mosum"
).
x <- testData(lengths = rep(100, 3), means = c(0, 5, -2), sds = rep(1, 3), seed = 1234)$x m <- mosum(x, G = 40) par(mfrow = c(2, 1), mar = c(2.5, 2.5, 2.5, .5)) plot(m, display = "data") plot(m, display = "mosum")
x <- testData(lengths = rep(100, 3), means = c(0, 5, -2), sds = rep(1, 3), seed = 1234)$x m <- mosum(x, G = 40) par(mfrow = c(2, 1), mar = c(2.5, 2.5, 2.5, .5)) plot(m, display = "data") plot(m, display = "mosum")
Plotting method for S3 objects of class "multiscale.cpts".
## S3 method for class 'multiscale.cpts' plot( x, display = c("data", "significance")[1], shaded = c("CI", "bandwidth", "none")[1], level = 0.05, N_reps = 1000, CI = c("pw", "unif")[1], xlab = "Time", ... )
## S3 method for class 'multiscale.cpts' plot( x, display = c("data", "significance")[1], shaded = c("CI", "bandwidth", "none")[1], level = 0.05, N_reps = 1000, CI = c("pw", "unif")[1], xlab = "Time", ... )
x |
a |
display |
which to be plotted against the estimated change point locations; possible values are
|
shaded |
string indicating which to display as shaded areas surrounding the estimated change point locations. Poissble values are
|
level , N_reps
|
argument to be parsed to confint.multiscale.cpts; use iff |
CI |
string indicating whether pointwise ( |
xlab |
graphical parameter |
... |
not in use |
The locations of change point estimators are plotted
against the input time series and the estimated piecewise constant signal (display = "data"
), or
the significance of each estimator is represented by the corresponding
1-p.value
derived from the asymptotic distribution of MOSUM test statistic (display = "significance"
).
It also produces the rectangles representing the
detection intervals (if shaded = "bandwidth"
) or
bootstrap confidence intervals of the corresponding change points (if shaded = "CI"
)
around their locations.
x <- testData(model = "blocks", seed = 1234)$x mlp <- multiscale.localPrune(x) par(mfrow = c(2, 1)) plot(mlp, display = "data", shaded = "bandwidth") plot(mlp, display = "significance", shaded = "CI")
x <- testData(model = "blocks", seed = 1234)$x mlp <- multiscale.localPrune(x) par(mfrow = c(2, 1)) plot(mlp, display = "data", shaded = "bandwidth") plot(mlp, display = "significance", shaded = "CI")
Print method for objects of class mosum.cpts
## S3 method for class 'mosum.cpts' print(x, ...)
## S3 method for class 'mosum.cpts' print(x, ...)
x |
a |
... |
not in use |
x <- testData(lengths = rep(100, 3), means = c(0, 5, -2), sds = rep(1, 3), seed = 1234)$x m <- mosum(x, G = 40) print(m)
x <- testData(lengths = rep(100, 3), means = c(0, 5, -2), sds = rep(1, 3), seed = 1234)$x m <- mosum(x, G = 40) print(m)
Print method for objects of class multiscale.cpts
## S3 method for class 'multiscale.cpts' print(x, ...)
## S3 method for class 'multiscale.cpts' print(x, ...)
x |
a |
... |
not in use |
x <- testData(model = "mix", seed = 12345)$x mlp <- multiscale.localPrune(x) print(mlp)
x <- testData(model = "mix", seed = 12345)$x mlp <- multiscale.localPrune(x) print(mlp)
Summary method for objects of class mosum.cpts
## S3 method for class 'mosum.cpts' summary(object, ...)
## S3 method for class 'mosum.cpts' summary(object, ...)
object |
a |
... |
not in use |
Provide information about each estimated change point,
including the bandwidths used for its estimation, associated p-value and (scaled) jump size;
if object$do.confint=TRUE
, end points of the pointwise and uniform confidence intervals
are also provided.
x <- testData(lengths = rep(100, 3), means = c(0, 5, -2), sds = rep(1, 3), seed = 1234)$x m <- mosum(x, G = 40, do.confint = TRUE) summary(m)
x <- testData(lengths = rep(100, 3), means = c(0, 5, -2), sds = rep(1, 3), seed = 1234)$x m <- mosum(x, G = 40, do.confint = TRUE) summary(m)
Summary method for objects of class multiscale.cpts
## S3 method for class 'multiscale.cpts' summary(object, ...)
## S3 method for class 'multiscale.cpts' summary(object, ...)
object |
a |
... |
not in use |
Provide information about each estimated change point,
including the bandwidths used for its detection, associated p-value and (scaled) jump size;
if object$do.confint=TRUE
, end points of the pointwise and uniform confidence intervals
are also provided.
x <- testData(model = "mix", seed = 12345)$x mlp <- multiscale.localPrune(x, do.confint = TRUE) summary(mlp)
x <- testData(model = "mix", seed = 12345)$x mlp <- multiscale.localPrune(x, do.confint = TRUE) summary(mlp)
Generate piecewise stationary time series with independent innovations and change points in the mean.
testData( model = c("custom", "blocks", "fms", "mix", "stairs10", "teeth10")[1], lengths = NULL, means = NULL, sds = NULL, rand.gen = rnorm, seed = NULL, ... )
testData( model = c("custom", "blocks", "fms", "mix", "stairs10", "teeth10")[1], lengths = NULL, means = NULL, sds = NULL, rand.gen = rnorm, seed = NULL, ... )
model |
a string indicating from which model a realisation is to be generated;
possible values are "custom" (for user-specified model
using |
lengths |
use iff |
means |
use iff |
sds |
use iff |
rand.gen |
optional; a function to generate the noise/innovations |
seed |
optional; if a seed value is provided ( |
... |
further arguments to be parsed to |
See Appendix B in the reference for details about the test signals.
a list containing the following entries:
x a numeric vector containing a realisation of the piecewise time series model, given as signal + noise
mu mean vector of piecewise stationary time series model
sigma scaling vector of piecewise stationary time series model
cpts a vector of change points in the piecewise stationary time series model
P. Fryzlewicz (2014) Wild Binary Segmentation for Multiple Change-Point Detection. The Annals of Statistics, Volume 42, Number 6, pp. 2243-2281.
# visualise estimated changepoints by solid vertical lines # and true changepoints by broken vertical lines td <- testData(lengths = c(50, 50, 200, 300, 300), means = c(0, 1, 2, 3, 2.3), sds = rep(1, 5), seed = 123) mbu <- multiscale.bottomUp(td$x) plot(mbu, display = "data") abline(v = td$cpts, col = 2, lwd = 2, lty = 2) # visualise estimated piecewise constant signal by solid line # and true signal by broken line td <- testData("blocks", seed = 123) mlp <- multiscale.localPrune(td$x) plot(mlp, display = "data") lines(td$mu, col = 2, lwd = 2, lty = 2)
# visualise estimated changepoints by solid vertical lines # and true changepoints by broken vertical lines td <- testData(lengths = c(50, 50, 200, 300, 300), means = c(0, 1, 2, 3, 2.3), sds = rep(1, 5), seed = 123) mbu <- multiscale.bottomUp(td$x) plot(mbu, display = "data") abline(v = td$cpts, col = 2, lwd = 2, lty = 2) # visualise estimated piecewise constant signal by solid line # and true signal by broken line td <- testData("blocks", seed = 123) mlp <- multiscale.localPrune(td$x) plot(mlp, display = "data") lines(td$mu, col = 2, lwd = 2, lty = 2)