knitr::opts_chunk$set( collapse = TRUE, comment = "#>", fig.align = "center", fig.path = "man/figures/README-" )
Flexible and user-friendly probabilistic segmentation of time series with smooth and/or abrupt regime changes by a mixture model-based regression approach with a hidden logistic process, fitted by the EM algorithm.
You can install the RHLP package from GitHub with:
# install.packages("devtools") devtools::install_github("fchamroukhi/RHLP")
To build vignettes for examples of usage, type the command below instead:
# install.packages("devtools") devtools::install_github("fchamroukhi/RHLP", build_opts = c("--no-resave-data", "--no-manual"), build_vignettes = TRUE)
Use the following command to display vignettes:
browseVignettes("RHLP")
library(RHLP)
# Application to a toy data set data("toydataset") x <- toydataset$x y <- toydataset$y K <- 5 # Number of regimes (mixture components) p <- 3 # Dimension of beta (order of the polynomial regressors) q <- 1 # Dimension of w (order of the logistic regression: to be set to 1 for segmentation) variance_type <- "heteroskedastic" # "heteroskedastic" or "homoskedastic" model n_tries <- 1 max_iter = 1500 threshold <- 1e-6 verbose <- TRUE verbose_IRLS <- FALSE rhlp <- emRHLP(X = x, Y = y, K, p, q, variance_type, n_tries, max_iter, threshold, verbose, verbose_IRLS) rhlp$summary() rhlp$plot()
# Application to a real data set data("realdataset") x <- realdataset$x y <- realdataset$y2 K <- 5 # Number of regimes (mixture components) p <- 3 # Dimension of beta (order of the polynomial regressors) q <- 1 # Dimension of w (order of the logistic regression: to be set to 1 for segmentation) variance_type <- "heteroskedastic" # "heteroskedastic" or "homoskedastic" model n_tries <- 1 max_iter = 1500 threshold <- 1e-6 verbose <- TRUE verbose_IRLS <- FALSE rhlp <- emRHLP(X = x, Y = y, K, p, q, variance_type, n_tries, max_iter, threshold, verbose, verbose_IRLS) rhlp$summary() rhlp$plot()
In this package, it is possible to select models based on information criteria such as BIC, AIC and ICL.
The selection can be done for the two following parameters:
Let's select a RHLP model for the following time series Y:
data("toydataset") x <- toydataset$x y <- toydataset$y plot(x, y, type = "l", xlab = "x", ylab = "Y")
selectedrhlp <- selectRHLP(X = x, Y = y, Kmin = 2, Kmax = 6, pmin = 0, pmax = 3) selectedrhlp$plot(what = "estimatedsignal")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.