Mental Health Trends in Scotland Pre- & Post-COVID-19 (R & Shiny)

A public-health analytics project examining how the COVID-19 pandemic reshaped mental-health service use across Scotland, using time-series modelling, mixed-effects regression and an interactive Shiny dashboard.

Project Motivation

During the COVID-19 pandemic, public discussion frequently highlighted rising loneliness, anxiety and burnout. However, the evidence behind these narratives was often fragmented.

This project aimed to answer several data-driven questions:

The objective was to transform Scotland’s public health data into actionable insights that could inform policy discussions, resource planning and equitable recovery strategies.

Data Sources

Diagnostic data were organised using ICD-10 categories including schizophrenia, bipolar disorder, depression and anxiety-related conditions.

Data Preparation

All datasets were cleaned and harmonised in R using packages such as dplyr, tidyr and lubridate.

Methods and Modelling

Two complementary analytical approaches were used to evaluate changes in mental-health service patterns.

Interrupted Time-Series Analysis

Interrupted Time-Series modelling was used to detect whether March 2020, when COVID-19 restrictions began, caused a structural break in service use. The model estimated both the immediate shock and subsequent trend changes.

Mixed-Effects Regression (GLMM)

Mixed-effects models were used to account for regional variation across health boards.

This approach allowed the analysis to capture both national trends and regional differences in service disruption.

Key Findings

Admission Change (Early 2020)
≈ 25% decline
Most Affected Age Group
18–29 years
Regions Most Impacted
Glasgow, Lothian, Grampian
Budget vs Service Activity
Spending rose while inpatient activity remained below pre-pandemic levels

Interpretation

These patterns suggest that service delivery shifted towards community-based and remote care, while hospital capacity constraints limited inpatient access.

Visual Analytics: The Shiny Dashboard

To translate the statistical modelling into an accessible tool, an interactive Shiny dashboard was developed.

The dashboard allows users to explore:

This interactive environment bridges advanced statistical modelling with clear visual storytelling for policymakers and public-health stakeholders.

Interactive Dashboard Preview

Open Live Dashboard
Mental Health Shiny Dashboard preview Mental Health Shiny Dashboard preview

Note: Posit Cloud blocks embedded previews on external websites. Use “Open Live Dashboard” to interact with the app.

Ethics and Data Responsibility

All analysis used publicly available, aggregated and anonymised datasets. Several methodological checks were performed to maintain integrity:

The project emphasises responsible analytics where statistical evidence informs policy decisions while protecting privacy and avoiding misuse of sensitive health data.

Impact and Practical Value

Project Links