LocationStability {changepoint.influence}R Documentation

Location Stability Graphic

Description

Plots the middle detail level of the changepoint location stability according to the influence measure.

Usage

LocationStability(original.cpts, influence, expected.class=NULL,
  type=c("Difference","Global","Local"),data=NULL,include.data=FALSE,cpt.lwd=4,
  cpt.col=c("#009E73", "#E69F00", "#E41A1C"),cpt.lty=c("dashed","dotdash","dotted"),
  ylab='',xlab='Index',...)

Arguments

original.cpts

An ordered vector of the changepoint locations found by your favourite changepoint method.

influence

The influence as calculated the influence() function provided within this package. This is a list object.

expected.class

Only needed for type="Difference". An nxn matrix containing the expected class of each datapoint from the original.cpts segmentation under perturbation of each datapoint. If this is left as NULL and type="Difference", it will be calculated and returned to the user.

type

The type of Location Stability plot, can be "Difference", "Global" or "Local". If all three are listed (as in the default) then three graphs will be plotted. type="Difference" will histogram the difference between the observed and expected segmentations at each of the datapoints. type="Global" will histogram the observed segmentations. type="Local" will histogram the observed segmentations with the original.cpts locations removed. See details for more description of the graphics.

data

A vector containing the data on which you have run your changepoint method.

include.data

Is a plot of the data to be included above the histogram. Default is FALSE.

cpt.lwd

The line width to be used when plotting the original.cpts on the data. Standard lwd values allowed. A single value is expected.

cpt.col

Colour of the original.cpts lines when plotted. We need three colours specified here, corresponding to the "stable", "unstable" and "outlier" categories respectively. Any values accepted by the col plotting argument are allowed.

cpt.lty

Line type of the original.cpts lines when plotted. We need three line types specified here, corresponding to the "stable", "unstable" and "outlier" categories respectively. Any values accepted by the lty plotting argument are allowed.

ylab, xlab

The labels for the x- and y-axis, character vector expected.

...

Any other arguments to be passed to the plot() or equivalently hist() function.

Details

This function creates a more granular graphic to display the results of a changepoint influence analysis on the location of the changepoints. The graphic is a histogram of the observed segmentations under the "delete" or "outlier" Influence analysis. The colour and line type of the bars at the original.cpts locations reflect their stability. The first value of their arguments denotes a stable changepoint - which appears at the same location in all influence segmentations. The second argument denotes an unstable changepoint - which doesn't appear at the same location in all influence segmentations, either it moves or is deleted. The third argument denotes changepoint locations which are deemed outliers as two changepoints occur at consecutive locations (surrounding the outlying observation). Please note that the type="Global" only uses colour and not line type.

type="Difference" gives the difference between the observed and expected changepoint segmentations under the "delete" or "outlier" Influence analysis. A positive value can only occur where a changepoint is contained in the observed segmentations but is not present in the expected (an additional changepoint time). A negative value can only occur at the original changepoint location where the changepoint is not present in atleast one of the observed segmentations. Note that the expected segmentations take into account the fact that a changepoint at a timepoint, say 100, will move (to 99) when a timepoint prior to it is deleted.

type="Global" histograms the observed segmentations. Colour is added to the original changepoint locations and a horizontal (light grey) line is added to the plot to denote the maximum count. Any original changepoint bars that do not meet this grey line indicates that the changepoint is unstable as it either moves or is deleted in atleast one of the observed segmentations. For large datasets this can be difficult to view what is going on at any locations that appear as black bars as these are typically small counts. Hence the inclusion of the "Local" option.

type="Local" histograms the observed segmentations with the original changepoint locations removed. This is to allow users to see the smaller counts that can be masked in larger datasets. These are the locations where either original changepoints move to or additional changepoints are added.

Value

The function returns plot(s) and a list containing the labels of the original.cpts as either "stable", "unstable", or "outlier". If type="Difference" and expected.class=NULL then the expected class is also returned as the first element of the list.

Author(s)

Rebecca Killick

References

Wilms I, Killick R, Matteson DS (2022) Graphical Influence Diagnostics for Changepoint Models, Journal of Computational and Graphical Statistics, 31:3, 753–765 DOI: 10.1080/10618600.2021.2000873

See Also

influence-methods, StabilityOverview,ParameterStability,InfluenceMap

Examples

#### Generate Simulated data example ####
set.seed(30)
x = c(rnorm(50), rnorm(50, mean = 5), rnorm(1, mean = 15), rnorm(49, mean = 5), rnorm(50, mean = 4))
xcpt = cpt.mean(x,method='PELT') # Get the changepoints via PELT

#### Get the influence for both delete and outlier options ####
x.inf = influence(xcpt)


#### Location Stability Difference plot ####
exp.class=LocationStability(cpts(xcpt), type = 'Difference', x.inf, cpt.lwd = 4, las = 1)
# note that the expected.class is also returned

#### Location Stability Global plot ####
exp.class=LocationStability(cpts(xcpt), type = 'Global', x.inf, cpt.lwd = 4, las = 1)

#### Location Stability Local plot ####
exp.class=LocationStability(cpts(xcpt), type = 'Local', x.inf, cpt.lwd = 4, las = 1)

[Package changepoint.influence version 1.0.2 Index]