Abstract
In this article, the Dirichlet process (DP) is applied to cluster subjects with longitudinal observations. The basis of clustering is the ability of subjects to adapt themselves to new circumstances. Indeed, the basis of clustering depends on the time of changing response variability. This is done by providing a random change-point time in the variance structure of mixed-effects models. The DP is assumed as a prior for the distribution of the random change point. The discrete nature of the DP is utilized to cluster subjects according to the time of adaption. The proposed model is useful to identify groups of subjects with distinctive time-based progressions or declines. Transition mixed-effects models are also used to account for the serial correlation among observations over time. A joint modelling approach is utilized to handle the bias created in these models. The Gibbs sampling technique is adopted to achieve parameter estimates. Performance of the proposed method is evaluated via conducting a simulation study. The usefulness of the proposed model is assessed on a course-evaluation dataset.
Keywords
Introduction
Cluster analysis is commonly employed to determine the intrinsic grouping in a set of unlabelled data. In this way, objects within a cluster are more similar to each other, in comparison to those in the other clusters. The notation of similarity can differ depending on the purpose of study. Clustering techniques have been applied for different purposes in many fields such as marketing, biology, medicine, econometrics and social sciences. Many clustering algorithms have been adopted to address different concepts of similarity measures. There are good reviews of clustering methods (see, e.g., Xu and Wunsch, 2005).
The model-based or distribution-based clustering approach, which utilizes a mixture of distributions, is one of the most adaptable clustering approaches in facing with datasets involving complex structures (see, e.g., McLachlan and Peel, 2000; McNicholas, 2016). In this approach, clusters consist of subjects belonging most likely to the same distribution. This clustering approach can be flexibly applied to cluster data with different sources of dependency. A very important and widely used type of data having a dependent structure is longitudinal data, which involves repeatedly measuring subjects recorded through time. There are two major sources of dependency in longitudinal data: intra-class correlation and serial correlation (Diggle et al., 2002).
In recent years, clustering of longitudinal data, sometimes called clustering of trajectories, has been the focus of attention. Overviews of model-based clustering approaches in longitudinal researches are provided by Vermunt (2010), Frühwirth-Schnatter (2011) and Bock (2014). Because of the rich structure of longitudinal data, different clustering purposes can be assumed to achieve homogeneous clusters in different studies. For example, Juarez and Steel (2010) assume a transition mixed-effects model and consider clustering based on constructing homogeneous groups in which the common behaviour may arise either from the dynamics (i.e., the coefficient of the lagged response), the effects of the covariates or from the equilibrium level of the time series. Suarez and Ghosal (2016) and Vogt and Linton (2016) among many others consider functional data clustering where individual observations are viewed as realizations of a random function. In this setting, finding representative curve patterns corresponding to different shapes and variations is the purpose.
A very prominent feature of the longitudinal data is the ability to monitor the evolution of underlying variables over time. Clustering subjects through time is among the most empirically important topics in econometrics, medicine, and social and behavioural sciences (see, e.g., Nagin, 1999; Weisburd et al., 2004; Juarez and Steel, 2010; Nie et al., 2010; Airila et al., 2014; Theodore et al., 2015; Carbonneau et al., 2016; Collins et al., 2016; Graziane et al., 2016). On the other hand, the behaviour change of subjects through time has always been the centre of attention (see, e.g., Nigg, 2001; Tobia and Inauen, 2010; Fleig et al., 2015). However, to the best of my knowledge, none of these researches has pointed out the problem of clustering subjects based on the time of changing subject's behaviour, as discussed in this article. Indeed, the idea of this article is motivated by the problem of clustering longitudinal data including the evaluation scores of 1 154 professors teaching at the Isfahan University of Technology (IUT) in Iran, during the years 1998–2014. It is seen that the variability of evaluation scores for each professor is large at first and then is reduced after the passage of time and gaining more experience. Since the way each professor teaches depends on many latent and unobserved factors, reductions in the variability for different individuals arise at different time points. Therefore, it can be important to cluster professors based on the time of reaching these change points. Accessing the stability of teacher's behaviour and effectiveness has been the focus of much attention over the last decade (e.g., Goldhaber and Hansen, 2013; Morgan et al., 2014).
There are many other situations in which the subject shows a very irregular and uncontrolled behaviour at the start of a process. For example, changes in monetary policy may affect firms’ stock volatility (see, e.g., Xu et al., 2016). Finding groups of firms with common change points in variances can be of great importance in practice to explore the effective features of firms that can contribute to the formation of groups. In these situations, there is usually a large variability for the response variable (the variable of interest) at the beginning of the process, whereas, after the passage of time and adaption to the new circumstance, the behaviour of subjects will be more stable. Usually, subjects who have a similar performance in adapting with the conditions show similar manners. Thus, identifying groups of subjects with a similar ability in attaining a stable time point in which their response variability is controlled may be essential. The reverse problem may also happen, as usually found in the literature of degradation. The reliability prediction based on degradation modelling is a useful method to estimate reliability for some highly reliable components or systems when there are rare failures (Wang and Coit, 2007). It is usual that the variability in any given degradation measure increases with the usage time (Wang and Coit, 2007; Rathod et al., 2011). Clustering of components of a large and complex system (or population) based on the time of starting or speeding up the degradation can be important for grading products, understanding the effective factors on degradation of parts and achieving more accurate reliability predictions. Also, the same process can occur regarding some medical or behavioural features of individuals, such as reaction time, memory and fluid intelligence measures, which have been shown to have more variability by aging, as mentioned in Morse (1993) and references therein.
Categories obtained in clustering based on the time of changing variability can then be used for further statistical inference in clusters with more homogeneous subjects. This is particularly important when doing some specific statistical inference is the key point in the data analysis process, and because of a very non-homogeneous population, the resulting inference cannot efficiently be used for most elements of the population. Moreover, by clustering subjects, it may be feasible to specify common factors effective in the creation of clusters. It may also be possible to test if subjects categorized in the same cluster show similar responses to different stimulants. Various methods have been designed to this purpose; as a good reference, see Nagin (2005). Although regression models with shifts in variance components have been investigated vastly as variance shift models (e.g., Babadi et al., 2014; Gumedze and Chatora, 2014; Li et al., 2015; Xu et al., 2016), none of these researches has yet pointed out the problem of clustering subjects based on the time of changing response variability. These current researches have been mainly designed to detect observations with large variations and to make models robust.
To formulate the above clustering idea, I assume that the variation of response measurements will change after certain time lag. This assumption corresponds to a variance shift model, in which the variance of residual term will change. In practice, changes usually happen at different time points for different subjects. Therefore, it is more realistic to assume a random change point in the structure of a mixed-effects model. In some applications, it is usually important that different subjects can be categorized based on behaviour of their responses over time. In these studies, it usually takes time for a subject to gain experience and be adapted to the conditions; thus the variability of response will usually be reduced after a change-point. Similarly, the reverse problem may happen such that the variance of response measured on parts may be increased after a change-point time due to the degradation. Being able to cluster subjects based on this similarity measure, that is, the time of changing response variability, the Dirichlet process (DP; Ferguson, 1973) is considered as a prior for the distribution of the random change point. According to the DP, the distribution
A prominent feature of assuming the DP as a prior for the distribution of the random change point is that the number of clusters can be inferred based on the data structure and not in an a priori manner. Applications of the DP to cluster analysis of data with special structures have appeared in many disciplines (e.g., Pennell and Dunson, 2007; Li et al., 2010; Heinzl et al., 2012; Heinzl and Tutz, 2013; Wang and Wang, 2013; Rikhtehgaran and Kazemi, 2016).
To study the association of responses over time, transition mixed-effects models are used by assuming lagged responses in the mean structure of the model (Crouchley and Davies, 2001; Diggle et al., 2002). The bias created in these models is handled by joint modelling of the initial responses and subsequent responses (Kazemi and Crouchley, 2006).
Estimates of model parameters are obtained by the use of the Gibbs sampler algorithm (Geman and Geman, 1984), in a Bayesian perspective. The performance of the proposed model is evaluated by conducting a simulation study as well as applying the model on a real dataset.
The remainder of this article is organized as follows. Sections 2 introduces the course-evaluation dataset. Section 3 specifies the transition mixed-effects model. In Section 4, the semi-parametric approach of clustering subjects with longitudinal observations is introduced. Section 5 presents the proposed transition variance shift model. Section 6 includes a simulation study. In Section 7, the usefulness of the proposed model is shown in clustering of a course-evaluation dataset. The last section includes conclusions.
Motivating data-set: Course-evaluation data
The data includes 12 354 records from 1 154 official or contractual professors teaching at the IUT in Iran during the years 1998–2014. The course evaluation is recorded via an electronic questionnaire, which consists of a series of questions in order to evaluate the instruction of a given course. The dataset is unbalanced such that the number of teaching semesters varies between 1 and 32. The data includes all course-evaluation scores for 14 departments of the university, including engineering and the basic science. Among these records,

Profiles of evaluation scores (left panel) and the non-parametric estimates of the mean structure of evaluation scores (right panel)
It is assumed that the variability of evaluation scores for each professor is large at first and is reduced after the passage of time and gaining more experience. Since the way of teaching each professor depends on many latent and unobserved factors, they get to the stability at different time points. It can be important to cluster professors based on the time of reaching these stabilization points. For example, it is possible to examine the relationship between the grade-point-average (GPA) of classes and their corresponding evaluation scores concerning the professors assigned to the same cluster instead of assessing this relationship among the population of whole professors. Therefore, the relationship between these two factors can be evaluated more precisely. Inference about this relationship may be an important issue in judgement about course-evaluation systems. In the next sections, I develop statistical models that aim to flexibly model the data structure and cluster subjects based on the time of reaching stabilization points.
Let
In fitting transition models, the presence of random effects which are added to capture the between-subject variability may cause the so-called initial conditions problem. This problem happens because of the correlation between the random effects and the initial state
Maximum likelihood estimates of model parameters can easily be obtained (see, e.g., Kazemi and Crouchley, 2006).
In many longitudinal studies, clustering of subjects with longitudinal observations is the purpose. In the model-based clustering approach, a mixture distribution with normal components for random effects is usually applied to cluster subjects. In these cases, the determination of the number of mixture components, or say subjects clusters is usually the main concern. To deal with this issue, the Bayesian semi-parametric approach of the DP is applied in the literature (e.g., Li et al., 2010; Heinzl et al., 2012; Heinzl and Tutz, 2013; Wang and Wang, 2013). Ferguson (1973) introduced the DP as a random probability measure defined on the space of all possible distribution functions. Indeed, the random probability measure
As was mentioned, the base distribution
The discrete nature of the DP makes it useless in those data modelling where a continuous distribution is required. However, this restriction is relaxed by the introduction of Dirichlet process mixture (DPM) models (Escobar, 1994; MacEachern, 1994) by adding a hierarchy level to the model. Indeed, it is assumed that
Thus, the DPM model has an interpretation as an infinite mixture model by assuming the stick-breaking representation of the DP.
Nevertheless, the discreteness property of draws from the DP can be used for clustering purposes. Thus, in the DPM model, several
When Markov chain Monte Carlo (MCMC) simulation methods such as the Gibbs sampler and the Metropolis–Hastings (MH) algorithm (Hastings, 1970) are applied to achieve Bayes estimates of parameters for mixture models, the so-called label switch problem takes place (Frühwirth-Schnatter, 2006). Indeed, because of the invariance of the likelihood function with respect to the permutation of the component labels in the mixture model, the marginal posterior distribution of the parameters for all components is identical. Therefore, the Bayesian inference is not appropriate. To handle the label switch problem, the constraint
The proposed transition variance shift model
For clustering subjects based on the time of changing response variability, I first consider the transition model given in Equation (3.1) and then allowing for subject-specific change points
To handle the initial conditions problem, I consider Equation (3.2) and assume that the
The above random intercept model is inspired by the longitudinal study on course-evaluation data whereby individual profiles show subject-specific shift in variances over time. Note, however, that based on the purpose of study, different clustering strategies can be considered by assuming the DP as the prior of the random effects of models with different structures.
Bayesian estimation
The parameter estimates can be obtained from the freely available software Openbugs (Lunn et al., 2009). Being applicable in this software, I use an equivalent structure introduced by Ishwaran and James (2001) which introduces labels
Fitting complex models, such as the proposed transition variance shift model, requires the use of MCMC methods. To obtain Bayesian parameter estimates using the MCMC simulation methods, I apply conditionally conjugate priors with hyper parameters being chosen such that the corresponding priors be vague. The Gibbs sampler simulates iteratively from the complete conditional posterior distribution of each unknown parameter, given the current values of all other model parameters and observations. Then, means of MCMC samples are used to achieve Bayes estimates.
In the Appendix, I provide the chosen priors for the model parameters and all full conditionals to implement the Gibbs sampling.
The data generating process is organized to the mixed model

Profiles of response values for 30 randomly selected subjects, in the simulation study. Darker lines show profiles of subjects with smaller change points
I fit the proposed model of Section 5, where
Bayesian estimation results for the simulated dataset
Bayesian estimates of change points, the BMed and (Q1,Q3) for the size of each cluster, obtained from the Openbugs software, are reported for the simulated dataset. Also, the size of each cluster computed by the use of Matlab software are reported
Comparing the estimated change points

Profiles of generated values in estimated clusters A, D, E, H and I are depicted. The estimated change points are also depicted with vertical lines in each panel
In order to classify professors based on the time of changing evaluation-scores variability, I fitted model given in Equation (5.1) by assuming no covariate in the structure of the model, that is, the pure values of evaluation scores are considered for the clustering purpose and no confounding effects of covariates are extracted from the evaluation scores. I also let
Bayes estimates for the course-evaluation data
Bayes estimates for the course-evaluation data
To implement the Gibbs sampler, let priors be the same as those adopted in the simulation study. To improve the rate of convergence to the target posterior distributions, I set
The stick-breaking representation of the DP is approximated by

The posterior probability density function of parameter K (left panel) and the history of produced values of K (right panel)
Bayes estimates of change points and the BMed obtained from the Openbugs software are reported for the course-evaluation data. Also, the size of each cluster computed by the use of Matlab software and the ratio of censored subjects (RCS) in each cluster are reported

Profiles of evaluation scores in each estimated cluster are depicted. The estimated stabilization time points are also depicted with vertical lines in each panel.
Table 4 shows the Bayes estimates of the stabilization time points and the BMed of size of primary assumed clusters from the MCMC outputs. It is seen that clusters A, B, C, D and J have been active in the most Gibbs sampler runs, while other clusters have been inactive at least for the 50
In this article, I extended the application of the DP prior for clustering subjects with longitudinal observations. This was specifically done by incorporating the DP as the prior for the unknown distribution of the random change point in the structure of the variance components of a transition mixed-effects model. Indeed, I assumed that the measure of similarity for model-based clustering of subjects is the time of changing response variability. In some applications, mainly in medicine, industry, and social and behavioural sciences, it usually takes time for a subject to gain experience and be adapted to the conditions and thus the variability of response will usually be reduced after a change point. Similarly, in the current literature, for example, the new parts usually start with small variations, while after the passage of time and the degradation, their variability will increase. Therefore, it is usually important that different subjects can be categorized based on the behaviour of their responses over time. Identifying groups of subjects with a similar ability in adaption to the circumstances is important for post-processing issues. Some examples are exploring common factors that can contribute to the formation of clusters, testing if subjects of the same cluster show the same responses to the stimulants and assessing some relationships among variables for the more homogeneous subjects in clusters.
It was shown by a simulation study that the ratio of true clustered subjects was high in the proposed model. In a real data application, the proposed model was used to cluster professors based on the stabilization term in which, the variability of the course-evaluation scores was reduced. Clustering of professors based on this similarity concept could be important for investigating different hypotheses in each cluster with more homogeneous individuals instead of the non-homogeneous population of whole individuals. One of the most challenging issues about the course-evaluation system is to assess the relationship between the course-evaluation scores and the GPA of classes.
The proposed model can also be applied to the field of medicine, economy or the industry (degradation). As another example than the course-evaluation study, I can point out the work of Xu et al. (2016) in detecting and identifying a common variance change point among different countries.
In their work, the impact of the gross domestic product (GDP) growth rate on the variation of unemployment rate among countries was investigated. This impact was addressed by regressing unemployment rate on GDP growth rate and assuming a common change point in the variance of residuals. Nevertheless, fitting a mixed-effects model and assuming a country-specific change point in the variance structure may produce more flexibility to the model and improve the efficiency of the model parameters’ estimates. On the other hand, applying the proposed model could cluster countries based on the time when the impact of GDP growth rate on the variation of unemployment rate becomes smaller. Then, further issues such as finding common features in countries of the same cluster may be informative.
Further, the methodology can be improved by clustering subjects based on the time of changing other features of models. The model can also be extended to the variance shift models with several jumping points for each subject.
Acknowledgments
The author is grateful to the academic affairs of the Isfahan University of Technology for making the course-evaluation data available.
Appendix
The following distributions are adopted as priors for the proposed model: Inverse-Gamma prior, Inverse-Gamma prior, Multivariate normal prior, Normal prior, Normal prior,
Full conditionals required for running the Gibbs sampler for the proposed model are derived as follows: By the conjugacy of the multinomial and the Dirichlet distributions, I have
For each random effect, let The MH algorithm can be used to simulate from this complete conditional posterior distribution.
