{'fraction_non_alphanumeric': 0.033809243958931104, 'fraction_numerical': 0.016282365955681544, 'mean_word_length': 4.5470757430488975, 'pattern_counts': {'":': 0, '<': 0, '<?xml version=': 0, '>': 0, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
A comparison of some criteria for states selection in the latent Markov model for longitudinal data

We compare different selection criteria to choose the number of latent states of a multivariate latent Markov model for longitudinal data. This model is based on an underlying Markov chain to represent the evolution of a latent characteristic of a group of individuals over time. Then, the response variables observed at the different occasions are assumed to be conditionally independent given this chain. Maximum likelihood of the model is carried out through an Expectation-Maximization algorithm based on forward-backward recursions which are well known in the hidden Markov literature for time series. The selection criteria we consider in our comparison are based on penalized versions of the maximum log-likelihood or on the posterior probabilities of belonging to each latent state, that is the conditional probability of the latent state given the observed data. A Monte Carlo simulation study shows that the indices referred to the log-likelihood based information criteria perform in general better with respect to those referred to the classification based criteria. This is due to the fact that the latter tend to underestimate the true number of latent states, especially in the univariate case.


Introduction
A crucial element in the literature about the wide class of mixture models (McLachlan and Peel, 2000) is represented by the choice of the number of mixture components, which represents a specific aspect related with the model selection process. For instance, this issue arises in the context of latent class (LC) models about the choice of latent classes and in the contexts of hidden Markov (HM) models for time-series and stochastic processes (Zucchini and MacDonald, 2009) and of latent Markov (LM) models (Wiggins, 1973) for longitudinal data. This last class of models is typically used when the interest is in describing the evolution of a latent characteristic of a group of individuals over time. They assume that one or more occasion-specific response variables depend only on a discrete latent variable, characterized by a given number of latent states, which follows a firstorder Markov process (Bartolucci et al, 2013). The basic idea behind this assumption is that the latent process fully explains the observable behavior of a subject. Furthermore, the latent state to which a subject belongs to at a certain occasion only depends on the latent state at the previous occasion. An LM model may also be seen as an extension of the LC model, in which the assumption that each subject belongs to the same latent class throughout the period of observation is suitable relaxed.
In such a context the number of latent states is usually selected on the basis of the observed data, both in the case of the basic LM model or in the advanced versions that, for example, allow for the inclusion of observable individual covariates. Only in certain applications the number of latent states is a priori defined by the nature of the problem or by the interest of the research. However, states selection on the basis of the observed data implies that increasing the number of states often improves the fit of the model, as judged by the likelihood, but also the number of parameters. The same problem arises when selecting the number of components in a finite mixture model. The more common approaches which have been adopted to balance model fit and parsimony are based on information criteria constructed according to indices that are penalized versions of the maximum log-likelihood. Among these criteria, the most common are the Akaike Information Criterion (AIC; Akaike, 1973) and the Bayesian Information Criterion (BIC; Schwarz, 1978). The first one is known as an estimator of the Kullback-Leibler discrepancy between the model generating the data and the fitted model. BIC may be instead seen as an asymptotic approximation of the integrated likelihood, which provides an estimator of a transformation of the Bayesian posterior probability of a candidate model. Several alternative to the AIC criterion have been proposed in literature such as AIC 3 of Bozdogan (1993) and the Consistent AIC (CAIC) criterion proposed by Bozdogan (1987) which are based on different penalization terms. It is important to mention that the information criteria are preferred to methods based on the likelihood ratio test between nested models because the latter require bootstrap resampling procedure.
In addition to the above log-likelihood based information criteria, classification based criteria have been proposed in literature, which allow us to measure the quality of the classification provided by a model. The Normalized Entropy Criterion (NEC) is an approach first developed by Celeux and Soromenho (1996) to select the number of components in the context of mixture models. It is based on an entropy term computed on the basis of the posterior probabilities for every sample unit and mixture component. This criterion takes into account the quality of the classification, and then how well the clusters are separated, further to the goodness-of-fit of the model, which is measured in terms of log-likelihood. An entropy index has been recently proposed in HM literature to measure uncertainty involved in connection with finding the most likely sequence of the latent states; see Hernando et al (2005) and Durand and Guédon (2012). The entropy measure, however, has not been investigated as a tool for states selection in such a context. Among other classification based criteria, it is worth mentioning also the Classification Likelihood information Criterion (CLC), adopted by Biernacki and Govaert (1997) in the mixture context, and an approximation of the Integrated Classification Likelihood criterion (ICL; Biernacki et al, 1998) using BIC denoted as (ICL-BIC) firstly adopted by Biernacki et al (2000) and McLachlan and Peel (2000).
In the context of finite mixture models and, in particular, of LC models, several studies exist aimed at comparing the performance of the above mentioned criteria. Among others, Fraley and Raftery (2002) used BIC for clustering in mixture models, showing its satisfactory behavior (see also McLachlan and Peel, 2000, Ch. 8). Simulation studies have also been performed by Nylund et al (2006) for growth mixture and LC models, and by  for Gaussian mixtures. In both situations it was found that BIC outperforms the other information criteria. We also refer to Dias (2006) for a study refer to the LC model with binary response variables in which emerges that AIC 3 is the best criterion for selecting the number of latent classes. Moreover, CAIC has been proved to have a similar performance with respect to BIC (Lin and Dayton, 1997).
About the behavior of the classification based criteria, we refer to , which found that NEC gives poor results in selecting the model under comparison, although it exhibits good behavior in detecting the number of clusters. Moreover, Biernacki et al (2000) showed that ICL appears to be more robust than BIC to violation of some of the mixture model assumptions.
Even if these criteria are widely used in literature, their performance have not been studied enough in detail in connection with LM models. A comparison of AIC and BIC performance in connection with states selection of a univariate LM model may be found in Bartolucci et al (2013) [Ch. 7]. However, to our knowledge, there are no studies aimed at comparing the behavior of the different information criteria mentioned above.
On the other hand their properties have been studied in the context of HM models; see, among others, Celeux and Durand (2008), Costa and De Angelis (2010) and the references therein. However, the context is quite different, since HM models are used for time series, whereas LM models are applied to longitudinal data. The main purpose of this paper is to compare the performance of all the illustrated information criteria when applied to select the number of latent states in a multivariate LM model.
We show a Monte Carlo simulation study on the basis of different model specifications, with respect to the number of response variables, and to different conditional response probabilities and transition probabilities. The aim is to analyze the effect of these factors on selecting the number of states and to set up a comparison between log-likelihood based and classification based criteria. In particular, in applying the NEC criterion, we consider an entropy measure based on the posterior probabilities of all the possible configurations of latent states, given the observed data, for every sample unit. We also consider two approximations of NEC which are based on a modified version of the entropy computed on the basis of the posterior probability of every single latent state at every time occasion.
The article is organized as follows. In the following section we illustrate the multivariate LM model and we deal with maximum likelihood estimation of the model parameters.
In Section 3 we illustrate the latent states selection criteria under comparison. In Section 4 we show the results of a series of simulations made in order to assess the quality of the analyzed criteria. In Section 5 we provide main conclusions.

The multivariate LM model
In the multivariate formulation of the LM model (that includes the univariate one as a special case) we observe a vector of categorical response variables j , j = 1, . . . , r, has c j categories, labeled from 0 to c j − 1. We denote by Y = (Y (1) , . . . , Y (T ) ) the vector of observed responses made of the union of vectors Y (t) , which usually, is referred to repeated measurements of the same variables Y j (j = 1, . . . , r) on the same individuals at different time points.
The model is based on two main assumptions. Firstly, the vectors Y (t) are conditionally independent given a latent process U = (U (1) , . . . , U (T ) ), and the response variables in each of these vectors are conditionally independent given U (t) at time t with state space {1, . . . , k}. In other words, each occasion-specific observed variable Y h , for all h = j = 1, . . . , r, given U (t) . This is the so called local independence assumption. Secondly, the latent process U is assumed to follow a first-order Markov chain with k latent states, that is each latent variable U (t) is independent of U (t−2) , . . . , U (1) , given U (t−1) . The resulting model is represented by the path diagram in Figure 1. The model is characterized by three different types of parameters: • the conditional response probabilities with j = 1, . . . , r, t = 1, . . . , T , u = 1, . . . , k, and y = 0, . . . , c j − 1, which may be collected into the vector • the initial probabilities π u = p(U (1) = u), with u = 1, . . . , k; • the transition probabilities Note that all these probabilities do not depend on the specific sample unit. Moreover, it is possible to include a constraint on the transition probabilities corresponding to the hypothesis that the Markov chain is time homogeneous. Under this hypothesis, which is considered in the simulation study illustrated in Section 4, the transition probabilities do not depend on t, so as The number of free parameters of the multivariate LM model above is given by (1) The probability mass function of the distribution of U may be expressed as Note that computing p(Y = y) involves all the possible k T configurations of vector u, that typically requires a considerable computational effort. In order to efficiently compute this probability we can use a forward recursion (Baum et al, 1970;Welch, 2003) for obtaining In particular, the t-th iteration of this recursion, for t = 2, . . . , T consists of computing y|u , for t = 1. This recursion may be easily implemented by using matrix notation; see Bartolucci et al (2013) for details.

Likelihood inference
In an observed sample of n subjects, let n (y) be the frequency of the observed response configuration y, and assuming independence between the sample units, the model loglikelihood may be computed as where θ is the vector of all model parameters arranged in a suitable way. The model loglikelihood may be maximized with respect to θ by using the Expectation-Maximization (EM) algorithm of Dempster et al (1977) which represents the main tool to estimate this class of models. This algorithm is based on the concept of complete data, which is represented by the pair (u, y), where u denotes a realization of U . Therefore, the complete data log-likelihood is given by juy corresponds to the frequency of subjects responding by y for the j-th response variable and belonging to latent state u at time t, b (1) u is the frequency of subjects in latent state u at time 1, and b (t) vu corresponds to the frequency of subjects which move from latent state v to state u at time t.
Since the latent configuration for each subject is not known the EM maximizes the log-likelihood above by alternating the following two steps until convergence: • E-step: compute the expected value of the above frequencies, given the observed data and the current value of the parameters, so as to obtain the expected value of ℓ * (θ) • M-step: update θ by maximizing the expected value of ℓ * (θ) obtained above; explicit solutions for θ estimation are available at this aim, see Bartolucci et al (2013).
The E-step of the algorithm involves the computation of the posterior probabilities u|v,y . Using the following backward recursion whereas, for t = 2, . . . , T and u, v = 1, . . . , k, we have The recursions above may be implemented by using the matrix notation, as shown in Bartolucci (2006) and Bartolucci et al (2007).

The class of states selection criteria
As already discussed in Section 1, a crucial point in using LM models concerns the selection of the number of latent states k. When this number cannot be a priori defined, it is possible to rely on model selection criteria. In the following we illustrate the most common loglikelihood based information criteria together with classification based criteria which take the quality of classification into account.

Log-likelihood based information criteria
The information criteria are based on indices that are, essentially, penalized versions of the maximum log-likelihood. The two most common criteria of this type are AIC and BIC. The first criterion, proposed by Akaike (1973), is a measure of the relative goodness of fit of a model, which describes the tradeoff between accuracy and complexity of the model. In particular, AIC is based on estimating the Kullback-Leibler distance between the true density and the estimated density, which focuses on the expected log-likelihood, and is defined on the basis of the following index For a given model,l denotes the maximum of the log-likelihood of the LM model of interest and #par denotes the number of free parameters as defined in (1). According to this criterion, the optimal number of latent states is that corresponding to the minimum value of the index in (4). In practice, we fit the LM model for increasing values of k until the index does not start to increase. Then, we select the previous k as the optimal number of latent states, which guarantees the best compromise between goodness-of-fit and model parsimony.
The BIC criterion of Schwarz (1978) is derived, for regular models, as an approximation to twice the log integrated likelihood (Kass and Raftery, 1995), using the Laplace method (Tierney and Kadane, 1986). From the asymptotic behavior of this approximation, the corresponding index may be defined as withl and #par defined as above. In certain settings, model selection based on BIC is roughly equivalent to model selection based on Bayes factors; see among others Kass and Raftery (1995). The number of latent states k to be selected is the one which corresponds to the minimum value of the index in (5) Among the variants of the AIC criterion existing in literature we also consider the criterion introduced by Bozdogan (1993). In particular, this criterion defines a more penalized version of the index in (4), on the basis of the results in Wolfe (1970), so as to obtain AIC 3 = −2l(θ) + 3#par, in which the penalizing term 2 is substituted with 3.
On the other hand, the Consistent AIC criterion (CAIC), proposed by Bozdogan (1987), includes a penalizing term which also takes into account the sample size n, and is defined as CAIC = −2l(θ) + #par(log(n) + 1).
Further to the above information criteria that are aimed at measuring the goodness of fit of a model, we also consider criteria that take into account the performance of the classification procedure, as outlined in the following.

Classification based information criteria
The criteria developed in the context of the classification likelihood approach, also known as complete data information criteria, are based on data augmentation, that is, the complete data as defined in Section 2.1. These criteria consider the following relation, that was first showed by Hathaway (1986) see also Celeux and Soromenho (1996) and Biernacki and Govaert (1997), where EN is an entropy measure, which involves the posterior probabilities of component membership of each subject belonging to a specific group. Such entropy may be seen as a penalization term which is a measure of the ability of the model to provide a relevant partition of the data. More in detail, if the components are well separated, the posterior probabilities tend to define a partition of the data, assuming values close to 1. As a consequence, the entropy will be close to 0. The entropy measure cannot be directly used to assess the number of clusters since ℓ(θ) is an increasing function of k and has to be renormalized.
With reference to the mixture models, Celeux and Soromenho (1996) proposed to consider the NEC criterion, which is expressed by wherel k (θ) is the maximum log-likelihood in case of a k components mixture andl 1 (θ) is the maximum log-likelihood in case of a 1 component mixture. As also illustrated in Biernacki and Govaert (1997), NEC must assume small values to obtain a compromise between a good classification feature and a good description of the data. Then, the optimal number of components is the one that minimizes the index in (9). It is worth noting that the NEC criterion is not defined when k = 1; to deal with this problem  proposed an empirical version of the NEC for Gaussian mixture.
Usually it is convention to use NEC = 1 for k = 1.
In extending NEC to LM models, the difficulty is in considering entropy based on the posterior probabilities of all the possible configurations of latent states, given the observed data, for every sample unit. Therefore, this "true" entropy can be computed only when we have a reduced number of times occasions and latent states. In the context of HM models this measure is defined by Hernando et al (2005) as u|v,y are defined in equations (2) and (3), respectively. In the context of LM models, we may simplify the above equation for EN by formulating an approximated version that allows us to compute entropy also for any number of time occasions and latent states. More precisely, under the assumption that u (t) are independent given Y , we define EN as follows u|y log(f (t) u|y ).
A possible renormalized variant of EN 1 may also be expressed as Therefore, we consider a NEC criterion relying on the "true" entropy based on the posterior probabilities of all possible configurations of latent states, and two different approximated versions, which may be computed for any number of time occasions and latent states. As an example we suppose to observe subjects at three occasions (T = 3), then the above criteria may be explicitly written as follows According with the entropy measures defined above we consider three different versions of the NEC criterion where the first one is based on the "true" entropy, as defined in (9), and the other two versions are expressed as Among other criteria which take the quality of classification into account, we also consider the CLC criterion, proposed by Biernacki and Govaert (1997) in the mixture context, which uses the relation in (8) to define the following index CLC = −2l(θ) + 2 EN.
Moreover, Biernacki et al (1998) suggested an alternative information criterion based on the complete data likelihood named as Integrated Classification Likelihood criterion (ICL). The same authors also proposed an approximated version of the ICL using BIC (Biernacki et al, 2000). In particular, McLachlan and Peel (2000) referred to this approx-imated version as ICL-BIC and showed that may be computed as ICL-BIC = BIC + 2 EN, in which the term 2 EN represents a kind of penalization for poorly separated clusters; see also Li (2005).
As already discussed in Section 1, although the above information criteria are widely used and their performance are studied in the context of finite mixture, LC, and HM models, there is still a lack in the literature about their comparison in the context of LM models. In the following section we set an experimental design to compare the performance of these criteria in the context of multivariate LM model, in order to choose the optimal number of latent states.

Simulation study
We illustrate the results obtained by a Monte Carlo simulation study aimed at comparing the performance of the following indices for states selection: • Log-likelihood based criteria: AIC, CAIC, AIC 3 , BIC; • Classification based criteria: CLC, ICL-BIC, NEC, NEC 1 , NEC 2 .
More in detail, we simulate 100 samples with a given size n (n = 250, 500) and coming from an LM model, characterized by r (r = 1, 3, 5) binary (y = 0, 1) response variables observed in T = 5 time occasions, k (k = 2, 3) latent states, and given values of initial probabilities π u , transition probabilities π (t|t−1) u|v , and conditional response probabilities jy|u . All analyses are implemented in R software (the code is available upon request by authors). In all cases, the strategy adopted to choose the number of latent states is the same: we fit the LM model with increasing k values and, then, the value just before the first increasing criterion index is taken as optimal number of latent states.
We first consider a scenery (scenery 1) based on n = 250 individuals belonging to k = 2 latent states and observed on T = 5 time occasions. Moreover, we suppose equal initial probabilities, that is π 1 = 0.5 = π 2 , and denoting by Π the transition probabilities matrix with elements π u|v , under the time homogeneous assumption, we consider Π = 0.9 0.1 0.1 0.9 .
We also assume alternatively r = 1, 3, 5 binary response variables with the following matrix Φ of the conditional response probabilities φ (t) jy|u Φ = 0.8 0.2 0.2 0.8 . Table 1 shows the relative frequencies of the number k of components chosen by each of the considered criteria, both in univariate case (r = 1) and in multivariate cases (r = 3 and r = 5).
In the univariate case, all log-likelihood based criteria perform very well, whereas the performance of classification based criteria is very bad: they tend to underestimate k in almost all cases. Instead, in the multivariate cases (r = 3 and r = 5) the classification based criteria improve considerably their performance, being the selected number of latent states equal to 2 in almost all cases. We only observe a worsening of AIC, which tends to overestimate the right number of latent states in 17 and 29 cases out of 100, for r = 3 and for r = 5 respectively.  All the other elements are the same than those considered in scenery 1. Results are shown in Table 2.
With respect to scenery 1 we note several differences. In the univariate case, the behavior of both BIC and CAIC gets worse: BIC leads to select the true value k = 2 in less than 50% of cases and CAIC in 37% of cases, whereas in the remaining simulations  Another scenery (scenery 3) is then considered, which differs from scenery 1 for a greater uncertainty in the allocation of the observations to the latent states, being the conditional response probabilities matrix given by All the other elements are the same than scenery 1. Results are shown in Table 3.  With respect to scenery 1, in presence of r = 1 response variables the behavior of BIC and CAIC is not very satisfactory, because they tend to underestimate k in 35% and 53% of cases. Concerning the classification based criteria, we note a significant deterioration of their behavior both in univariate case and in multivariate cases. Only NEC 2 presents a satisfactory performance, being the correct number of k selected in 88 cases out of 100 with r = 3 and in 98 cases out of 100 with r = 5 (and overestimated in the remaining cases). Instead, the remaining criteria lead to choose k = 1 in almost all cases when r = 3, improving just a little when r = 5. More precisely, in this last case, NEC and CLC allow us to select the right number of k in the 59% of cases, whereas they underestimate k in 28.5% of cases. Moreover, ICL-BIC leads to select k = 1 for the 55% of simulated models and NEC 1 for the 77% of them.
The three above described sceneries are then replicated by increasing the number of observations from n = 250 to n = 500, all the other things being constant. Results are shown in Tables 4, 5, and 6 for sceneries 1, 2, and 3 respectively.
By increasing the number of observations we note a considerable improvement of performances of BIC and CAIC in the univariate cases of sceneries 2 and 3, whereas the behavior of the other criteria, especially of classification based criteria, is unchanged.
Rather, in case of scenery 3, when r = 5 response variables are considered, the behavior of NEC 1 and ICL-BIC gets worse, being k = 2 selected in 10% and 43% of cases for n = 500 against 22% and 44.5% of cases for n = 250.
To conclude, we also consider two further sceneries (sceneries 4 and 5) characterized by n = 500 individuals and k = 3 latent states. We also suppose T = 5, equal initial probabilities, that is π 1 = π 2 = π 3 = 1/3, conditional response probabilities matrix equal to Φ = 0.9 0.1 0.7 0.1 0.9 0.3 ,  With respect to the cases with k = 2 latent states, we now observe a very poor performance of all criteria in the univariate case (r = 1): log-likelihood based criteria   (Tables 7 and 8). Instead, in presence of r = 3 response variables, the behavior of log-likelihood based criteria gets better, especially under scenery 4. Indeed, Table 7 shows that with AIC and AIC 3 the right number of latent states is chosen in 91 and 98 cases out of 100 respectively, whereas with BIC and CAIC the percentages of right choices are reduced to 59% and 39% respectively, being k underestimated in the remaining cases. On the other hand, under scenery 5 (Table 8), which refers to a situation with lower latent states persistence probabilities, the improvement is far from clear: k = 3 is selected by AIC in 75% of cases and by AIC 3 in 35%, whereas BIC and CAIC lead to choose regularly
On the basis of some Monte Carlo simulations, we compared the performance of loglikelihood and classification based criteria for the latent states selection in univariate and multivariate LM models. Generally speaking, lower values of persistence probabilities in a same state and/or a greater uncertainty in the allocation of the observations to the latent states complicate the task of latent states selection procedures, leading to a generally worse performance of the adopted criteria. Instead, the number of observations does not play a relevant role.
Concerning the specific criteria, we observed that those based on the log-likelihood present a better general behavior with respect to those based on classification, even if AIC tends to overestimate the correct number of latent states, especially in multivariate cases. The classification based criteria tend to underestimate the true number of latent states, mainly for the univariate case, whereas their performance improves by increasing the number of observed response variables. We also observed a significant better behavior for NEC 2 with respect to the other classification based criteria. Finally, by increasing the number of latent states the performance of all considered criteria gets worse, mainly in the univariate case. We conclude outlining that the results we obtained are coherent with those observed in the literature about HM models (see, among others, Costa and De Angelis, 2010).
Concerning further developments of the present work, we intend to extend the simulation study to LM models with covariates. We also intend to rely on the most recent advances in the context of HM models for a different formulation of the entropy that takes into account the tendency of traditional formulation to overestimate the uncertainty in these type of models (Durand and Guédon, 2012).