InfluenceMap {changepoint.influence}R Documentation

Influence Map Graphic

Description

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

Usage

InfluenceMap(original.cpts, influence, resid=NULL,data=NULL,include.data=FALSE,
influence.col=c("#0C4479","white","#AB9783"),cpt.col=c("#009E73", "#E69F00", "#E41A1C"),
cpt.lty=c("dashed","dotdash","dotted"),ylab='',ggops=NULL)

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.

resid

An nxn matrix containing the difference of the observed class (influence) from the expected class at each datapoint. If this is left as NULL, it will be calculated and returned to the user.

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.

influence.col

A length 3 vector giving the lower, middle (0) and upper bounds for the influence map colour grading. Note that you should choose these colours to not conflict with the colours used for cpt.col. We advise using "white" for the middle choice as this provides a clean (majority white) heatmap.

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. These are plotted on the Influence Map as well as the original data if include.data=TRUE. 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. Only used if include.data=TRUE.

ylab

The label for the y-axis, character vector expected.

ggops

Any other settings to be passed to the ggplot() function. Note that you will need to library(ggplot2) if calling ggplot functions in arguments. See examples.

Details

This function creates the highest detail graphic to display the results of a changepoint influence analysis on the location of the changepoints. The graphic is an nxn heatmap of the difference between the observed segmentations under the "delete" or "outlier" Influence analysis and the expected segmentation. 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 and that adding an outlier will introduce new changepoints.

Datapoints on the vertical axis without a single coloured co-ordinate on the horizontal axis can be considered as non-influential since they do not trigger any changepoint instability. Rows with coloured pixels correspond to data points which are instability triggers.

How to interpret the Influence Map (please also read the paper in the references for fuller details):

colouring:

Colouring above the diagonal indicates that an al-teration of the corresponding data point (on the vertical axis) affects earlier data points,colouring below the diagonal indicates that subsequent data points are affected.

horizonal span:

A stop in colouring indicates that change-points have moved, while a continuation of colouring to the last data point indicates that, in total, fewer or additional changepoints are detected.

local vs global:

Most colouring originates on the diagonal,thereby indicating that a data point's alteration mainly affects neighbouring data points that most often belong to the same segment. By contrast, in some cases a coloured pixel may originate away from the diagonal, thereby exercising global influence.

height:

All data points (on the vertical axis) that appear in the coloured area are influential and assert influence over the corresponding data points on the horizontal axis. The height can be seen as the extent to which instability arises in this influential region.

Value

The function returns a plot denoted the Influence Map. If resid=NULL then the residuals (observed class - expected class) are also returned.

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, LocationStability

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


#### Influence Map ####
## Not run: 
library(ggplot2)
x.inf = influence(xcpt, method = "delete")
InfluenceMap(cpts(xcpt), x.inf, data = x, include.data = TRUE, 
   ggops = theme(axis.text = element_text(size=15), axis.title = element_text(size=20),
   plot.title = element_text(size=25)))


x.inf = influence(xcpt, method = "outlier")
InfluenceMap(cpts(xcpt), x.inf, data=x, include.data = TRUE,
    ggops = theme(axis.text = element_text(size=15), axis.title = element_text(size=20),
    plot.title = element_text(size=25)))

## End(Not run)

[Package changepoint.influence version 1.0.2 Index]