
Psychology
Smartphone keyboard dynamics predict affect in suicidal ideation
L. Knol, A. Nagpal, et al.
This innovative study by Loran Knol, Anisha Nagpal, Imogen E. Leaning, and colleagues explores how smartphone keyboard dynamics can predict affect in mental health outpatients, particularly those with suicidal ideation. By integrating self-report data and phone movement, the research unveils critical links to well-being and anhedonia, providing a novel method for analyzing digital phenotyping data.
~3 min • Beginner • English
Introduction
Traditional clinic-based mental health assessments occur infrequently and outside the context of daily life. Smartphones enable frequent, real-time assessments such as ecological momentary assessment (EMA), but active self-report imposes burden and can lead to attrition and increased measurement error. Moreover, even frequent EMA is often too sparse to capture fast affect dynamics, motivating the development of passive, unobtrusive smartphone-based measures that can predict mental state via digital phenotyping. Integrating passively collected data with self-reports is analytically challenging due to temporal misalignment across modalities (self-reports sampled daily vs. sensors sampled hundreds of times per day) and high dimensionality, necessitating principled fusion and dimensionality reduction approaches. This study introduces a pipeline to align modalities temporally, reduce dimensionality of high-dimensional self-reports using temporal ICA, and fuse with smartphone keyboard dynamics via mixed-effects models, applied to a clinical sample with recent suicidal ideation.
Literature Review
Prior work has integrated multimodal smartphone typing data (e.g., accelerometry, alphanumeric keystrokes) using deep recurrent neural architectures to predict depression and mania, employing early or late fusion and various strategies to align sparse clinical labels with dense sensor streams (e.g., temporal aggregation of sensors to the label resolution or propagation/interpolation of labels). For high-dimensional response variables, multivariate regression literature offers dimensionality reduction methods; in self-report contexts, principal component analysis (PCA) has been used to derive low-dimensional affect factors, and clustering has been applied to multivariate time series. However, these approaches can discard temporal structure or rely on feature engineering. Temporal ICA offers a way to decompose multivariate time series into statistically independent components while preserving time, potentially yielding interpretable components amenable to mixed-effects modeling for longitudinal fusion.
Methodology
Dataset and participants: Data were drawn from the CLEAR-3 randomized controlled trial examining hormonal intervention effects on menstrual-cycle exacerbation of suicidal ideation and affective symptoms. Participants were outpatients, assigned female sex at birth, aged 18–45, with past-month suicidal ideation, regular menstrual cycles (25–35 days), no hormonal medications, BMI 18–29, and without conditions likely to interfere with safe participation. Exclusions included long-term nonpsychiatric health conditions, history of hospitalization for mania/psychosis, or interfering affective/substance use disorders. Participants provided informed consent and were compensated. High-frequency daily self-report items were collected alongside passive smartphone typing dynamics via the BiAffect iOS keyboard app.
Self-reports: Thirty-four daily items covering affective, cognitive, and behavioral domains relevant to suicidal ideation were selected from DRSP, BAM, BITe, ASIQ, PANAS, INQ, and miscellaneous prior-study items. Self-reports were concatenated across participants along the temporal axis to form a p×n matrix (p items, n total days) for ICA.
Temporal ICA: Self-report Likert items were log-transformed to better suit ICA assumptions. Temporal ICA using FastICA (parallel mode, G=log cosh, a=1; R 4.2.2, fastICA 1.3.3) decomposed the data X into mixing matrix A (item loadings) and source matrix S (component time series): X = A S + ε. Multiple component solutions (e.g., 5, 10, 20) were examined; a 5-component solution is emphasized. Run-to-run variability was assessed via sensitivity analysis. Components were interpreted from the mixing matrix loadings linking original items to components.
Keyboard dynamics preprocessing: Individual keypresses were grouped into typing sessions (starting at first keypress and ending when the keyboard hid or after 6 seconds inactivity). For each session, autocorrect and backspace counts were divided by total keypresses to yield rates; total keypresses were counted. Inter-key delays (IKDs) between successive keypresses were computed to derive session-level features: median IKD (inverse typing speed), 95th percentile IKD (pausing), and mean absolute deviation (MAD) of IKD (typing speed variability). Sessions were aggregated to daily features by averaging session-level variables; total daily keypresses were summed. Days with fewer than 750 keypresses were excluded. The number of keypresses was log-transformed, and all BiAffect features were standardized (grand mean 0, variance 1).
Accelerometer preprocessing: Accelerometer samples were collected only while the BiAffect keyboard was active to limit battery burden. Samples within sessions were low-pass filtered with a 2nd-order bidirectional Butterworth filter (cutoff 4 Hz). Sample magnitudes from filtered x, y, z were used to classify activity: magnitudes <0.95 or >1.05 were labeled active (moving), otherwise stationary. A session was labeled active if >8% of its samples were active. Orientation was classified as upright if median filtered z < 0.1 and x between −0.2 and 0.2; non-upright sessions potentially indicated lying down or non-seated use. Accelerometer-derived session labels were aggregated to daily rates, including movement rate and upright rate.
Fusion via mixed-effects models: After aligning modalities to daily resolution, separate linear mixed-effects models were fit for each ICA component time series. Fixed effects included all BiAffect-derived daily features (e.g., median IKD, 95th percentile IKD, MAD IKD, autocorrect rate, backspace rate, total keypresses [log], movement rate, posture-related features). Random effects included participant-specific intercepts and random slopes across participant weeks (random intercepts per participant and random week-by-participant interactions). Model selection for random effects used a forward-fitting procedure; multiple-comparisons corrections (e.g., Bonferroni) were applied across component-feature tests. Only complete cases with both self-report and BiAffect features present per day were included. Participants with insufficient contiguous observations (e.g., fewer than two observations per week) were excluded.
Sample sizes and missingness: Of 109 participants, 104 had sufficient baseline self-report data for ICA. For mixed-effects modeling, substantial missingness in BiAffect usage and device/keyboard constraints led to exclusion of 44 participants; an additional 15 were excluded for insufficient within-week observations, yielding 55 participants for fusion models. Sensitivity analyses included restricting to contiguous data segments to assess robustness to missingness.
Key Findings
- Temporal ICA on 34 daily self-report items from 104 participants yielded interpretable components: IC1 (well-being; high loadings on FeltHappy, FeltCapable, FeltConnected, with opposing loadings on negative items), an anhedonia component, and an irritability and social dysfunction component. A mean-level component (IC3) reflecting participant-specific response means was also identified and characterized by additional analyses.
- Mixed-effects models linking daily BiAffect features to ICA components in 55 participants showed that higher phone movement while typing (movement rate) was associated with more anhedonia (β = -0.12, p = 0.0030; significant after multiple-comparisons correction in primary analyses).
- Forward selection of random slopes did not alter fixed-effect conclusions.
- Sensitivity analyses using only contiguous data segments indicated that in some subsets, the movement–anhedonia association did not survive multiple-comparisons correction, highlighting sensitivity to missingness patterns.
- IC3 appeared to capture mean response tendencies for certain participants: average self-report levels correlated negatively with IC3 values; within-participant mean-centering eliminated IC3 in reanalysis.
- Data volume: self-reports spanned 5712 total days across participants; mixed-effects analyses included a subset of participants (n=55).
Discussion
The study demonstrates a generalizable pipeline to align and integrate dense passive smartphone typing dynamics with high-dimensional daily self-reports by preserving temporal structure via temporal ICA and fusing modalities through mixed-effects models. The ICA-derived components map onto theoretically meaningful axes of affect—well-being, anhedonia, and irritability/social dysfunction—providing a compact, interpretable representation of daily mental states in individuals with recent suicidal ideation. Crucially, passively collected keyboard/accelerometer dynamics predicted these affective components: greater phone movement during typing tracked higher anhedonia, supporting the utility of unobtrusive digital phenotyping as an ecologically valid marker of low-arousal, diminished motivation/pleasure states relevant to suicide risk. The alignment of modalities at the daily level and modeling of individual heterogeneity via random effects enable robust inference across participants while accounting for within-person temporal dynamics. These findings advance multimodal digital phenotyping by showing that keyboard dynamics can index clinically relevant affective fluctuations measured by validated instruments, offering opportunities for scalable monitoring and potential early warning applications.
Conclusion
Temporal ICA provides an effective approach to reduce high-dimensional daily self-report data while preserving temporal information, enabling principled fusion with dense passive smartphone data. In a clinical outpatient cohort with recent suicidal ideation, the method revealed well-being, anhedonia, and irritability/social dysfunction components that were predicted by smartphone keyboard dynamics—particularly phone movement rates associated with anhedonia. The pipeline is widely applicable to longitudinal digital phenotyping, offering interpretable components linked to established affect theory and practical markers for mental well-being. Future work should: (1) refine mapping between anhedonia-related components and suicidal ideation constructs to inform risk prediction; (2) characterize autocorrelation and seasonal patterns in keyboard/accelerometer dynamics; (3) extend sensing beyond typing periods where feasible; and (4) evaluate generalizability in broader, more diverse populations and real-world deployment settings.
Limitations
- Missing data and incomplete days were common due to variable BiAffect usage, device/keyboard adoption issues (e.g., usability, multilingual needs, lack of compatible iOS device, technical problems), and self-report compliance, necessitating substantial exclusions and potentially biasing the analyzed sample.
- Fusion required complete daily cases and at least two observations per week per participant, further reducing sample size (to 55 participants) and possibly limiting power and generalizability.
- Accelerometer data were collected only during typing sessions, not continuously throughout the day, which may miss broader activity/posture patterns.
- Sensitivity analyses indicated that the movement–anhedonia association can lose significance under stricter missingness handling, suggesting vulnerability to data gaps.
- ICA solutions entail stochastic variability; although sensitivity analyses were conducted, component structure may vary across runs or datasets.
- The cohort was restricted to AFAB adults with recent suicidal ideation in outpatient care, limiting generalizability to other populations (e.g., males, older adults, inpatient settings).
- The link between the identified anhedonia component and suicidal ideation risk requires further validation and clearer mapping to established constructs.
- iOS-only BiAffect deployment and minimum daily keypress thresholds (>750) may introduce platform and usage biases.
Related Publications
Explore these studies to deepen your understanding of the subject.