A Data-Driven Exploration of Mental Health Trends in Scotland Pre- & Post-COVID-19 (R & Shiny)
As part of my MSc in Applied Data Analytics at the University of the Highlands and Islands (UHI), I used public health data, advanced time-series modelling and visual analytics to understand how COVID-19 reshaped mental health service patterns across Scotland and to translate complex results into an interactive Shiny dashboard for evidence-based decision-making.
Problem
Public discussion during the pandemic highlighted loneliness, anxiety and burnout but evidence was often fragmented. This project set out to answer three questions using data rather than assumption:
- Did mental health service use rise or fall after COVID-19 began?
- Which age groups and regions were most affected?
- How did policy changes and NHS pressures influence access to care?
The goal was to transform Scotland’s public health data into actionable insight that can inform future policy, planning and equitable recovery.
Data
- Sources: Public Health Scotland and NHS Scotland datasets
- Time period: 2018–2023 (pre- and post-March 2020 disruption)
- Key measures: psychiatric inpatient admissions and referrals
- Context indicators: mental health expenditure by local authority
- Breakdowns: health board, age, gender and geographic variation
- Diagnostics: ICD-10 categories (e.g., schizophrenia, depression, anxiety)
Data were cleaned and harmonised in R (dplyr, tidyr, lubridate), including time-series indexing (monthly), handling missing values and inconsistencies and creating normalised indicators for cross-regional comparisons.
Methods
- Interrupted Time-Series (ITS) Analysis: estimated the immediate shock (March 2020) and longer-term slope changes after COVID-19 began
- Mixed-Effects Regression (GLMM, lme4): modelled service use over time while accounting for health board variation
- Model structure: fixed effects (time, spending, pandemic indicator) + random effects (health board)
- Quality & ethics: sensitivity checks with lagged models, cross-year validation, aggregate/anonymised data only
Results
- Sharp decline in inpatient admissions: early 2020 drops (over ~25% in some regions) with incomplete recovery-suggesting constrained access/capacity rather than reduced need
- Regional and age inequalities: steepest reductions in urban boards (e.g., Greater Glasgow & Clyde, Lothian, Grampian) and strongest impact on younger adults (18–29)
- Diagnosis patterns: severe disorders (e.g., schizophrenia, bipolar) remained comparatively stable, while depression and anxiety admissions fell sharply-consistent with shifts toward remote care
- Spending vs service use: despite rising mental health budgets, inpatient activity did not rebound-indicating systemic changes in how support is accessed and delivered
Essentially, the findings show both adaptation and widening gaps: digital/community services expanded, but the transition created uneven access across regions and groups. The work reinforces that careful analytics can illuminate social realities and support equitable resource targeting.
Visual Analytics: R Shiny Dashboard
To make the insights accessible, I built an interactive Shiny dashboard that enables exploration of: diagnosis trends, demographic patterns, health board comparisons by year, and pre-/post-COVID changes. The dashboard bridges advanced modelling with practical public health storytelling.