ocpt.meanvar.update: Identifying Changes in Mean and variance. Update function.

Description Usage Arguments Details Value Author(s) References See Also Examples

View source: R/ocpt.meanvar.R

Description

Calculates the optimal positioning and (potentially) number of changepoints for data using the user specified method. The update function should be used once ocpt.meanvar.initialise has created an answer.

Usage

1
ocpt.meanvar.update(previousanswer, newdata)

Arguments

previousanswer

A S4 class. This will be the output from the ocpt.mean.initialise function.

newdata

A vector, ts object or matrix containing the new data within which you wish to find a changepoint. If data is a matrix, each row is considered a separate dataset.

Details

This function is used to find changes in mean for data using the test statistic specified in the test.stat parameter. The changes are found using the method supplied which can be single changepoint or multiple changepoints. A changepoint is denoted as the last observation of the segment / regime.

Value

If class=TRUE then an object of S4 class "ocpt" is returned. The slot ocpts contains the changepoints that are returned. For class=FALSE the structure is as follows.

If data is a vector (single dataset) then a vector/list is returned depending on the value of method. If data is a matrix (multiple datasets) then a list is returned where each element in the list is either a vector or list depending on the value of method.

Returns a summary of:

cpttype

In this case it will always be change in mean.

Method

The method used.

test.stat

The chosen test statistic.

penalty

Both the type and value of the penalty

minseglen

The minimum segment length.

max no. of cpts

Maximum number of changepoints possible.

ndone

Length of the time series when analysis begins.

nupdate

Length of the time series to be analysed in this update.

Author(s)

Andrew Connell Rebecca Killick

References

Change in Normal mean: Hinkley, D. V. (1970) Inference About the Change-Point in a Sequence of Random Variables, Biometrika 57, 1–17

PELT Algorithm: Killick R, Fearnhead P, Eckley IA (2012) Optimal detection of changepoints with a linear computational cost, JASA 107(500), 1590–1598

MBIC: Zhang, N. R. and Siegmund, D. O. (2007) A Modified Bayes Information Criterion with Applications to the Analysis of Comparative Genomic Hybridization Data. Biometrics 63, 22-32.

See Also

ocpt.var.initialise,ocpt.mean.initialise,ocpt

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
set.seed(1)
x=c(rnorm(50,0,1),rnorm(50,5,1),rnorm(50,10,1),rnorm(50,3,1))
y = c(rnorm(50,15,1),rnorm(50,25,1),rnorm(50,33,1),rnorm(50,7,1))
previousans = ocpt.meanvar.initialise(x)
ocpt.meanvar.update(previousanswer = previousans, newdata = y)

x_ecp = matrix(c(rnorm(50,0,1),rnorm(50,5,1),rnorm(50,10,1),rnorm(50,3,1)), ncol = 1)
y_ecp = matrix(c(rnorm(50,15,1),rnorm(50,25,1),rnorm(50,33,1),rnorm(50,7,1)), ncol = 1)
previousansecp = ocpt.meanvar.initialise(x_ecp, test.stat="ECP")
ocpt.meanvar.update(previousanswer = previousansecp, newdata = y_ecp)

rkillick/changepoint.online documentation built on Sept. 26, 2020, 11:01 p.m.