break.ts: Change-point analysis by clustering

View source: R/ts.R

break.tsR Documentation

Change-point analysis by clustering

Description

Divide a time-series into homogenous segments.

Usage

break.ts(x, n = 2, trace = T, same.var = T, ...)

Arguments

x

a numerical vector or ts object

n

the desired number of segments

trace

If TRUE, shows a merging trace via plot_hclust_trace

same.var

argument passed to ward

Details

Calls ward with sortx=F to cluster the series into segments. Only the marginal distribution of data is used; temporal smoothness, for example, is ignored.

Value

A vector of time breaks. The breaks are also plotted visually via plot.segments.ts.

Author(s)

Tom Minka

See Also

plot.segments.ts, plot_breaks

Examples


data(LakeHuron)
# single major change
break.ts(LakeHuron,2)
# merging trace suggests n=6 is also interesting:
break.ts(LakeHuron,6)
# interesting oscillation

data(treering)
break.ts(treering[1:500],9,same=T)
break.ts(treering[1:100],7,same=T)
# interesting multiscale structure

x <- c(rnorm(100),rnorm(300)*3,rnorm(200)*2)
b <- break.ts(x,3,same=F)
plot(x,type="l")
plot_breaks(b)


paulemms/datamining documentation built on March 1, 2023, 4:01 p.m.