Function that performs the time series clustering algorithm described in Nieto-Barajas and Contreras-Cristan (2014) for monthly time series data.

1 2 3 4 5 6 | ```
tseriescm(data, maxiter = 1000, burnin = floor(0.1 * maxiter),
thinning = 5, level = FALSE, trend = TRUE, seasonality = TRUE,
deg = 2,c0eps = 2, c1eps = 1, c0beta = 2, c1beta = 1,
c0alpha = 2,c1alpha = 1, priora = FALSE, pia = 0.5, q0a = 1,
q1a = 1, priorb = FALSE, q0b = 1, q1b = 1, a = 0.25, b = 0,
indlpml = FALSE)
``` |

`data` |
Data frame with the time series information. |

`maxiter` |
Maximum number of iterations for Gibbs sampling. |

`burnin` |
Burn-in period of the Markov Chain generated by Gibbs sampling. |

`thinning` |
Number that indicates how many Gibbs sampling simulations should be skipped to form the Markov Chain. |

`level` |
Flag that indicates if the level of the time series will be considered for clustering. If TRUE, then it is taken into account. |

`trend` |
Flag that indicates if the polinomial trend of the model will be considered for clustering. If TRUE, then it is taken into account. |

`seasonality` |
Flag that indicates if the seasonal components of the model will be considered for clustering. If TRUE, then they are taken into account. |

`deg` |
Degree of the polinomial trend of the model. |

`c0eps` |
Shape parameter of the hyper-prior distribution on sig2eps. |

`c1eps` |
Rate parameter of the hyper-prior distribution on sig2eps. |

`c0beta` |
Shape parameter of the hyper-prior distribution on sig2beta. |

`c1beta` |
Rate parameter of the hyper-prior distribution on sig2beta. |

`c0alpha` |
Shape parameter of the hyper-prior distribution on sig2alpha. |

`c1alpha` |
Rate parameter of the hyper-prior distribution on sig2alpha. |

`priora` |
Flag that indicates if a prior on parameter "a" is to be assigned. If TRUE, a prior on "a" is assigned. |

`pia` |
Mixing proportion of the prior distribution on parameter "a". |

`q0a` |
Shape parameter of the continuous part of the prior distribution on parameter "a". |

`q1a` |
Shape parameter of the continuous part of the prior distribution on parameter "a". |

`priorb` |
Flag that indicates if a prior on parameter "b" is to be assigned. If TRUE, a prior on "b" is assigned. |

`q0b` |
Shape parameter of the prior distribution on parameter "b". |

`q1b` |
Shape parameter of the prior distribution on parameter "b". |

`a` |
Initial/fixed value of parameter "a". |

`b` |
Initial/fixed value of parameter "b". |

`indlpml` |
Flag that indicates if the LPML is to be calculated. If TRUE, LPML is calculated. |

It is assumed that the time series data is organized into a data frame with the time periods included as its row names.

`mstar` |
Number of groups of the chosen cluster configuration. |

`gnstar` |
Array that contains the group number to which each time series belongs. |

`HM` |
Heterogeneity Measure of the chosen cluster configuration. |

`arrho` |
Acceptance rate of the parameter "rho". |

`ara` |
Acceptance rate of the parameter "a". |

`arb` |
Acceptance rate of the parameter "b". |

`sig2epssample` |
Matrix that in its columns contains the sample of each sig2eps_i's posterior distribution after Gibbs sampling. |

`sig2alphasample` |
Matrix that in its columns contains the sample of each sig2alpha_i's posterior distribution after Gibbs sampling. |

`sig2betasample` |
Matrix that in its columns contains the sample of each sig2beta_i's posterior distribution after Gibbs sampling. |

`sig2thesample` |
Vector that contains the sample of sig2the's posterior distribution after Gibbs sampling. |

`rhosample` |
Vector that contains the sample of rho's posterior distribution after Gibbs sampling. |

`asample` |
Vector that contains the sample of a's posterior distribution after Gibbs sampling. |

`bsample` |
Vector that contains the sample of b's posterior distribution after Gibbs sampling. |

`msample` |
Vector that contains the sample of the number of groups at each Gibbs sampling iteration. |

`lpml` |
If indlpml = TRUE, lpml contains the value of the LPML of the chosen model. |

Martell-Juarez, D.A. and Nieto-Barajas, L.E.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 | ```
## Do not run
#
# data(stocks)
# tseriescm.out <- tseriescm(stocks,maxiter=4000,level=FALSE,trend=TRUE,
# seasonality=TRUE,a=0,b=1)
#
# The console output of the above example is:
#
# Number of groups of the chosen cluster configuration: 9
# Time series in group 1 : 1 2 4 5 7 10 12 13 19 21 22 25 29 30 31 33 34
# 40 41 42 43 44 46 47 48 49 52 57 58
# Time series in group 2 : 3 6 8 9 11 14 15 17 18 26 27 28 32 35 36 37 38
# 45 50 51 53 56
# Time series in group 3 : 16
# Time series in group 4 : 20
# Time series in group 5 : 23
# Time series in group 6 : 24
# Time series in group 7 : 39
# Time series in group 8 : 54
# Time series in group 9 : 55
# HM Measure: 199.2226
#
# Make sure that chain convergence is always assessed. Run the following
# code to show the cluster and diagnostic plots:
data(stocks)
data(tseriescm.out)
attach(tseriescm.out)
clusterplots(tseriescm.out,stocks)
diagplots(tseriescm.out)
``` |

Questions? Problems? Suggestions? Tweet to @rdrrHQ or email at ian@mutexlabs.com.

Please suggest features or report bugs with the GitHub issue tracker.

All documentation is copyright its authors; we didn't write any of that.

Embedding an R snippet on your website

Add the following code to your website.

For more information on customizing the embed code, read Embedding Snippets.