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.

fun_scot_edited_edited.jpg

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.

sample_df_edited.jpg

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).

traj_p.jpg

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).

Welcome to my e-home, and thanks for stopping by!

Here's where I stash my data viz creations, dive into analysis adventures, and share the coolest research sparks. You'll also catch glimpses of my "oceanic expedition"—a wild ride through curiosity and discovery. Feel free to snoop around, explore, and reach out with any ideas. I'm always up for a coffee chat!​

© 2025 by Chun-Yuan Chen. Powered and secured by Wix. Licensed under CC BY-NC-ND 4.0.

bottom of page