# Directed Clustering of Multivariate Data Based on Linear or Quadratic Latent Variable Models
## 6 Application on Speed-Flow Data
### Directed Clustering  
Now, we demonstrate how Algorithm 2 can be applied to obtain directed clustering of the speed-flow datasets. Based on the output of Algorithm 1, we fit the quadratic model with \(K=4\) and \(K=8\) mass points, respectively, to the two datasets. The estimated mass points \(\hat{z}_{1},\hat{z}_{2},\ldots,\hat{z}_{K}\) and the posterior probability matrix \(W\) are obtained at the convergence of the EM algorithm. These are then reordered according to steps (ii) and (iii) of Algorithm 2. This is followed by applying the maximum a posteriori (MAP) clustering rule according to step (iv). The resulting clusterings are illustrated in the left panels of Figures 9 and 10. One can see how the clusters are lined up along the estimated curve, and ordered with respect to the latent variable that parameterizes the curve. Returning to the considerations expressed in Section 2, one can relate the clustering to traffic density. This argument can be made explicit by computing the theoretical traffic density at each mass point according to the fundamental diagram, which is given by the following:  
\[d_{k}=\frac{q_{k}}{v_{k}}=\frac{g(z_{k},\hat{\theta})_{[1]}}{g(\hat{z}_{k},\hat {\theta})_{[2]}}\]  
where the indices \([1]\) and \([2]\) stand for the first and second elements of the vector, respectively. Figure 11 displays the \(d_{k}\) against \(k\). It is visible from this plot that this relationship is indeed monotone, endorsing that the latent variable has a meaningful interpretation in  
Figure 8: Speed-flow data from the southbound freeway SR57-S, fitted with a quadratic curve (in blue), and mass points represented by red triangles, with different numbers of mixture components. terms of the traffic density; hence, the clusters are ordered from the top left to the bottom right end by increasing traffic density, starting with low densities at the top left end and proceeding toward larger densities in the bottom right end. For the first dataset, Table 5 reports the ordered cluster labels with the estimated \(\hat{z}_{k}\), as well as the center coordinates \(g(\hat{z}_{k},\hat{\theta})\) in the data space, and the density values derived as above. It is clear from this table that the clusters represent increasing density (congestion) from \(K=1\) to \(K=4\). Note that the information required to display this table is already available from part (ii) of Algorithm 2. Additional features and insights can be obtained from the output (iv) of Algorithm 2. Specifically, we can obtain the posterior random effect through the use of \({z_{i}}^{*}=\sum_{k=1}^{K}w_{ik}\hat{z}_{k}\)[33], where \(w_{ik}\) represents the posterior probabilities for each observation. The \(z_{i}^{*}\) can serve as one-dimensional summary information for the \(x_{i}\) and can be used for ranking purposes. The right-hand panels in Figures 9 and 10 show the resulting projections, i.e., the segments connecting \(x_{i}\) with \(g({z_{i}}^{*},\hat{\theta})\), along the fitted curve for the respective datasets. In practice, it means that each observation (each 5-min interval of speed- and flow values) can be immediately associated with a specific cluster, corresponding to a certain operating condition at the measured location. This information could then be used by intelligent transportation systems to take appropriate action, or perhaps just to flag a 'congestion score' (in the form of the current cluster label) to relevant road management authorities. Additionally, we can construct a 'league table' of the observations, ranked by the \(z_{i}^{*}\). We illustrate this here only for the first dataset, i.e., the left one in Figure 1, with results shown in Table 6. The table displays the matrix of posterior probabilities, \(W\), with rows reordered according to increasing \(z_{i}^{*}\). The values \(z_{i}^{*}\) are given in the second column of the table. The last column displays the clustering allocation according to the MAP rule.