Giter Site home page Giter Site logo

changepoint.np's Introduction

changepoint.np

An R package to detect changepoints using nonparametric methods. This package is an extension to the [changepoint R package] (https://cran.r-project.org/web/packages/changepoint/index.html) which looks at parametric methods for changepoint detection.

Currently the method uses PELT with a cost function based on the empirical distribution

Example
set.seed(12)

J <- function(x){
   (1+sign(x))/2
 }

n <- 1000
tau <- c(0.1,0.13,0.15,0.23,0.25,0.4,0.44,0.65,0.76,0.78,0.81)*n
h <- c(2.01, -2.51, 1.51, -2.01, 2.51, -2.11, 1.05, 2.16, -1.56, 2.56, -2.11)
sigma <- 0.5
t <- seq(0,1,length.out = n)
data <- array()
for (i in 1:n){
   data[i] <- sum(h*J(n*t[i] - tau)) + (sigma * rnorm(1))
}

out <- cpt.np(data, penalty = "SIC",method="PELT",test.stat="empirical_distribution",
             class=TRUE,minseglen=2, nquantiles =4*log(length(data)))
changepoint::cpts(out)

#returns 100 130 150 230 250 400 440 650 760 780 810 as the changepoint locations.

plot(out)

alt tag

####### Heart Rate Example

This example uses heart rate data recorded using a wearable heart rate monitor whilst running. We use the CROPS penalty in this situation. The diagnostic plot gives us an idea of how many changes to choose (the point on the elbow).

cptHeartRate <- cpt.np(HeartRate, penalty = "CROPS", pen.value = c(25,200), method="PELT",
   test.stat="empirical_distribution",class=TRUE,minseglen=2, nquantiles =4*log(length(HeartRate)))

plot(cptHeartRate, diagnostic = TRUE)
plot(cptHeartRate, ncpts = 11)

alt tag alt tag

changepoint.np's People

Stargazers

 avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.