run.cghseg: run cghseg

Description Usage Arguments Value Author(s) Examples

Description

Estimate the least squares model for a noisy signal. We use the cghseg package, which implements the pruned dynamic programming method of Rigaill (2010) to find, for all k=1,...,maxSegments: argmin_x has k segments ||Y-x||^2_2.

Usage

1
run.cghseg(Y, base = seq_along(Y), maxSegments = 20)

Arguments

Y

Numeric vector of the noisy signal to segment.

base

Integer vector of bases where Y is sampled.

maxSegments

Maximum number of segments to consider.

Value

List containing the solutions. The "segments" element is a data.frame that describes the segmentation model, with 1 line for each segment.

Author(s)

Toby Dylan Hocking

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
set.seed(1)
y <- c(rnorm(50),rnorm(100,2))
kmax <- 3
result <- run.cghseg(y,maxSegments=kmax)
signal.df <- data.frame(signal=y,base=seq_along(y))
library(ggplot2)
ggplot()+
  geom_point(aes(base,signal),data=signal.df)+
  geom_segment(aes(first.base,mean,xend=last.base,yend=mean),
               data=result$segments,colour=signal.colors[["estimate"]],lwd=3)+
  geom_vline(aes(xintercept=base),data=result$break.df,
             colour=signal.colors[["estimate"]],linetype="dashed")+
  facet_grid(segments~.,labeller=label_both)

breakpointError documentation built on May 2, 2019, 5:22 p.m.