top of page

Simulating Sleep Quality
Trajectories Over Time
Imagine tracking 1,000 sleepers over time, some maintain steady, good sleep quality, others gradually improve, while the rest follow more varied and unpredictable sleep journeys.

Code
This R function generates three sleep quality journeys over time by simulating Pittsburgh Sleep Quality Index (PSQI) scores with random fluctuations that reflect real-world variability.

Data
A simulated dataset of 1,000 individuals was generated, including a synthetic total score (0–21) based on a seven-item PSQI at each measurement point (week 0, week 2, …week 16).

Figure
42.0% maintain stable, good sleep quality over time (green), 30.3% show gradual improvement (purple), and the rest are not intentionally grouped into any specific trajectory (gray).
bottom of page
