A-quick-tour-of-MRHLP

Introduction

MRHLP: Flexible and user-friendly probabilistic joint segmentation of multivariate time series (or multivariate structured longitudinal data) with smooth and/or abrupt regime changes by a mixture model-based multiple regression approach with a hidden logistic process, fitted by the EM algorithm.

It was written in R Markdown, using the knitr package for production.

See help(package="samurais") for further details and references provided by citation("samurais").

Load simulated data

data("multivtoydataset")

Set up MRHLP model parameters

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

Set up EM parameters

n_tries <- 1
max_iter <- 1500
threshold <- 1e-6
verbose <- TRUE
verbose_IRLS <- FALSE

Estimation

mrhlp <- emMRHLP(multivtoydataset$x, multivtoydataset[,c("y1", "y2", "y3")], 
                 K, p, q, variance_type, n_tries, max_iter, threshold, verbose,
                 verbose_IRLS)
## EM: Iteration : 1 || log-likelihood : -4975.54178073111
## EM: Iteration : 2 || log-likelihood : -3108.34368267019
## EM: Iteration : 3 || log-likelihood : -3083.17524307375
## EM: Iteration : 4 || log-likelihood : -3052.50226089162
## EM: Iteration : 5 || log-likelihood : -3020.60866899672
## EM: Iteration : 6 || log-likelihood : -2967.37662742306
## EM: Iteration : 7 || log-likelihood : -2948.61300517293
## EM: Iteration : 8 || log-likelihood : -2945.45995943558
## EM: Iteration : 9 || log-likelihood : -2937.99296968724
## EM: Iteration : 10 || log-likelihood : -2924.28973568246
## EM: Iteration : 11 || log-likelihood : -2901.25080458438
## EM: Iteration : 12 || log-likelihood : -2859.88249257022
## EM: Iteration : 13 || log-likelihood : -2858.05147236845
## EM: Iteration : 14 || log-likelihood : -2856.38015382933
## EM: Iteration : 15 || log-likelihood : -2854.68196743737
## EM: Iteration : 16 || log-likelihood : -2852.69581381481
## EM: Iteration : 17 || log-likelihood : -2849.93140705665
## EM: Iteration : 18 || log-likelihood : -2846.34467361507
## EM: Iteration : 19 || log-likelihood : -2843.82658707157
## EM: Iteration : 20 || log-likelihood : -2842.75921494243
## EM: Iteration : 21 || log-likelihood : -2842.23613093614
## EM: Iteration : 22 || log-likelihood : -2841.91343879009
## EM: Iteration : 23 || log-likelihood : -2841.66202746618
## EM: Iteration : 24 || log-likelihood : -2841.41784743305
## EM: Iteration : 25 || log-likelihood : -2841.1466892538
## EM: Iteration : 26 || log-likelihood : -2840.82033084757
## EM: Iteration : 27 || log-likelihood : -2840.39141036666
## EM: Iteration : 28 || log-likelihood : -2839.74532808446
## EM: Iteration : 29 || log-likelihood : -2838.62532246595
## EM: Iteration : 30 || log-likelihood : -2836.64319656469
## EM: Iteration : 31 || log-likelihood : -2833.87378893594
## EM: Iteration : 32 || log-likelihood : -2831.75584270117
## EM: Iteration : 33 || log-likelihood : -2831.16293540252
## EM: Iteration : 34 || log-likelihood : -2831.06467840063
## EM: Iteration : 35 || log-likelihood : -2831.06467489664

Summary

mrhlp$summary()
## ----------------------
## Fitted MRHLP model
## ----------------------
## 
## MRHLP model with K = 5 regimes
## 
##  log-likelihood nu       AIC       BIC       ICL
##       -2831.065 98 -2929.065 -3149.921 -3149.146
## 
## Clustering table:
##   1   2   3   4   5 
## 100 120 200 100 150 
## 
## 
## ------------------
## Regime 1 (K = 1):
## 
## Regression coefficients:
## 
##       Beta(d = 1)   Beta(d = 2) Beta(d = 3)
## 1       0.4466558     0.8104534    -2.36719
## X^1   -25.5100013   -20.5995360    32.75195
## X^2   413.8717640   498.0085618  -541.38904
## X^3 -1811.4612012 -2477.5546420  2523.64723
## 
## Covariance matrix:
##                                   
##  1.17712613  0.1114059  0.07303969
##  0.11140591  0.8394152 -0.02442220
##  0.07303969 -0.0244222  0.85240361
## ------------------
## Regime 2 (K = 2):
## 
## Regression coefficients:
## 
##     Beta(d = 1) Beta(d = 2) Beta(d = 3)
## 1      21.30187   -4.108239    1.838238
## X^1  -199.86512  112.953325  112.257782
## X^2   905.60445 -449.623857 -493.914613
## X^3 -1316.42937  581.197948  694.872075
## 
## Covariance matrix:
##                                     
##   1.0409982 -0.180821350 0.137568024
##  -0.1808214  1.042169409 0.009699162
##   0.1375680  0.009699162 0.754147599
## ------------------
## Regime 3 (K = 3):
## 
## Regression coefficients:
## 
##     Beta(d = 1) Beta(d = 2) Beta(d = 3)
## 1     4.4721830    9.349642    6.349724
## X^1   0.7467282  -33.315977   17.837763
## X^2 -11.9302818   96.730621  -51.086769
## X^3  16.1571109  -85.951201   42.760070
## 
## Covariance matrix:
##                                     
##   1.02026230 -0.04094457 -0.02544812
##  -0.04094457  1.15656511  0.02852275
##  -0.02544812  0.02852275  0.99750511
## ------------------
## Regime 4 (K = 4):
## 
## Regression coefficients:
## 
##     Beta(d = 1) Beta(d = 2) Beta(d = 3)
## 1      1267.288   -840.5119   -10.37768
## X^1   -5458.817   3613.7277    19.40202
## X^2    7813.123  -5184.1105    14.37102
## X^3   -3718.619   2475.7170   -29.55020
## 
## Covariance matrix:
##                                       
##   0.822157810  0.006792726 -0.03667011
##   0.006792726  1.093351046 -0.07477892
##  -0.036670114 -0.074778924  0.85425249
## ------------------
## Regime 5 (K = 5):
## 
## Regression coefficients:
## 
##     Beta(d = 1) Beta(d = 2) Beta(d = 3)
## 1      194.7894    12.88268    483.8383
## X^1   -658.4684   -45.73544  -1634.9481
## X^2    753.1086    61.92924   1858.1528
## X^3   -286.1078   -27.37495   -702.9064
## 
## Covariance matrix:
##                                 
##  1.1282728 0.25684915 0.02034990
##  0.2568491 1.21055927 0.04414336
##  0.0203499 0.04414336 0.77644297

Plots

Fitted regressors

mrhlp$plot(what = "regressors")

Estimated signal

mrhlp$plot(what = "estimatedsignal")

Log-likelihood

mrhlp$plot(what = "loglikelihood")