## 4 Methodology
### Detecting Summarization Patterns  
In this stage of the analysis, the aim was to detect subsequences of the patients' time series able to summarize their behavior. For this task, we employed method _Matrix Pro  
Figure 3: Our methodology to characterize the periods of CPAP use based on analytical techniques over a real-world dataset. Figure 2: Basic distributions related to the CPAP use dataset. **(a)** Distribution of the length of the time series (number of days of use) found in the CPAP use dataset. We discarded patients with less than 181 days (6 months) of monitoring. **(b)** Distribution of the average number of hours of CPAP use considering all the patients with, at least, 181 days of monitoring. file_[26], a recently proposed set of techniques and tools to analyze time series with respect to subsequences of interest, such as unusual, common, or representative subsequences. Matrix Profile is based on distance measure MPdist [27], which considers two time series to be similar if they share many similar subsequences, regardless of the order and time of matching. According to its authors, MPdist is robust to spikes, warping, linear trends, dropouts, wandering baseline, and missing values. The name of the method comes from the construction of a matrix in which each line corresponds to a pairwise time series distance comparison. From the matrix, many patterns can be detected. Given a time series, the method Matrix Profile produces a set of subsequences of a predetermined length named _snippets_. We used the length of 30 days as it corresponds to 1 month--a temporal unit that is in accordance with the clinical practice seen in countries such as the USA, where certain insurance companies require a face-to-face visit between 2 or 3 months after the CPAP set-up to ensure adherence, and further 12-months visits to confirm the adherence [9]. In contrast to the more known term _motif_, snippets are not only patterns of a data series but patterns that repeat; also, different from motifs, the snippets are detected from each time series individually and not from the set of time series. The advantage is that snippets are prime for summarizing the time series instead of just finding unique patterns. For each detected snippet, the more 30-day subsequences (contiguous or not) it matches (high MPdist) in the series of interest, the more important the snippet is as expressed by a metric named _fraction_. For example, a sinusoidal signal and a length of interest of \(2\pi\) would be represented by one single snippet with a maximum fraction; meanwhile, a messy signal and a non-infinitesimal length of interest would be represented by the maximum possible number of snippets with minimum fraction. Notice that a time series can have no relevant snippets (zero, or too low, fraction) if it is a signal with far too high entropy. Algorithm Matrix Profile will look for the \(k\) snippets with the highest _fraction_; \(k\) provided by the user. For determining \(k\), we run the algorithm for \(k\) in the range \([1,25]\), selecting the number of snippets that confers the highest variation with respect to the summation of metric MPdist, as proposed by the author [9]. Each time series in our dataset obtained several snippets depending on its regularity and specific patterns. After extracting the snippets, we ended up with a set of 24,018 snippets. We kept only the snippets whose product \(fraction*length\_of\_the\_original\_series\) was of at least 31 days, i.e., the snippets that represent at least a month of the original series. The final set of snippets captures the most common 30-day-long series of CPAP use. As an example, if a snippet \(s\) has a fraction of 20% with respect to a time series \(t\), one can say that \(t\) behaves as described by \(s\) during 20% of the days. The remaining 80% is represented by other snippets. Figure 4 presents an example with two snippets, each one with two matches (high MPdist similarity) over the original series; the left-most snippet has a fraction of 34% while the right-most one has a fraction of 64%.