pelt: Detecting Multiple Changepoints using the PELT Algorithm

Description Usage Arguments Details Value Examples

View source: R/pelt.bck.R View source: R/pelt.R

Description

Calculates the optimal positioning and number of changepoints using PELT.

Calculates the optimal positioning and number of changepoints using PELT.

Usage

1
2
3
4
5
6
7
pelt(data, pen = 2 * log(length(data)), min.dist = 2,
  cost = pelt.norm.meanvar.cost, sum.stat = pelt.norm.sum,
  initial.likelihood.value = 0)

pelt(data, pen = 2 * log(length(data)), min.dist = 2,
  cost = pelt.norm.meanvar.cost, sum.stat = pelt.norm.sum,
  initial.likelihood.value = 0)

Arguments

data

A vector of length n containing the data within which you wish to find a changepoint.

pen

Numeric value of the linear penalty function. This value is used in the decision for each individual changepoint so that in total the penalty is k*pen where k is the optimal number of changepoints detected.

min.dist

The minimum distance allowed between any two changepoints. Required to have an integer value of at least 1 for changes in mean, or at least 2 for changes in variance.

cost

The function used to calculate the cost of a given segment of data. The choice of this function dictates the assumed distribution and the type(s) of changes being detected (or simply the generic cost of data if non-parametric). See Details for possible choices.

sum.stat

The function used to generate the summary statistics used by cost. See Details for possible choices.

initial.likelihood.value

The initial value of the likelihood/cost function.

data

A vector of length n containing the data within which you wish to find a changepoint.

pen

Numeric value of the linear penalty function. This value is used in the decision for each individual changepoint so that in total the penalty is k*pen where k is the optimal number of changepoints detected.

min.dist

The minimum distance allowed between any two changepoints. Required to have an integer value of at least 1 for changes in mean, or at least 2 for changes in variance.

cost

The function used to calculate the cost of a given segment of data. The choice of this function dictates the assumed distribution and the type(s) of changes being detected (or simply the generic cost of data if non-parametric). See Details for possible choices.

sum.stat

The function used to generate the summary statistics used by cost. See Details for possible choices.

initial.likelihood.value

The initial value of the likelihood/cost function.

Details

This method uses the PELT algorithm to obtain the optimal number and location of changepoints within a univariate time series. This is done via the minimisation of a penalised cost function using dynamic programming. Inequality-based pruning is used to reduce computation whilst retaining optimality. A range of different cost functions and penalty values can be used.

This method uses the PELT algorithm to obtain the optimal number and location of changepoints within a univariate time series. This is done via the minimisation of a penalised cost function using dynamic programming. Inequality-based pruning is used to reduce computation whilst retaining optimality. A range of different cost functions and penalty values can be used.

Value

The vector of changepoint locations detected by PELT.

The vector of changepoint locations detected by PELT.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
# Normal observations, multiple change in mean.
data = c( rnorm(100, mean=0, sd=1), rnorm(100, mean=5, sd=1), rnorm(100, mean=-1, sd=1), rnorm(100, mean=2, sd=1) )
# plot.ts(data)
n = length(data)
pelt.results = pelt(data=data, pen=2*log(n), cost=pelt.norm.mean.cost, sum.stat=pelt.norm.sum)
# Normal observations, multiple change in mean.
data = c( rnorm(100, mean=0, sd=1), rnorm(100, mean=5, sd=1), rnorm(100, mean=-1, sd=1), rnorm(100, mean=2, sd=1) )
# plot.ts(data)
n = length(data)
pelt.results = pelt(data=data, pen=2*log(n), cost=pelt.norm.mean.cost, sum.stat=pelt.norm.sum)

benpickering/smop documentation built on Sept. 4, 2020, 1:45 a.m.