changepoint::cpt.mean

This is an R Markdown document. Markdown is a simple formatting syntax for authoring web pages (click the MD toolbar button for help on Markdown).

When you click the Knit HTML button a web page will be generated that includes both content as well as the output of any embedded R code chunks within the document. You can embed an R code chunk like this:

library(changepoint)
## Loading required package: zoo
## Attaching package: 'zoo'
## The following object(s) are masked from 'package:base':
## 
## as.Date, as.Date.numeric
## Successfully loaded changepoint package version 1.1 Created on 2013-06-19
## Substantial changes to the structure of the package have occured between
## version 0.8 and 1.0.2.  Please see the package NEWS for details.

set.seed(10)
mean2 <- c(rnorm(100, 0, 1), rnorm(100, 1, 1), rnorm(100, 0, 1), rnorm(199, 
    0.2, 1))
plot(mean2, type = "l")

plot of chunk defaultPlot

You can also embed plots, for example:

# default penalty
mean2.pelt <- cpt.mean(mean2, method = "PELT")
cpts(mean2.pelt)
## [1]  97 192 273 353 362 366
plot(mean2.pelt, type = "l", cpt.col = "blue", xlab = "Value", cpt.width = 4, 
    main = "default penalty")

plot of chunk defaultPenalty


# pen.value
mean2.pelt <- cpt.mean(mean2, method = "PELT", penalty = "Manual", pen.value = "1.4*log(n)")
cpts(mean2.pelt)
## [1]  97 192 273
plot(mean2.pelt, type = "l", cpt.col = "blue", xlab = "Value", cpt.width = 2, 
    main = "default penalty")

plot of chunk manualPenalty