View source: R/classify_changepoint.R
classify_changepoint | R Documentation |
This function implements a changepoint analysis to find changes in variance, mean or both. By default it is set to look for changes in the pressure data to identify migration periods, however it can be altered to any form of changepoint analysis in the package changepoint.
classify_changepoint(
dta,
cpt.method = "meanvar",
method = "PELT",
penalty = "Manual",
pen.value = "100*log(n)",
...
)
dta |
data to be classified (vector) |
cpt.method |
method for classifying data, currently support "mean","variance", "meanvar", use ?changepoint::cpt.mean ?changepoint::cpt.var or ?changepoint::cpt.meanvar for additional parameters |
method |
changepoint method used in package changepoint. see changepoint::cpt.mean, changepoint::cpt.var and changepoint::cpt.meanvar for details |
penalty |
See changepoint package for details. Choice of "None", "SIC", "BIC", "MBIC", AIC", "Hannan-Quinn", "Asymptotic", "Manual" and "CROPS" penalties. If Manual is specified, the manual penalty is contained in the pen.value parameter. If Asymptotic is specified, the theoretical type I error is contained in the pen.value parameter. If CROPS is specified, the penalty range is contained in the pen.value parameter; note this is a vector of length 2 which contains the minimum and maximum penalty value. Note CROPS can only be used if the method is "PELT". The predefined penalties listed DO count the changepoint as a parameter, postfix a 0 e.g."SIC0" to NOT count the changepoint as a parameter. |
pen.value |
See changepoint package for details. Tthe theoretical type I error e.g.0.05 when using the Asymptotic penalty. A vector of length 2 (min,max) if using the CROPS penalty. The value of the penalty when using the Manual penalty option - this can be a numeric value or text giving the formula to use. Available variables are, n=length of original data, null=null likelihood, alt=alternative likelihood, tau=proposed changepoint, diffparam=difference in number of alternatve and null parameters |
... |
any additional inputs for changepoint::cpt.mean, changepoint::cpt.var or changepoint::cpt.meanvar |
Changepoints in the data.
Killick, R. and Eckley, I., 2014. changepoint: An R package for changepoint analysis. Journal of statistical software, 58(3), pp.1-19.
## Not run:
# Import and crop PAM data
data("swift")
start = as.POSIXct("2016-09-01","%Y-%m-%d", tz="UTC")
end = as.POSIXct("2017-04-15","%Y-%m-%d", tz="UTC")
PAM_data = create_crop(swift, start, end)
# data(bee_eater)
# start = as.POSIXct("2015-08-01","%Y-%m-%d", tz="UTC")
# end = as.POSIXct("2016-06-01","%Y-%m-%d", tz="UTC")
# PAM_data = create_crop(bee_eater, start, end)
changepoints = classify_changepoint(PAM_data$pressure$obs)
# plot the timeseries with the changepoint
par(mfrow=c(2,1))
plot(PAM_data$pressure$obs, type="l")
abline(v=changepoints$changepoints, col="red",lwd=2)
# plot using changepoint package output
changepoint::plot(changepoints$output, cpt.width=3)
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.