Citation: Liu, G.; Onnela, J.-P. Online
Anomaly Detection for Smartphone-
Based Multivariate Behavioral Time
Series Data. Sensors 2022, 22, 2110.
https://doi.org/10.3390/s22062110
Academic Editors: Sławomir
Nowaczyk, Rita P. Ribeiro
and Grzegorz Nalepa
Received: 4 February 2022
Accepted: 3 March 2022
Published: 9 March 2022
Publisher’s Note: MDPI stays neutral
with regard to jurisdictional claims in
published maps and institutional affil-
iations.
Copyright: © 2022 by the authors.
Licensee MDPI, Basel, Switzerland.
This article is an open access article
distributed under the terms and
conditions of the Creative Commons
Attribution (CC BY) license (https://
creativecommons.org/licenses/by/
4.0/).
Article
Online Anomaly Detection for Smartphone-Based Multivariate
Behavioral Time Series Data
Gang Liu * and Jukka-Pekka Onnela
Department of Biostatistics, Harvard T.H. Chan School of Public Health, Boston, MA 02115, USA;
onnela@hsph.harvard.edu
* Correspondence: gang_liu@g.harvard.edu
Abstract:
Smartphones can be used to collect granular behavioral data unobtrusively, over long time
periods, in real-world settings. To detect aberrant behaviors in large volumes of passively collected
smartphone data, we propose an online anomaly detection method using Hotelling’s T-squared test.
The test statistic in our method was a weighted average, with more weight on the between-individual
component when the amount of data available for the individual was limited and more weight on
the within-individual component when the data were adequate. The algorithm took only an
O(
1
)
runtime in each update, and the required memory usage was fixed after a pre-specified number of
updates. The performance of the proposed method, in terms of accuracy, sensitivity, and specificity,
was consistently better than or equal to the offline method that it was built upon, depending on the
sample size of the individual data. Future applications of our method include early detection of
surgical complications during recovery and the possible prevention of the relapse of patients with
serious mental illness.
Keywords: online learning; anomaly detection; Hotelling’s T-squared test; digital phenotyping
1. Introduction
Digital phenotyping has been defined as “the moment-by-moment quantification of
the individual-level human phenotype in situ using data from personal digital devices,”
in particular smartphones [
1
]. Passively collected smartphone behavioral data [
2
] consist
of data from sensors, such as the built-in Global Positioning System (GPS) and accelerom-
eter, as well as phone usage data, such as communication logs and screen activity logs.
Anomalies in such multivariate time series (MTS) have been shown to be predictive of
relapse for patients with schizophrenia [
3
,
4
] and depressive symptoms for women at risk
of perinatal depression [
5
]. Barnett et al. [
3
] proposed an unsupervised semi-parametric
anomaly detection method that is robust against mis-specification of the distribution of
a time series. The method was applied to a passively collected smartphone behavioral
dataset to detect an escalation of symptoms or signs of a potential relapse. The method
decomposes the observed MTS into a general trend, a periodic component, and an error
component for each dimension. The error components are then used to build Hotelling’s
T-squared test statistic and identify anomalies. Henson et al. [
6
] applied the method to
predict relapse in schizophrenia and achieved 89% sensitivity and 75% specificity in a
cohort of 126 participants followed for 3–12 mo.
There are two main limitations to the method described by Barnett et al. [
3
]. First, the
offline algorithm is used mainly to identify anomalous behaviors in a one-time retrospective
analysis, where computational performance is not critical. If, however, the goal is to carry
out anomaly detection as data are being collected over time (and possibly even in real time)
rather than at the end of a data collection period, the method needs to scale to large cohorts
of individuals followed for months or years. Second, the offline method uses only within-
individual comparisons to overcome the heterogeneity of the data and requires at least two
weeks of data to establish the individual baseline for comparisons. This approach is not
ideal for anomaly detection in many health-related settings, from surgery to rehabilitation,
Sensors 2022, 22, 2110. https://doi.org/10.3390/s22062110 https://www.mdpi.com/journal/sensors