# Functional Data Analysis in Sport Science: Example of Swimmers' Progression Curves Clustering
## 2 Materials and Methods
### Clustering the Real Swimming Data Set  
As mentioned above, the real data set is very irregular, with no accordance in time and in number of measurements between athletes. Thus, the first step of the analysis was the definition of a common ground through a smoothing procedure. According to the non-periodic form of the data and the relatively low sampling of observational points (around 30) for each athlete, a B-spline basis was chosen. The study focuses on the age period from 12 to 20 years old, which is crucial in the progression phenomenon that we aimed at studying. A basis of seven B-splines of order 4 was defined so that the derivatives remain smooth enough to work on derivatives. Since we did not wish to focus on a specific time period, the knots were equally placed on ages 13 to 19. One should note that data are considered as realisations of a stochastic process, and thus raw data are assumed to contain random fluctuations. The function that is fitted using the B-spline basis has to represent properly the true signal and the well known over/under-fitting issue appears in this case. In order to differentiate the true signal from the noise, several methods can be used, knowing that there is always a trade-off between smoothness of the function and closeness to observation points. A classical approach consists of the use of penalisation in the least-square fitting calculation, and the signal-to-noise ratio would be controlled by a unique hyper-parameter. In our case, we used a cross-validation criterion to compute an optimal value for this hyper-parameter, and the resulting functional data were considered as coherent by swimming experts. This whole fitting procedure was performed thanks to \(R\) (version 3.5.0) software, and especially the _fda_ (version 2.4.8) package. To efficiently analyse a real data set, one needs first to explore it, in order to figure out the more suitable algorithm to use. To this purpose, an FPCA was performed on the progression curves and their derivatives, separately. We looked at the percentage of variance explained by each eigenfunction and the shapes of them, to understand the main features of the curves. One can see in Figure 11 of the appendix that main variations among level of performance appear at young ages and a clustering procedure on progression curves tends to simply group individuals according to this criterion. As displayed on Figure 12, first eigenfunctions of the derivatives represent three different modes of variations localized at young, middle, and older ages. These characteristics of data would be relevant for including in the clustering procedure in addition to the level of performance information. For this purpose, the funHDDC algorithm was used as clustering procedure, as this is one of the rare implemented algorithms that works in a multivariate case and thus allows for considering both curves and their derivatives simultaneously. One can find more details in the results section about the reasons of this choice. Although implemented in the _funcy_ package, we chose to work with the original _funHDDC_\(R\) package because of current problems of implementation on it. Several features of the package were used, as Bayesian Information Criterion (BIC), Integrated Classification Likelihood (ICL) and slope heuristic, to deal with problems of model selection and choice of the number \(K\) of clusters. Since no particular assumptions were made on the covariance structure or the number of clusters forming a sport expert point of view, the hyper-parameters of the model have been optimised from data. All possible models were computed for different values of \(K\) and the best one (the sense of the term _best_ is developed in the Results section) was retained as our result clustering. In the funHDDC algorithm, each cluster is considered to be fully characterised by a Gaussian vector, from which scores on eigenfunctions of the FPCA are assumed to come.