detect.change: Change point detection

Description Usage Arguments Value Author(s) Examples

View source: R/analysis.R

Description

Take time series data and perform change point detection. It uses cpt.mean or cpt.var from changepoint package for change point detection. If plot is TRUE, it also plots the point where the changes take place.

Usage

1
detect.change(data, type = c("mean", "var"), ..., plot = TRUE)

Arguments

data

Time series data whose change point is to be detected. The data should be either ts object or numeric vector.

type

Type of change to be detected. Should be one of "mean" and "var". (default = "mean")

...

Extra arguments for change point detection. Refer to cpt.mean and cpt.var.

plot

If TRUE, the chagne points will be plotted. Otherwise, not. (default = TRUE)

Value

A list containing the following elements:

change.point Change point detection result(cpt object).
plot ggplot object of the plot. (Returned only if plot is TRUE.)

Author(s)

Sanghyun Park, Daun Jeong, and Sehun Kim

Examples

1
2
3
4
5
6
7
8
# 228 is the station code for SNU
data <- get.subway(228)

# Change point detection in mean
detect.change(data$total, type = "mean")

# Change point detection in variance
detect.change(data$total, type = "var")

eik4862/Subway documentation built on Sept. 24, 2021, 3:39 a.m.