Analysis code for the manuscript "Longitudinal patterns and determinants of statin adherence in over one million individuals from Finland and Italy" - Andrea Corbetta, Katherine M. Logan, Matteo Ferro, Luisa Zuccolo, Markus Perola, Andrea Ganna, Emanuele Di Angelantonio, Francesca Ieva (medRxiv 2026.01.26.26344722; doi: https://doi.org/10.64898/2026.01.26.26344722)
Pipelines (Finregistry / Finland and Regione Lombardia / Italy) to construct long-term medication purchase histories, compute adherence time-series (e.g., MPR), smooth trajectories, and run functional trajectory modelling with downstream clustering and association analyses.
Important: This repository contains code only. The underlying registry data are not included. Many scripts use environment-specific/hard-coded paths that you will need to adapt.
You will need individual-level longitudinal purchase/dispensing data with variables of this type (names differ by source):
- person identifier (e.g.,
ID) - dispensing/purchase date (e.g.,
DATE) - medication identifier (e.g., ATC code)
- quantity / pack information to derive pills and days supplied
- optional daily dose assumptions/derivations (some scripts filter to 1 tablet/day)
The Lombardia pipeline includes logic to merge nearby purchases (e.g., within 7 days), compute pills per purchase, and derive both point and cumulative MPR (including capped versions at 1).
Scripts are numbered to reflect the intended order.
-
Process purchase histories
Finregistry/Analysis/1_process_trajectories.RRegioneLombardia/Analysis/1_process_purchases.R
-
Select cohort & summarise
Finregistry/Analysis/2_select&summarise.RRegioneLombardia/Analysis/2_select_summarise.R(and_4covid.Rvariant)
-
Smooth adherence trajectories
Finregistry/Analysis/3_smooth_adherence.RRegioneLombardia/Analysis/3_smooth_traj.R
-
Functional data analysis
*/Analysis/4_fda.Rwith helper functions in*/Analysis/fda_funs.R
-
Create covariates / cluster trajectories
5.1_create_endpoints.R,5.2_create_socioeco.R,5.3_create_medication.R- Lombardia additionally:
5.4_create_visits.R - Clustering scripts:
Finregistry/Analysis/5_cluster_curves.RRegioneLombardia/Analysis/5_cluster.R
-
Assemble covariate table
*/Analysis/6_covariates.R
-
Fit models
*/Analysis/7_models.R- Lombardia also:
models_PC.Randsummary_stats.R