Function that performs the time series clustering algorithm described in Nieto-Barajas and Contreras-Cristan (2014) for annual time series data.
tseriesca(data, maxiter = 500, burnin = floor(0.1 * maxiter),
thinning = 5, scale = TRUE, level = FALSE, trend = TRUE, deg = 2,
c0eps = 2, c1eps = 1, c0beta = 2, c1beta = 1, c0alpha = 2, c1alpha = 1,
priora = TRUE, pia = 0.5, q0a = 1, q1a = 1, priorb = TRUE, q0b = 1,
q1b = 1, a = 0.25, b = 0, indlpml = FALSE)Data frame with the time series information.
Maximum number of iterations for Gibbs sampling.
Burn-in period of the Markov Chain generated by Gibbs sampling.
Number that indicates how many Gibbs sampling simulations should be skipped to form the Markov Chain.
Flag that indicates if the time series data should be scaled to the [0,1] interval with a linear transformation as proposed by Nieto-Barajas and Contreras-Cristan (2014). If TRUE, then the time series are scaled to the [0,1] interval.
Flag that indicates if the level of the time series will be considered for clustering. If TRUE, then it is taken into account.
Flag that indicates if the polinomial trend of the model will be considered for clustering. If TRUE, then it is taken into account.
Degree of the polinomial trend of the model.
Shape parameter of the hyper-prior distribution on sig2eps.
Rate parameter of the hyper-prior distribution on sig2eps.
Shape parameter of the hyper-prior distribution on sig2beta.
Rate parameter of the hyper-prior distribution on sig2beta.
Shape parameter of the hyper-prior distribution on sig2alpha.
Rate parameter of the hyper-prior distribution on sig2alpha.
Flag that indicates if a prior on parameter "a" is to be assigned. If TRUE, a prior on "a" is assigned.
Mixing proportion of the prior distribution on parameter "a".
Shape parameter of the continuous part of the prior distribution on parameter "a".
Shape parameter of the continuous part of the prior distribution on parameter "a".
Flag that indicates if a prior on parameter "b" is to be assigned. If TRUE, a prior on "b" is assigned.
Shape parameter of the prior distribution on parameter "b".
Shape parameter of the prior distribution on parameter "b".
Initial/fixed value of parameter "a".
Initial/fixed value of parameter "b".
Flag that indicates if the LPML is to be calculated. If TRUE, LPML is calculated.
Number of groups of the chosen cluster configuration.
Array that contains the group number to which each time series belongs.
Heterogeneity Measure of the chosen cluster configuration.
Acceptance rate of the parameter "rho".
Acceptance rate of the parameter "a".
Acceptance rate of the parameter "b".
Matrix that in its columns contains the sample of each sig2eps_i's posterior distribution after Gibbs sampling.
Matrix that in its columns contains the sample of each sig2alpha_i's posterior distribution after Gibbs sampling.
Matrix that in its columns contains the sample of each sig2beta_i's posterior distribution after Gibbs sampling.
Vector that contains the sample of sig2the's posterior distribution after Gibbs sampling.
Vector that contains the sample of rho's posterior distribution after Gibbs sampling.
Vector that contains the sample of a's posterior distribution after Gibbs sampling.
Vector that contains the sample of b's posterior distribution after Gibbs sampling.
Vector that contains the sample of the number of groups at each Gibbs sampling iteration.
If indlpml = TRUE, lpml contains the value of the LPML of the chosen model.
Flag that indicates if the time series data were scaled to the [0,1] interval with a linear transformation. This will be taken as an input for the plotting functions.
It is assumed that the time series data is organized into a data frame with the time periods included as its row names.
# NOT RUN {
## Do not run
#
# data(gdp)
# tseriesca.out <- tseriesca(gdp,maxiter = 4000,level=FALSE,trend=TRUE,
# c0eps = 0.1,c1eps = 0.1,c0beta = 0.1,
# c1beta = 0.1,c0alpha = 0.1,
# c1alpha= 0.1)
# Make sure that chain convergence is always assessed. Run the following
# code to show the cluster and diagnostic plots:
data(gdp)
data(tseriesca.out)
attach(tseriesca.out)
clusterplots(tseriesca.out,gdp)
diagplots(tseriesca.out)
# }
Run the code above in your browser using DataLab