| Type: | Package |
| Title: | Statistical Models for the Unsupervised Segmentation of Time-Series ('SaMUraiS') |
| Version: | 0.1.0 |
| Description: | Provides a variety of original and flexible user-friendly statistical latent variable models and unsupervised learning algorithms to segment and represent time-series data (univariate or multivariate), and more generally, longitudinal data, which include regime changes. 'samurais' is built upon the following packages, each of them is an autonomous time-series segmentation approach: Regression with Hidden Logistic Process ('RHLP'), Hidden Markov Model Regression ('HMMR'), Multivariate 'RHLP' ('MRHLP'), Multivariate 'HMMR' ('MHMMR'), Piece-Wise regression ('PWR'). For the advantages/differences of each of them, the user is referred to our mentioned paper references. |
| URL: | https://github.com/fchamroukhi/SaMUraiS |
| License: | GPL (≥ 3) |
| Depends: | R (≥ 2.10) |
| Imports: | methods, stats, MASS, Rcpp |
| Suggests: | knitr, rmarkdown |
| LinkingTo: | Rcpp, RcppArmadillo |
| Collate: | samurais-package.R RcppExports.R utils.R dynamicProg.R fitPWRFisher.R mkStochastic.R hmmProcess.R MData.R ParamHMMR.R ParamMHMMR.R ParamMRHLP.R ParamPWR.R ParamRHLP.R StatHMMR.R StatMHMMR.R StatMRHLP.R StatPWR.R StatRHLP.R ModelHMMR.R ModelMHMMR.R ModelMRHLP.R ModelPWR.R ModelRHLP.R emHMMR.R emMHMMR.R emMRHLP.R emRHLP.R selectHMMR.R selectMHMMR.R selectMRHLP.R selectRHLP.R data-multivrealdataset.R data-multivtoydataset.R data-univrealdataset.R data-univtoydataset.R |
| VignetteBuilder: | knitr |
| Encoding: | UTF-8 |
| LazyData: | true |
| RoxygenNote: | 6.1.1 |
| NeedsCompilation: | yes |
| Packaged: | 2019-07-25 16:23:38 UTC; lecocq191 |
| Author: | Faicel Chamroukhi |
| Maintainer: | Florian Lecocq <florian.lecocq@outlook.com> |
| Repository: | CRAN |
| Date/Publication: | 2019-07-28 09:50:02 UTC |
SaMUraiS: StAtistical Models for the UnsupeRvised segmentAtIon of time-Series
Description
samurais is a toolbox including many original and flexible
user-friendly statistical latent variable models and efficient unsupervised
algorithms to segment and represent time-series data (univariate or
multivariate), and more generally, longitudinal data, which include regime
changes.
samurais contains the following time series segmentation models:
RHLP;
HMM/HMMR;
PWR;
MRHLP;
MHMMR;
For the advantages/differences of each of them, the user is referred to our mentioned paper references.
To learn more about samurais, start with the vignettes:
browseVignettes(package = "samurais")
Author(s)
Maintainer: Florian Lecocq florian.lecocq@outlook.com
Authors:
Faicel Chamroukhi faicel.chamroukhi@unicaen.fr (0000-0002-5894-3103)
Marius Bartcus marius.bartcus@gmail.com
References
Chamroukhi, F., and Hien D. Nguyen. 2019. Model-Based Clustering and Classification of Functional Data. Wiley Interdisciplinary Reviews: Data Mining and Knowledge Discovery. https://doi.org/10.1002/widm.1298.
Chamroukhi, F. 2015. Statistical Learning of Latent Data Models for Complex Data Analysis. Habilitation Thesis (HDR), Universite de Toulon. https://chamroukhi.com/Dossier/FChamroukhi-Habilitation.pdf.
Trabelsi, D., S. Mohammed, F. Chamroukhi, L. Oukhellou, and Y. Amirat. 2013. An Unsupervised Approach for Automatic Activity Recognition Based on Hidden Markov Model Regression. IEEE Transactions on Automation Science and Engineering 3 (10): 829–335. https://chamroukhi.com/papers/Chamroukhi-MHMMR-IeeeTase.pdf.
Chamroukhi, F., D. Trabelsi, S. Mohammed, L. Oukhellou, and Y. Amirat. 2013. Joint Segmentation of Multivariate Time Series with Hidden Process Regression for Human Activity Recognition. Neurocomputing 120: 633–44. https://chamroukhi.com/papers/chamroukhi_et_al_neucomp2013b.pdf.
Chamroukhi, F., A. Same, G. Govaert, and P. Aknin. 2010. A Hidden Process Regression Model for Functional Data Description. Application to Curve Discrimination. Neurocomputing 73 (7-9): 1210–21. https://chamroukhi.com/papers/chamroukhi_neucomp_2010.pdf.
Chamroukhi, F. 2010. Hidden Process Regression for Curve Modeling, Classification and Tracking. Ph.D. Thesis, Universite de Technologie de Compiegne. https://chamroukhi.com/papers/FChamroukhi-Thesis.pdf.
Chamroukhi, F., A. Same, G. Govaert, and P. Aknin. 2009. Time Series Modeling by a Regression Approach Based on a Latent Process. Neural Networks 22 (5-6): 593–602. https://chamroukhi.com/papers/Chamroukhi_Neural_Networks_2009.pdf.
See Also
Useful links:
A Reference Class which represents multivariate data.
Description
MData is a reference class which represents multivariate objects. The data
can be ordered by time (multivariate time series). In the last case, the
field X represents the time.
Fields
XNumeric vector of length m.
YMatrix of size
(m, d)representing addimension function ofXobserved at points1,\dots,m.
A Reference Class which represents a fitted HMMR model.
Description
ModelHMMR represents an estimated HMMR model.
Fields
paramAn object of class ParamHMMR. It contains the estimated values of the parameters.
statAn object of class StatHMMR. It contains all the statistics associated to the HMMR model.
Methods
plot(what = c("predicted", "filtered", "smoothed", "regressors", "loglikelihood"), ...)Plot method.
whatThe type of graph requested:
-
"predicted" =Predicted time series and predicted regime probabilities (fieldspredictedandpredict_probof class StatHMMR). -
"filtered" =Filtered time series and filtering regime probabilities (fieldsfilteredandfilter_probof class StatHMMR). -
"smoothed" =Smoothed time series, and segmentation (fieldssmoothedandklasof the class StatHMMR). -
"regressors" =Polynomial regression components (fieldsregressorsandtau_tkof class StatHMMR). -
"loglikelihood" =Value of the log-likelihood for each iteration (fieldstored_loglikof class StatHMMR).
-
...Other graphics parameters.
By default, all the graphs mentioned above are produced.
summary(digits = getOption("digits"))Summary method.
digitsThe number of significant digits to use when printing.
See Also
Examples
data(univtoydataset)
hmmr <- emHMMR(univtoydataset$x, univtoydataset$y, K = 5, p = 1, verbose = TRUE)
# hmmr is a ModelHMMR object. It contains some methods such as 'summary' and 'plot'
hmmr$summary()
hmmr$plot()
# hmmr has also two fields, stat and param which are reference classes as well
# Log-likelihood:
hmmr$stat$loglik
# Parameters of the polynomial regressions:
hmmr$param$beta
A Reference Class which represents a fitted MHMMR model.
Description
ModelMHMMR represents an estimated MHMMR model.
Fields
paramA ParamMHMMR object. It contains the estimated values of the parameters.
statA StatMHMMR object. It contains all the statistics associated to the MHMMR model.
Methods
plot(what = c("predicted", "filtered", "smoothed", "regressors", "loglikelihood"), ...)Plot method.
whatThe type of graph requested:
-
"predicted" =Predicted time series and predicted regime probabilities (fieldspredictedandpredict_probof class StatMHMMR). -
"filtered" =Filtered time series and filtering regime probabilities (fieldsfilteredandfilter_probof class StatMHMMR). -
"smoothed" =Smoothed time series, and segmentation (fieldssmoothedandklasof class StatMHMMR). -
"regressors" =Polynomial regression components (fieldsregressorsandtau_tkof class StatMHMMR). -
"loglikelihood" =Value of the log-likelihood for each iteration (fieldstored_loglikof class StatMHMMR).
-
...Other graphics parameters.
By default, all the above graphs are produced.
summary(digits = getOption("digits"))Summary method.
digitsThe number of significant digits to use when printing.
See Also
Examples
data(multivtoydataset)
mhmmr <- emMHMMR(multivtoydataset$x, multivtoydataset[,c("y1", "y2", "y3")],
K = 5, p = 1, verbose = TRUE)
# mhmmr is a ModelMHMMR object. It contains some methods such as 'summary' and 'plot'
mhmmr$summary()
mhmmr$plot()
# mhmmr has also two fields, stat and param which are reference classes as well
# Log-likelihood:
mhmmr$stat$loglik
# Parameters of the polynomial regressions:
mhmmr$param$beta
A Reference Class which represents a fitted MRHLP model.
Description
ModelMRHLP represents an estimated MRHLP model.
Fields
paramA ParamMRHLP object. It contains the estimated values of the parameters.
statA StatMRHLP object. It contains all the statistics associated to the MRHLP model.
Methods
plot(what = c("regressors", "estimatedsignal", "loglikelihood"), ...)Plot method.
whatThe type of graph requested:
...Other graphics parameters.
By default, all the graphs mentioned above are produced.
summary(digits = getOption("digits"))Summary method.
digitsThe number of significant digits to use when printing.
See Also
Examples
data(multivtoydataset)
mrhlp <- emMRHLP(multivtoydataset$x, multivtoydataset[,c("y1", "y2", "y3")],
K = 5, p = 1, verbose = TRUE)
# mrhlp is a ModelMRHLP object. It contains some methods such as 'summary' and 'plot'
mrhlp$summary()
mrhlp$plot()
# mrhlp has also two fields, stat and param which are reference classes as well
# Log-likelihood:
mrhlp$stat$loglik
# Parameters of the polynomial regressions:
mrhlp$param$beta
A Reference Class which represents a fitted PWR model.
Description
ModelPWR represents an estimated PWR model.
Fields
paramA ParamPWR object. It contains the estimated values of the parameters.
statA StatPWR object. It contains all the statistics associated to the PWR model.
Methods
plot(what = c("regressors", "segmentation"), ...)Plot method.
whatThe type of graph requested:
...Other graphics parameters.
By default, all the graphs mentioned above are produced.
summary(digits = getOption("digits"))Summary method.
digitsThe number of significant digits to use when printing.
See Also
Examples
data(univtoydataset)
pwr <- fitPWRFisher(univtoydataset$x, univtoydataset$y, K = 5, p = 1)
# pwr is a ModelPWR object. It contains some methods such as 'summary' and 'plot'
pwr$summary()
pwr$plot()
# pwr has also two fields, stat and param which are reference classes as well
# Value of the objective function:
pwr$stat$objective
# Parameters of the polynomial regressions:
pwr$param$beta
A Reference Class which represents a fitted RHLP model.
Description
ModelRHLP represents an estimated RHLP model.
Fields
paramA ParamRHLP object. It contains the estimated values of the parameters.
statA StatRHLP object. It contains all the statistics associated to the RHLP model.
Methods
plot(what = c("regressors", "estimatedsignal", "loglikelihood"), ...)Plot method.
whatThe type of graph requested:
...Other graphics parameters.
By default, all the graphs mentioned above are produced.
summary(digits = getOption("digits"))Summary method.
digitsThe number of significant digits to use when printing.
See Also
Examples
data(univtoydataset)
rhlp <- emRHLP(univtoydataset$x, univtoydataset$y, K = 3, p = 1, verbose = TRUE)
# rhlp is a ModelMHMMR object. It contains some methods such as 'summary' and 'plot'
rhlp$summary()
rhlp$plot()
# rhlp has also two fields, stat and param which are reference classes as well
# Log-likelihood:
rhlp$stat$loglik
# Parameters of the polynomial regressions:
rhlp$param$beta
A Reference Class which contains parameters of a HMMR model.
Description
ParamHMMR contains all the parameters of a HMMR model. The parameters are calculated by the initialization Method and then updated by the Method implementing the M-Step of the EM algorithm.
Fields
XNumeric vector of length m representing the covariates/inputs
x_{1},\dots,x_{m}.YNumeric vector of length m representing the observed response/output
y_{1},\dots,y_{m}.mNumeric. Length of the response/output vector
Y.KThe number of regimes (HMMR components).
pThe order of the polynomial regression.
variance_typeCharacter indicating if the model is homoskedastic (
variance_type = "homoskedastic") or heteroskedastic (variance_type = "heteroskedastic"). By default the model is heteroskedastic.priorThe prior probabilities of the Markov chain.
prioris a row matrix of dimension(1, K).trans_matThe transition matrix of the Markov chain.
trans_matis a matrix of dimension(K, K).maskMask applied to the transition matrices
trans_mat. By default, a mask of order one is applied.betaParameters of the polynomial regressions.
\boldsymbol{\beta} = (\boldsymbol{\beta}_{1},\dots,\boldsymbol{\beta}_{K})is a matrix of dimension(p + 1, K), withpthe order of the polynomial regression.pis fixed to 3 by default.sigma2The variances for the
Kregimes. If HMMR model is heteroskedastic (variance_type = "heteroskedastic") thensigma2is a matrix of size(K, 1)(otherwise HMMR model is homoskedastic (variance_type = "homoskedastic") andsigma2is a matrix of size(1, 1)).nuThe degree of freedom of the HMMR model representing the complexity of the model.
phiA list giving the regression design matrices for the polynomial and the logistic regressions.
Methods
initParam(try_algo = 1)Method to initialize parameters
mask,prior,trans_mat,betaandsigma2.If
try_algo = 1thenbetaandsigma2are initialized by segmenting the time seriesYuniformly intoKcontiguous segments. Otherwise,betaandsigma2are initialized by segmenting randomly the time seriesYintoKsegments.MStep(statHMMR)Method which implements the M-step of the EM algorithm to learn the parameters of the HMMR model based on statistics provided by the object
statHMMRof class StatHMMR (which contains the E-step).
A Reference Class which contains parameters of a MHMMR model.
Description
ParamMHMMR contains all the parameters of a MHMMR model. The parameters are calculated by the initialization Method and then updated by the Method implementing the M-Step of the EM algorithm.
Fields
mDataMData object representing the sample (covariates/inputs
Xand observed multivariate responses/outputsY).KThe number of regimes (MHMMR components).
pThe order of the polynomial regression.
variance_typeCharacter indicating if the model is homoskedastic (
variance_type = "homoskedastic") or heteroskedastic (variance_type = "heteroskedastic"). By default the model is heteroskedastic.priorThe prior probabilities of the Markov chain.
prioris a row matrix of dimension(1, K).trans_matThe transition matrix of the Markov chain.
trans_matis a matrix of dimension(K, K).maskMask applied to the transition matrices
trans_mat. By default, a mask of order one is applied.betaParameters of the polynomial regressions.
\boldsymbol{\beta} = (\boldsymbol{\beta}_{1},\dots,\boldsymbol{\beta}_{K})is an array of dimension(p + 1, d, K), withpthe order of the polynomial regression.pis fixed to 3 by default.sigma2The variances for the
Kregimes. If MRHLP model is heteroskedastic (variance_type = "heteroskedastic") thensigma2is an array of size(d, d, K)(otherwise MRHLP model is homoskedastic (variance_type = "homoskedastic") andsigma2is a matrix of size(d, d)).nuThe degree of freedom of the MHMMR model representing the complexity of the model.
phiA list giving the regression design matrices for the polynomial and the logistic regressions.
Methods
initParam(try_algo = 1)Method to initialize parameters
prior,trans_mat,betaandsigma2.If
try_algo = 1thenbetaandsigma2are initialized by segmenting the time seriesYuniformly intoKcontiguous segments. Otherwise,betaandsigma2are initialized by segmenting randomly the time seriesYintoKsegments.MStep(statMHMMR)Method which implements the M-step of the EM algorithm to learn the parameters of the MHMMR model based on statistics provided by the object
statMHMMRof class StatMHMMR (which contains the E-step).
A Reference Class which contains the parameters of a MRHLP model.
Description
ParamMRHLP contains all the parameters of a MRHLP model. The parameters are calculated by the initialization Method and then updated by the Method implementing the M-Step of the EM algorithm.
Fields
mDataMData object representing the sample (covariates/inputs
Xand observed responses/outputsY).KThe number of regimes (MRHLP components).
pThe order of the polynomial regression.
qThe dimension of the logistic regression. For the purpose of segmentation, it must be set to 1.
variance_typeCharacter indicating if the model is homoskedastic (
variance_type = "homoskedastic") or heteroskedastic (variance_type = "heteroskedastic"). By default the model is heteroskedastic.WParameters of the logistic process.
\boldsymbol{W} = (\boldsymbol{w}_{1},\dots,\boldsymbol{w}_{K-1})is a matrix of dimension(q + 1, K - 1), withqthe order of the logistic regression.qis fixed to 1 by default.betaParameters of the polynomial regressions.
\boldsymbol{\beta} = (\boldsymbol{\beta}_{1},\dots,\boldsymbol{\beta}_{K})is an array of dimension(p + 1, d, K), withpthe order of the polynomial regression.pis fixed to 3 by default.sigma2The variances for the
Kregimes. If MRHLP model is heteroskedastic (variance_type = "heteroskedastic") thensigma2is an array of size(d, d, K)(otherwise MRHLP model is homoskedastic (variance_type = "homoskedastic") andsigma2is a matrix of size(d, d)).nuThe degree of freedom of the MRHLP model representing the complexity of the model.
phiA list giving the regression design matrices for the polynomial and the logistic regressions.
Methods
initParam(try_algo = 1)Method to initialize parameters
W,betaandsigma2.If
try_algo = 1thenbetaandsigma2are initialized by segmenting the time seriesYuniformly intoKcontiguous segments. Otherwise,W,betaandsigma2are initialized by segmenting randomly the time seriesYintoKsegments.MStep(statMRHLP, verbose_IRLS)Method which implements the M-step of the EM algorithm to learn the parameters of the MRHLP model based on statistics provided by the object
statMRHLPof class StatMRHLP (which contains the E-step).
A Reference Class which contains the parameters of a PWR model.
Description
ParamPWR contains all the parameters of a PWR model. The parameters are calculated by the initialization Method and then updated by the Method dynamic programming (here dynamic programming)
Fields
XNumeric vector of length m representing the covariates/inputs
x_{1},\dots,x_{m}.YNumeric vector of length m representing the observed response/output
y_{1},\dots,y_{m}.mNumeric. Length of the response/output vector
Y.KThe number of regimes (PWR components).
pThe order of the polynomial regression.
pis fixed to 3 by default.gammaSet of transition points.
gammais a column matrix of size(K + 1, 1).betaParameters of the polynomial regressions.
betais a matrix of dimension(p + 1, K), withpthe order of the polynomial regression.pis fixed to 3 by default.sigma2The variances for the
Kregimes.sigma2is a matrix of size(K, 1).phiA list giving the regression design matrices for the polynomial and the logistic regressions.
Methods
computeDynamicProgram(C1, K)Method which implements the dynamic programming based on the cost matrix
C1and the number of regimes/segmentsK.computeParam()Method which estimates the parameters
betaandsigma2knowing the transition pointsgamma.
A Reference Class which contains parameters of a RHLP model.
Description
ParamRHLP contains all the parameters of a RHLP model. The parameters are calculated by the initialization Method and then updated by the Method implementing the M-Step of the EM algorithm.
Fields
XNumeric vector of length m representing the covariates/inputs
x_{1},\dots,x_{m}.YNumeric vector of length m representing the observed response/output
y_{1},\dots,y_{m}.mNumeric. Length of the response/output vector
Y.KThe number of regimes (RHLP components).
pThe order of the polynomial regression.
qThe dimension of the logistic regression. For the purpose of segmentation, it must be set to 1.
variance_typeCharacter indicating if the model is homoskedastic (
variance_type = "homoskedastic") or heteroskedastic (variance_type = "heteroskedastic"). By default the model is heteroskedastic.WParameters of the logistic process.
\boldsymbol{W} = (\boldsymbol{w}_{1},\dots,\boldsymbol{w}_{K-1})is a matrix of dimension(q + 1, K - 1), withqthe order of the logistic regression.qis fixed to 1 by default.betaParameters of the polynomial regressions.
\boldsymbol{\beta} = (\boldsymbol{\beta}_{1},\dots,\boldsymbol{\beta}_{K})is a matrix of dimension(p + 1, K), withpthe order of the polynomial regression.pis fixed to 3 by default.sigma2The variances for the
Kregimes. If RHLP model is heteroskedastic (variance_type = "heteroskedastic") thensigma2is a matrix of size(K, 1)(otherwise RHLP model is homoskedastic (variance_type = "homoskedastic") andsigma2is a matrix of size(1, 1)).nuThe degree of freedom of the RHLP model representing the complexity of the model.
phiA list giving the regression design matrices for the polynomial and the logistic regressions.
Methods
initParam(try_algo = 1)Method to initialize parameters
W,betaandsigma2.If
try_algo = 1thenbetaandsigma2are initialized by segmenting the time seriesYuniformly intoKcontiguous segments. Otherwise,W,betaandsigma2are initialized by segmenting randomly the time seriesYintoKsegments.MStep(statRHLP, verbose_IRLS)Method which implements the M-step of the EM algorithm to learn the parameters of the RHLP model based on statistics provided by the object
statRHLPof class StatRHLP (which contains the E-step).
A Reference Class which contains statistics of a HMMR model.
Description
StatHMMR contains all the statistics associated to a HMMR model. It mainly includes the E-Step of the EM algorithm calculating the posterior distribution of the hidden variables (ie the smoothing probabilities), as well as the calculation of the prediction and filtering probabilities, the log-likelhood at each step of the algorithm and the obtained values of model selection criteria..
Fields
tau_tkMatrix of size
(m, K)giving the posterior probability that the observationY_{i}originates from thek-th regression model.alpha_tkMatrix of size
(m, K)giving the forwards probabilities:P(Y_{1},\dots,Y_{t}, z_{t} = k).beta_tkMatrix of size
(m, K), giving the backwards probabilities:P(Y_{t+1},\dots,Y_{m} | z_{t} = k).xi_tklArray of size
(m - 1, K, K)giving the joint post probabilities:xi_tk[t, k, l] = P(z_{t} = k, z_{t-1} = l | \boldsymbol{Y})fort = 2,\dots,m.f_tkMatrix of size
(m, K)giving the cumulative distribution functionf(y_{t} | z{_t} = k).log_f_tkMatrix of size
(m, K)giving the logarithm of the cumulative distributionf_tk.loglikNumeric. Log-likelihood of the HMMR model.
stored_loglikNumeric vector. Stored values of the log-likelihood at each iteration of the EM algorithm.
klasColumn matrix of the labels issued from
z_ik. Its elements areklas(i) = k,k = 1,\dots,K.z_ikHard segmentation logical matrix of dimension
(m, K)obtained by the Maximum a posteriori (MAP) rule:z\_ik = 1 \ \textrm{if} \ z\_ik = \textrm{arg} \ \textrm{max}_{s} \ P(z_{i} = s | \boldsymbol{Y}) = tau\_tk;\ 0 \ \textrm{otherwise},k = 1,\dots,K.state_probsMatrix of size
(m, K)giving the distribution of the Markov chain.P(z_{1},\dots,z_{m};\pi,\boldsymbol{A})with\pithe prior probabilities (fieldpriorof the class ParamHMMR) and\boldsymbol{A}the transition matrix (fieldtrans_matof the class ParamHMMR) of the Markov chain.BICNumeric. Value of BIC (Bayesian Information Criterion).
AICNumeric. Value of AIC (Akaike Information Criterion).
regressorsMatrix of size
(m, K)giving the values of the estimated polynomial regression components.predict_probMatrix of size
(m, K)giving the prediction probabilities:P(z_{t} = k | y_{1},\dots,y_{t-1}).predictedRow matrix of size
(m, 1)giving the sum of the polynomial components weighted by the prediction probabilitiespredict_prob.filter_probMatrix of size
(m, K)giving the filtering probabilitiesPr(z_{t} = k | y_{1},\dots,y_{t}).filteredRow matrix of size
(m, 1)giving the sum of the polynomial components weighted by the filtering probabilities.smoothed_regressorsMatrix of size
(m, K)giving the polynomial components weighted by the posterior probabilitytau_tk.smoothedRow matrix of size
(m, 1)giving the sum of the polynomial components weighted by the posterior probabilitytau_tk.
Methods
computeLikelihood(paramHMMR)Method to compute the log-likelihood based on some parameters given by the object
paramHMMRof class ParamHMMR.computeStats(paramHMMR)Method used in the EM algorithm to compute statistics based on parameters provided by the object
paramHMMRof class ParamHMMR.EStep(paramHMMR)Method used in the EM algorithm to update statistics based on parameters provided by the object
paramHMMRof class ParamHMMR (prior and posterior probabilities).MAP()MAP calculates values of the fields
z_ikandklasby applying the Maximum A Posteriori Bayes allocation rule.z\_ik = 1 \ \textrm{if} \ z\_ik = \textrm{arg} \ \textrm{max}_{s} \ P(z_{i} = s | \boldsymbol{Y}) = tau\_tk;\ 0 \ \textrm{otherwise}
See Also
A Reference Class which contains statistics of a MHMMR model.
Description
StatMHMMR contains all the statistics associated to a MHMMR model. It mainly includes the E-Step of the EM algorithm calculating the posterior distribution of the hidden variables (ie the smoothing probabilities), as well as the calculation of the prediction and filtering probabilities, the log-likelhood at each step of the algorithm and the obtained values of model selection criteria..
Fields
tau_tkMatrix of size
(m, K)giving the posterior probability that the observationY_{i}originates from thek-th regression model.alpha_tkMatrix of size
(m, K)giving the forwards probabilities:P(Y_{1},\dots,Y_{t}, z_{t} = k).beta_tkMatrix of size
(m, K), giving the backwards probabilities:P(Y_{t+1},\dots,Y_{m} | z_{t} = k).xi_tklArray of size
(m - 1, K, K)giving the joint post probabilities:xi_tk[t, k, l] = P(z_{t} = k, z_{t-1} = l | \boldsymbol{Y})fort = 2,\dots,m.f_tkMatrix of size
(m, K)giving the cumulative distribution functionf(y_{t} | z{_t} = k).log_f_tkMatrix of size
(m, K)giving the logarithm of the cumulative distributionf_tk.loglikNumeric. Log-likelihood of the MHMMR model.
stored_loglikNumeric vector. Stored values of the log-likelihood at each iteration of the EM algorithm.
klasColumn matrix of the labels issued from
z_ik. Its elements areklas(i) = k,k = 1,\dots,K.z_ikHard segmentation logical matrix of dimension
(m, K)obtained by the Maximum a posteriori (MAP) rule:z\_ik = 1 \ \textrm{if} \ z\_ik = \textrm{arg} \ \textrm{max}_{s} \ P(z_{i} = s | \boldsymbol{Y}) = tau\_tk;\ 0 \ \textrm{otherwise},k = 1,\dots,K.state_probsMatrix of size
(m, K)giving the distribution of the Markov chain.P(z_{1},\dots,z_{m};\pi,\boldsymbol{A})with\pithe prior probabilities (fieldpriorof the class ParamMHMMR) and\boldsymbol{A}the transition matrix (fieldtrans_matof the class ParamMHMMR) of the Markov chain.BICNumeric. Value of BIC (Bayesian Information Criterion).
AICNumeric. Value of AIC (Akaike Information Criterion).
regressorsMatrix of size
(m, K)giving the values of the estimated polynomial regression components.predict_probMatrix of size
(m, K)giving the prediction probabilities:P(z_{t} = k | y_{1},\dots,y_{t-1}).predictedRow matrix of size
(m, 1)giving the sum of the polynomial components weighted by the prediction probabilitiespredict_prob.filter_probMatrix of size
(m, K)giving the filtering probabilitiesPr(z_{t} = k | y_{1},\dots,y_{t}).filteredRow matrix of size
(m, 1)giving the sum of the polynomial components weighted by the filtering probabilities.smoothed_regressorsMatrix of size
(m, K)giving the polynomial components weighted by the posterior probabilitytau_tk.smoothedRow matrix of size
(m, 1)giving the sum of the polynomial components weighted by the posterior probabilitytau_tk.
Methods
computeLikelihood(paramMHMMR)Method to compute the log-likelihood based on some parameters given by the object
paramMHMMRof class ParamMHMMR.computeStats(paramMHMMR)Method used in the EM algorithm to compute statistics based on parameters provided by the object
paramMHMMRof class ParamMHMMR.EStep(paramMHMMR)Method used in the EM algorithm to update statistics based on parameters provided by the object
paramMHMMRof class ParamMHMMR (prior and posterior probabilities).MAP()MAP calculates values of the fields
z_ikandklasby applying the Maximum A Posteriori Bayes allocation rule.z\_ik = 1 \ \textrm{if} \ z\_ik = \textrm{arg} \ \textrm{max}_{s} \ P(z_{i} = s | \boldsymbol{Y}) = tau\_tk;\ 0 \ \textrm{otherwise}
See Also
A Reference Class which contains statistics of a MRHLP model.
Description
StatMRHLP contains all the statistics associated to a MRHLP model. It mainly includes the E-Step of the EM algorithm calculating the posterior distribution of the hidden variables, as well as the calculation of the log-likelhood at each step of the algorithm and the obtained values of model selection criteria..
Fields
pi_ikMatrix of size
(m, K)representing the prior/logistic probabilities\pi_{k}(x_{i}; \boldsymbol{\Psi}) = P(z_{i} = k | \boldsymbol{x}; \Psi)of the latent variablez_{i}, i = 1,\dots,m.z_ikHard segmentation logical matrix of dimension
(m, K)obtained by the Maximum a posteriori (MAP) rule:z\_ik = 1 \ \textrm{if} \ z\_ik = \textrm{arg} \ \textrm{max}_{s} \ \pi_{s}(x_{i}; \boldsymbol{\Psi});\ 0 \ \textrm{otherwise},k = 1,\dots,K.klasColumn matrix of the labels issued from
z_ik. Its elements areklas(i) = k,k = 1,\dots,K.tau_ikMatrix of size
(m, K)giving the posterior probability that the observationY_{i}originates from thek-th regression model.polynomialsArray of size
(m, d, K)giving the values of the estimated polynomial regression components.weighted_polynomialsArray of size
(m, d, K)giving the values of the estimated polynomial regression components weighted by the prior probabilitiespi_ik.ExMatrix of size (m, d).
Exis the curve expectation (estimated signal): sum of the polynomial components weighted by the logistic probabilitiespi_ik.loglikNumeric. Observed-data log-likelihood of the MRHLP model.
com_loglikNumeric. Complete-data log-likelihood of the MRHLP model.
stored_loglikNumeric vector. Stored values of the log-likelihood at each EM iteration.
stored_com_loglikNumeric vector. Stored values of the Complete log-likelihood at each EM iteration.
BICNumeric. Value of BIC (Bayesian Information Criterion).
ICLNumeric. Value of ICL (Integrated Completed Likelihood).
AICNumeric. Value of AIC (Akaike Information Criterion).
log_piik_fikMatrix of size
(m, K)giving the values of the logarithm of the joint probabilityP(y_{i}, \ z_{i} = k | \boldsymbol{x}, \boldsymbol{\Psi}),i = 1,\dots,m.log_sum_piik_fikColumn matrix of size m giving the values of
\textrm{log} \sum_{k = 1}^{K} P(y_{i}, \ z_{i} = k | \boldsymbol{x}, \boldsymbol{\Psi}),i = 1,\dots,m.
Methods
computeLikelihood(reg_irls)Method to compute the log-likelihood.
reg_irlsis the value of the regularization part in the IRLS algorithm.computeStats(paramMRHLP)Method used in the EM algorithm to compute statistics based on parameters provided by the object
paramMRHLPof class ParamMRHLP.EStep(paramMRHLP)Method used in the EM algorithm to update statistics based on parameters provided by the object
paramMRHLPof class ParamMRHLP (prior and posterior probabilities).MAP()MAP calculates values of the fields
z_ikandklasby applying the Maximum A Posteriori Bayes allocation rule.z_{ik} = 1 \ \textrm{if} \ k = \textrm{arg} \ \textrm{max}_{s} \ \pi_{s}(x_{i}; \boldsymbol{\Psi});\ 0 \ \textrm{otherwise}
See Also
A Reference Class which contains statistics of a PWR model.
Description
StatPWR contains all the statistics associated to a PWR model.
Fields
z_ikLogical matrix of dimension
(m, K)giving the class vector.klasColumn matrix of the labels issued from
z_ik. Its elements areklas(i) = k,k = 1,\dots,K.mean_functionApproximation of the time series given the estimated parameters.
mean_functionis a matrix of size(m, 1).regressorsMatrix of size
(m, K)giving the values of the estimated polynomial regression components.objectiveNumeric. Value of the objective function.
Methods
computeStats(paramPWR)Method used at the end of the dynamic programming algorithm to compute statistics based on parameters provided by
paramPWR.
See Also
A Reference Class which contains statistics of a RHLP model.
Description
StatRHLP contains all the statistics associated to a RHLP model. It mainly includes the E-Step of the EM algorithm calculating the posterior distribution of the hidden variables, as well as the calculation of the log-likelhood at each step of the algorithm and the obtained values of model selection criteria..
Fields
pi_ikMatrix of size
(m, K)representing the prior/logistic probabilities\pi_{k}(x_{i}; \boldsymbol{\Psi}) = P(z_{i} = k | \boldsymbol{x}; \Psi)of the latent variablez_{i}, i = 1,\dots,m.z_ikHard segmentation logical matrix of dimension
(m, K)obtained by the Maximum a posteriori (MAP) rule:z\_ik = 1 \ \textrm{if} \ z\_ik = \textrm{arg} \ \textrm{max}_{s} \ \pi_{s}(x_{i}; \boldsymbol{\Psi});\ 0 \ \textrm{otherwise},k = 1,\dots,K.klasColumn matrix of the labels issued from
z_ik. Its elements areklas(i) = k,k = 1,\dots,K.tau_ikMatrix of size
(m, K)giving the posterior probability that the observationY_{i}originates from thek-th regression model.polynomialsMatrix of size
(m, K)giving the values of the estimated polynomial regression components.ExColumn matrix of dimension m.
Exis the curve expectation (estimated signal): sum of the polynomial components weighted by the logistic probabilitiespi_ik.loglikNumeric. Observed-data log-likelihood of the RHLP model.
com_loglikNumeric. Complete-data log-likelihood of the RHLP model.
stored_loglikNumeric vector. Stored values of the log-likelihood at each EM iteration.
stored_com_loglikNumeric vector. Stored values of the Complete log-likelihood at each EM iteration.
BICNumeric. Value of BIC (Bayesian Information Criterion).
ICLNumeric. Value of ICL (Integrated Completed Likelihood).
AICNumeric. Value of AIC (Akaike Information Criterion).
log_piik_fikMatrix of size
(m, K)giving the values of the logarithm of the joint probabilityP(y_{i}, \ z_{i} = k | \boldsymbol{x}, \boldsymbol{\Psi}),i = 1,\dots,m.log_sum_piik_fikColumn matrix of size m giving the values of
\textrm{log} \sum_{k = 1}^{K} P(y_{i}, \ z_{i} = k | \boldsymbol{x}, \boldsymbol{\Psi}),i = 1,\dots,m.
Methods
computeLikelihood(reg_irls)Method to compute the log-likelihood.
reg_irlsis the value of the regularization part in the IRLS algorithm.computeStats(paramRHLP)Method used in the EM algorithm to compute statistics based on parameters provided by the object
paramRHLPof class ParamRHLP.EStep(paramRHLP)Method used in the EM algorithm to update statistics based on parameters provided by the object
paramRHLPof class ParamRHLP (prior and posterior probabilities).MAP()MAP calculates values of the fields
z_ikandklasby applying the Maximum A Posteriori Bayes allocation rule.z_{ik} = 1 \ \textrm{if} \ k = \textrm{arg} \ \textrm{max}_{s} \ \pi_{s}(x_{i}; \boldsymbol{\Psi});\ 0 \ \textrm{otherwise}
See Also
emHMMR implemens the EM (Baum-Welch) algorithm to fit a HMMR model.
Description
emHMMR implements the maximum-likelihood parameter estimation of the HMMR model by the Expectation-Maximization (EM) algorithm, known as Baum-Welch algorithm in the context of HMMs.
Usage
emHMMR(X, Y, K, p = 3, variance_type = c("heteroskedastic",
"homoskedastic"), n_tries = 1, max_iter = 1500, threshold = 1e-06,
verbose = FALSE)
Arguments
X |
Numeric vector of length m representing the covariates/inputs
|
Y |
Numeric vector of length m representing the observed
response/output |
K |
The number of regimes/segments (HMMR components). |
p |
Optional. The order of the polynomial regression. By default, |
variance_type |
Optional character indicating if the model is "homoskedastic" or "heteroskedastic" (i.e same variance or different variances for each of the K regmies). By default the model is "heteroskedastic". |
n_tries |
Optional. Number of runs of the EM algorithm. The solution providing the highest log-likelihood will be returned. If |
max_iter |
Optional. The maximum number of iterations for the EM algorithm. |
threshold |
Optional. A numeric value specifying the threshold for the relative difference of log-likelihood between two steps of the EM as stopping criteria. |
verbose |
Optional. A logical value indicating whether or not values of the log-likelihood should be printed during EM iterations. |
Details
emHMMR function implements the EM algorithm for the HMMR model. This
function starts with an initialization of the parameters done by the method
initParam of the class ParamHMMR, then it alternates between
the E-Step (method of the class StatHMMR) and the M-Step
(method of the class ParamHMMR) until convergence (until the
relative variation of log-likelihood between two steps of the EM algorithm
is less than the threshold parameter).
Value
EM returns an object of class ModelHMMR.
See Also
ModelHMMR, ParamHMMR, StatHMMR
Examples
data(univtoydataset)
hmmr <- emHMMR(univtoydataset$x, univtoydataset$y, K = 5, p = 1, verbose = TRUE)
hmmr$summary()
hmmr$plot()
emMHMMR implemens the EM (Baum-Welch) algorithm to fit a MHMMR model.
Description
emMHMMR implements the maximum-likelihood parameter estimation of the MHMMR model by the Expectation-Maximization (EM) algorithm, known as Baum-Welch algorithm in the context of HMMs.
Usage
emMHMMR(X, Y, K, p = 3, variance_type = c("heteroskedastic",
"homoskedastic"), n_tries = 1, max_iter = 1500, threshold = 1e-06,
verbose = FALSE)
Arguments
X |
Numeric vector of length m representing the covariates/inputs
|
Y |
Matrix of size |
K |
The number of regimes (MHMMR components). |
p |
Optional. The order of the polynomial regression. By default, |
variance_type |
Optional character indicating if the model is "homoskedastic" or "heteroskedastic". By default the model is "heteroskedastic". |
n_tries |
Optional. Number of runs of the EM algorithm. The solution providing the highest log-likelihood will be returned. If |
max_iter |
Optional. The maximum number of iterations for the EM algorithm. |
threshold |
Optional. A numeric value specifying the threshold for the relative difference of log-likelihood between two steps of the EM as stopping criteria. |
verbose |
Optional. A logical value indicating whether or not values of the log-likelihood should be printed during EM iterations. |
Details
emMHMMR function implements the EM algorithm. This function starts
with an initialization of the parameters done by the method initParam of
the class ParamMHMMR, then it alternates between the E-Step
(method of the class StatMHMMR) and the M-Step (method of the
class ParamMHMMR) until convergence (until the relative
variation of log-likelihood between two steps of the EM algorithm is less
than the threshold parameter).
Value
EM returns an object of class ModelMHMMR.
See Also
ModelMHMMR, ParamMHMMR, StatMHMMR
Examples
data(multivtoydataset)
mhmmr <- emMHMMR(multivtoydataset$x, multivtoydataset[,c("y1", "y2", "y3")],
K = 5, p = 1, verbose = TRUE)
mhmmr$summary()
mhmmr$plot()
emMRHLP implemens the EM algorithm to fit a MRHLP model.
Description
emMRHLP implements the maximum-likelihood parameter estimation of the MRHLP model by the Expectation-Maximization (EM) algorithm.
Usage
emMRHLP(X, Y, K, p = 3, q = 1, variance_type = c("heteroskedastic",
"homoskedastic"), n_tries = 1, max_iter = 1500, threshold = 1e-06,
verbose = FALSE, verbose_IRLS = FALSE)
Arguments
X |
Numeric vector of length m representing the covariates/inputs
|
Y |
Matrix of size |
K |
The number of regimes (MRHLP components). |
p |
Optional. The order of the polynomial regression. By default, |
q |
Optional. The dimension of the logistic regression. For the purpose of segmentation, it must be set to 1 (which is the default value). |
variance_type |
Optional character indicating if the model is "homoskedastic" or "heteroskedastic". By default the model is "heteroskedastic". |
n_tries |
Optional. Number of runs of the EM algorithm. The solution providing the highest log-likelihood will be returned. If |
max_iter |
Optional. The maximum number of iterations for the EM algorithm. |
threshold |
Optional. A numeric value specifying the threshold for the relative difference of log-likelihood between two steps of the EM as stopping criteria. |
verbose |
Optional. A logical value indicating whether or not values of the log-likelihood should be printed during EM iterations. |
verbose_IRLS |
Optional. A logical value indicating whether or not values of the criterion optimized by IRLS should be printed at each step of the EM algorithm. |
Details
emMRHLP function implements the EM algorithm of the MRHLP model.
This function starts with an initialization of the parameters done by the
method initParam of the class ParamMRHLP, then it
alternates between the E-Step (method of the class StatMRHLP)
and the M-Step (method of the class ParamMRHLP) until
convergence (until the relative variation of log-likelihood between two
steps of the EM algorithm is less than the threshold parameter).
Value
EM returns an object of class ModelMRHLP.
See Also
ModelMRHLP, ParamMRHLP, StatMRHLP
Examples
data(multivtoydataset)
mrhlp <- emMRHLP(multivtoydataset$x, multivtoydataset[,c("y1", "y2", "y3")],
K = 5, p = 1, verbose = TRUE)
mrhlp$summary()
mrhlp$plot()
emRHLP implements the EM algorithm to fit a RHLP model.
Description
emRHLP implements the maximum-likelihood parameter estimation of the RHLP model by the Expectation-Maximization (EM) algorithm.
Usage
emRHLP(X, Y, K, p = 3, q = 1, variance_type = c("heteroskedastic",
"homoskedastic"), n_tries = 1, max_iter = 1500, threshold = 1e-06,
verbose = FALSE, verbose_IRLS = FALSE)
Arguments
X |
Numeric vector of length m representing the covariates/inputs
|
Y |
Numeric vector of length m representing the observed
response/output |
K |
The number of regimes (RHLP components). |
p |
Optional. The order of the polynomial regression. By default, |
q |
Optional. The dimension of the logistic regression. For the purpose of segmentation, it must be set to 1 (which is the default value). |
variance_type |
Optional character indicating if the model is "homoskedastic" or "heteroskedastic". By default the model is "heteroskedastic". |
n_tries |
Optional. Number of runs of the EM algorithm. The solution providing the highest log-likelihood will be returned. If |
max_iter |
Optional. The maximum number of iterations for the EM algorithm. |
threshold |
Optional. A numeric value specifying the threshold for the relative difference of log-likelihood between two steps of the EM as stopping criteria. |
verbose |
Optional. A logical value indicating whether or not values of the log-likelihood should be printed during EM iterations. |
verbose_IRLS |
Optional. A logical value indicating whether or not values of the criterion optimized by IRLS should be printed at each step of the EM algorithm. |
Details
emRHLP function implements the EM algorithm for the RHLP model. This
function starts with an initialization of the parameters done by the method
initParam of the class ParamRHLP, then it alternates between
the E-Step (method of the class StatRHLP) and the M-Step
(method of the class ParamRHLP) until convergence (until the
relative variation of log-likelihood between two steps of the EM algorithm
is less than the threshold parameter).
Value
EM returns an object of class ModelRHLP.
See Also
ModelRHLP, ParamRHLP, StatRHLP
Examples
data(univtoydataset)
rhlp <- emRHLP(univtoydataset$x, univtoydataset$y, K = 3, p = 1, verbose = TRUE)
rhlp$summary()
rhlp$plot()
fitPWRFisher implements an optimized dynamic programming algorithm to fit a PWR model.
Description
fitPWRFisher is used to fit a Piecewise Regression (PWR) model by maximum-likelihood via an optimized dynamic programming algorithm. The estimation performed by the dynamic programming algorithm provides an optimal segmentation of the time series.
Usage
fitPWRFisher(X, Y, K, p = 3)
Arguments
X |
Numeric vector of length m representing the covariates/inputs
|
Y |
Numeric vector of length m representing the observed
response/output |
K |
The number of regimes/segments (PWR components). |
p |
Optional. The order of the polynomial regression. By default, |
Details
fitPWRFisher function implements an optimized dynamic programming
algorithm of the PWR model. This function starts with the calculation of
the "cost matrix" then it estimates the transition points given K the
number of regimes thanks to the method computeDynamicProgram (method of
the class ParamPWR).
Value
fitPWRFisher returns an object of class ModelPWR.
See Also
Examples
data(univtoydataset)
pwr <- fitPWRFisher(univtoydataset$x, univtoydataset$y, K = 5, p = 1)
pwr$summary()
pwr$plot()
hmmProcess calculates the probability distribution of a random process following a Markov chain
Description
hmmProcess calculates the probability distribution of a random process following a Markov chain
Usage
hmmProcess(prior, trans_mat, n)
Arguments
prior |
Numeric vector or a one row matrix of length K representing the prior probabilities of the Markov chain. |
trans_mat |
Matrix of size |
n |
Numeric. Number of variables of the Markov chain. |
Details
hmmProcess calculates the distribution
P(Z_{1},\dots,Z_{n};\pi,A) of a Markov chain
(Z_{1},\dots,Z_{n}) with prior probability \pi and transition
matrix A.
The calculation is based on the following formula:
P(Z_{i} = k) = \sum_{l} P(Z_{i} = k, Z_{i-1} = l) = \sum_{l} P(Z_{i} =
k | Z_{i-1} = l) \times P(Z_{i-1} = l) = \sum_{l} A_{lk} \times
P(Z_{i-1})
Value
Matrix of size (n, K) giving the distribution of process given
the K-state Markov chain parameters.
mkStochastic ensures that it is a stochastic vector, matrix or array.
Description
mkStochastic ensures that it is a stochastic vector, matrix or array.
Usage
mkStochastic(M)
Arguments
M |
A vector, matrix or array to transform. |
Details
mkStochastic ensures that the giving argument is a stochastic vector, matrix or array, i.e., that the sum over the last dimension is 1.
Value
A vector, matrix or array for which the sum over the last dimension is 1.
Time series representing the three acceleration components recorded over time with body mounted accelerometers during the activity of a given person.
Description
This dataset is provided for illustration only and represents the three acceleration components recorded over time with body mounted accelerometers during the activity of a given person. These data consist therefore of multidimensional time series with several regime changes over time, each regime is associated with an activity.
Usage
multivrealdataset
Format
A data frame with 2253 rows and 4 columns:
- x
The covariate variable (the sampling time).
- y1
X axis component of the acceleration.
- y2
Y axis component of the acceleration.
- y3
Z axis component of the acceleration.
A simulated non-stationary multidimensional time series with regime changes.
Description
A simulated non-stationary multidimensional time series with five regimes (segments). This time series is used for illustration.
Usage
multivtoydataset
Format
A data frame with 670 rows and 4 columns:
- x
The covariate variable (the sampling time for time series).
- y1
The first dimension of the time series. The latter has been generated as follows:
First regime: 100 values of standard Normally distributed random numbers.
Second regime: 120 values of Normally distributed random numbers with mean 7 and unit variance.
Third regime: 200 values of Normally distributed random numbers with mean 4 and unit variance.
Fourth regime: 100 values of Normally distributed random numbers with mean -1 and unit variance.
Fifth regime: 150 values of Normally distributed random numbers with mean 3.5 and unit variance.
- y2
The second dimension of the time series. The latter has been generated as follows:
First regime: 100 values of Normally distributed random numbers with mean 1 and unit variance.
Second regime: 120 values of Normally distributed random numbers with mean 5 and unit variance.
Third regime: 200 values of Normally distributed random numbers with mean 6 and unit variance.
Fourth regime: 100 values of Normally distributed random numbers with mean -2 and unit variance.
Fifth regime: 150 values of Normally distributed random numbers with mean 2 and unit variance.
- y3
The third dimension of the time series. The latter has been generated as follows:
First regime: 100 values of Normally distributed random numbers with mean -2 and unit variance.
Second regime: 120 values of Normally distributed random numbers with mean 10 and unit variance.
Third regime: 200 values of Normally distributed random numbers with mean 8 and unit variance.
Fourth regime: 100 values of Normally distributed random numbers and unit variance.
Fifth regime: 150 values of Normally distributed random numbers with mean 5 and unit variance.
selectHMMR implements a model selection procedure to select an optimal HMMR model with unknown structure.
Description
selectHMMR implements a model selection procedure to select an optimal HMMR model with unknown structure.
Usage
selectHMMR(X, Y, Kmin = 1, Kmax = 10, pmin = 0, pmax = 4,
criterion = c("BIC", "AIC"), verbose = TRUE)
Arguments
X |
Numeric vector of length m representing the covariates/inputs
|
Y |
Numeric vector of length m representing the observed
response/output |
Kmin |
The minimum number of regimes (HMMR components). |
Kmax |
The maximum number of regimes (HMMR components). |
pmin |
The minimum order of the polynomial regression. |
pmax |
The maximum order of the polynomial regression. |
criterion |
The criterion used to select the HMMR model ("BIC", "AIC"). |
verbose |
Optional. A logical value indicating whether or not a summary of the selected model should be displayed. |
Details
selectHMMR selects the optimal HMMR model among a set of model
candidates by optimizing a model selection criteria, including the Bayesian
Information Criterion (BIC). This function first fits the different HMMR
model candidates by varying the number of regimes K from Kmin to Kmax
and the order of the polynomial regression p from pmin to pmax. The
model having the highest value of the chosen selection criterion is then
selected.
Value
selectHMMR returns an object of class ModelHMMR
representing the selected HMMR model according to the chosen criterion.
See Also
Examples
data(univtoydataset)
selectedhmmr <- selectHMMR(X = univtoydataset$x, Y = univtoydataset$y,
Kmin = 2, Kmax = 6, pmin = 0, pmax = 2)
selectedhmmr$plot()
selectMHMMR implements a model selection procedure to select an optimal MHMMR model with unknown structure.
Description
selectMHMMR implements a model selection procedure to select an optimal MHMMR model with unknown structure.
Usage
selectMHMMR(X, Y, Kmin = 1, Kmax = 10, pmin = 0, pmax = 4,
criterion = c("BIC", "AIC"), verbose = TRUE)
Arguments
X |
Numeric vector of length m representing the covariates/inputs
|
Y |
Matrix of size |
Kmin |
The minimum number of regimes (c components). |
Kmax |
The maximum number of regimes (MHMMR components). |
pmin |
The minimum order of the polynomial regression. |
pmax |
The maximum order of the polynomial regression. |
criterion |
The criterion used to select the MHMMR model ("BIC", "AIC"). |
verbose |
Optional. A logical value indicating whether or not a summary of the selected model should be displayed. |
Details
selectMHMMR selects the optimal MHMMR model among a set of model
candidates by optimizing a model selection criteria, including the Bayesian
Information Criterion (BIC). This function first fits the different MHMMR
model candidates by varying the number of regimes K from Kmin to Kmax
and the order of the polynomial regression p from pmin to pmax. The
model having the highest value of the chosen selection criterion is then
selected.
Value
selectMHMMR returns an object of class ModelMHMMR
representing the selected MHMMR model according to the chosen criterion.
See Also
Examples
data(multivtoydataset)
x <- multivtoydataset$x
y <- multivtoydataset[, c("y1", "y2", "y3")]
selectedmhmmr <- selectMHMMR(X = x, Y = y, Kmin = 2, Kmax = 6,
pmin = 0, pmax = 2)
selectedmhmmr$summary()
selecMRHLP implements a model selection procedure to select an optimal MRHLP model with unknown structure.
Description
selecMRHLP implements a model selection procedure to select an optimal MRHLP model with unknown structure.
Usage
selectMRHLP(X, Y, Kmin = 1, Kmax = 10, pmin = 0, pmax = 4,
criterion = c("BIC", "AIC"), verbose = TRUE)
Arguments
X |
Numeric vector of length m representing the covariates/inputs
|
Y |
Matrix of size |
Kmin |
The minimum number of regimes (MRHLP components). |
Kmax |
The maximum number of regimes (MRHLP components). |
pmin |
The minimum order of the polynomial regression. |
pmax |
The maximum order of the polynomial regression. |
criterion |
The criterion used to select the MRHLP model ("BIC", "AIC"). |
verbose |
Optional. A logical value indicating whether or not a summary of the selected model should be displayed. |
Details
selectMRHLP selects the optimal MRHLP model among a set of model
candidates by optimizing a model selection criteria, including the Bayesian
Information Criterion (BIC). This function first fits the different MRHLP
model candidates by varying the number of regimes K from Kmin to Kmax
and the order of the polynomial regression p from pmin to pmax. The
model having the highest value of the chosen selection criterion is then
selected.
Value
selectMRHLP returns an object of class ModelMRHLP
representing the selected MRHLP model according to the chosen criterion.
See Also
Examples
data(multivtoydataset)
# Let's select a MRHLP model on a multivariate time series with 3 regimes:
data <- multivtoydataset[1:320, ]
x <- data$x
y <- data[, c("y1", "y2", "y3")]
selectedmrhlp <- selectMRHLP(X = x, Y = y, Kmin = 2, Kmax = 4,
pmin = 0, pmax = 1)
selectedmrhlp$summary()
selecRHLP implements a model selection procedure to select an optimal RHLP model with unknown structure.
Description
selecRHLP implements a model selection procedure to select an optimal RHLP model with unknown structure.
Usage
selectRHLP(X, Y, Kmin = 1, Kmax = 10, pmin = 0, pmax = 4,
criterion = c("BIC", "AIC"), verbose = TRUE)
Arguments
X |
Numeric vector of length m representing the covariates/inputs
|
Y |
Numeric vector of length m representing the observed
response/output |
Kmin |
The minimum number of regimes (RHLP components). |
Kmax |
The maximum number of regimes (RHLP components). |
pmin |
The minimum order of the polynomial regression. |
pmax |
The maximum order of the polynomial regression. |
criterion |
The criterion used to select the RHLP model ("BIC", "AIC"). |
verbose |
Optional. A logical value indicating whether or not a summary of the selected model should be displayed. |
Details
selectRHLP selects the optimal MRHLP model among a set of model
candidates by optimizing a model selection criteria, including the Bayesian
Information Criterion (BIC). This function first fits the different RHLP
model candidates by varying the number of regimes K from Kmin to Kmax
and the order of the polynomial regression p from pmin to pmax. The
model having the highest value of the chosen selection criterion is then
selected.
Value
selectRHLP returns an object of class ModelRHLP
representing the selected RHLP model according to the chosen criterion.
See Also
Examples
data(univtoydataset)
# Let's select a RHLP model on a time series with 3 regimes:
data <- univtoydataset[1:320,]
selectedrhlp <- selectRHLP(X = data$x, Y = data$y,
Kmin = 2, Kmax = 4, pmin = 0, pmax = 1)
selectedrhlp$summary()
Time series representing the electrical power consumption during a railway switch operation
Description
This dataset is provided for illustration only; It is issued from the switch railway monitoring domain. The switch mechanism enables trains to be guided from one track to another at a railway junction. During each switch operation, a set of measurements are recorded. Each measurement represents the consumed electrical power. The resulting time series present regime changes.
Usage
univrealdataset
Format
A data frame with 562 rows and 3 columns:
- x
The covariate variables which are the sampling time in this time-series case.
- y1
Measurements of the electrical power consumed during time for a first example of switch operations.
- y2
Measurements of the electrical power consumed during during time for another example of switch operations.
A simulated non-stationary time series with regime changes.
Description
A simulated non-stationary time series with regime changes. This time series is used for illustration.
Usage
univtoydataset
Format
A data frame with 670 rows and 2 columns:
- x
The covariate variable which is the time in this time-series case.
- y
The time series. The latter has been generated as follows:
First regime: 100 values of standard Normally distributed random numbers.
Second regime: 120 values of Normally distributed random numbers with mean 7 and unit variance.
Third regime: 200 values of Normally distributed random numbers with mean 4 and unit variance.
Fourth regime: 100 values of Normally distributed random numbers with mean -2 and unit variance.
Fifth regime: 150 values of Normally distributed random numbers with mean 3.5 and unit variance.