Description Usage Arguments Value Author(s) Examples
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.
1 | run.cghseg(Y, base = seq_along(Y), maxSegments = 20)
|
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. |
List containing the solutions. The "segments" element is a data.frame that describes the segmentation model, with 1 line for each segment.
Toby Dylan Hocking
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)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.