They say exercise improves sleep quality. Is that true for me?

To test this hypothesis, I took my daily calorie expenditures from the Apple Health app and correlated them with that night’s sleep time.1 I also included caffeine intake as a potential confounding variable.

The hypothesis: when I exercise more, I’ll get better rest that night, and therefore wake up earlier.

The results:2

name coef t-stat p-value
intercept 9.0134 65.072 0.0000
calories -1.6844 -6.967 0.0000
caffeine 0.4157 9.404 0.0000
0.2409    

I sleep 10 minutes less for every additional 100 calories of exercise. Exercise plus caffeine explained 24% of the variance in my sleep time; exercise alone explained 6.6%.

The trend shows up whether or not I have caffeine:

Data are binned into increments of 100 calories. Any bins with fewer than 5 data points are not displayed. Vertical lines show the 95% confidence intervals for each bin.

I also regressed bedtime and wake time. Am I sleeping less because I’m going to bed later, or because I’m waking up earlier (or both)?

Exercise did not reliably predict my bedtime (nor did caffeine):

name coef t-stat p-value
intercept3 20.9879 36.742 0.0000
calories 0.9083 0.911 0.3626
caffeine -0.0468 -0.257 0.7973
0.0018    

But exercise did predict that I’d wake up earlier:4

name coef t-stat p-value
intercept 7.6143 61.200 0.0000
calories -1.8247 -8.402 0.0000
caffeine 0.4023 10.132 0.0000
0.2879    

I hardly ever set an alarm, so the quality of my sleep is an important determinant of when I wake up.5

R² for exercise alone (controlling for caffeine):

dependent variable
time asleep 0.0662
bedtime 0.0012
wake time 0.0934

Robustness checks

Using step count instead of calories burned

Change in sleep per 1000 steps, according to my daily step count on Apple Health:

name coef t-stat p-value
intercept 8.6728 57.609 0.0000
step count -0.0608 -3.823 0.0001
caffeine 0.4760 10.722 0.0000
0.2041    

A visualization of the trend:6

Extended time horizon

For all the calculations up to this point, I included data from 2024-01-01 through 2025-12-08. I have data from 2021 through yesterday, but I narrowed the data range to keep the data clean:

  • My exercise volume trended upward throughout 2022 and 2023, and stabilized around late 2023/early 2024. I excluded the earlier years in case there was a confounding effect where the long-term upward trend in exercise is correlated with a long-term downward trend in sleep.
  • Starting 2025-12-09, I’ve started setting an alarm at 9pm to remind myself to go to bed. I don’t think that matters, but the recent period is short enough that I don’t lose much statistical power by excluding it.

Here’s the result of a regression when I include the older data (2021-01-14 to 2025-12-08):

name coef t-stat p-value
0.1229    
intercept 8.5683 133.197 0.0000
calories -0.5954 -4.397 0.0000
caffeine 0.2835 10.958 0.0000

Methodology details

I chose calorie expenditure as the independent variable and time in bed as the dependent variable.

Why I chose calorie expenditure:

  • Apple Health gives me data on step count and calories, according to my iPhone. (An Apple Watch would be more accurate, but I don’t have one.)
  • The calorie estimate should incorporate more information than step count.
  • Calorie estimates are systematically wrong because my phone can’t tell when I’m lifting weights, but my weight routine is relatively consistent across time, so this shouldn’t qualitatively change the result.
  • I record my subjective productivity on all work days, but (as I’ve found in previous observational studies) productivity varies too much based on too many factors, which makes it hard to find statistically robust correlations.

Why I chose time in bed:

  • The Sleep Cycle app records my sleep and gives estimates of “time asleep” and “sleep quality”. From previous observational studies, I know that the app’s sleep quality estimates are negatively useful—they are less predictive than a raw “time in bed” number, which measures the time from when I start running the app to when I tell it to stop.
  • “Time in bed” includes a manual adjustment for any time I spend awake overnight (rounded to the nearest half hour).
  • If I got up to pee and then fell back asleep quickly, I counted that as a 15 minute loss.

Notes

  1. I measure sleep as “time in bed” according to my Sleep Cycle app, with a manual adjustment for time spent awake overnight. See Methodology for details. 

    • The dependent variable (sleep time) is measured in hours.
    • Calories are divided by 1000, to make the numbers more readable.
    • Caffeine is measured in units of 100mg. Coffee is my source of caffeine, and I estimate one cup of coffee at 100mg.

  2. The intercept should be interpreted as clock time on a 24-hour clock, so 20.9879 is 9:59 pm. 

  3. Having caffeine predicts that I wake up later the next morning. I’d speculate that there are two reasons for this:

    • Caffeine hurts my sleep quality, making my body want to sleep for longer.
    • I tend to work on caffeine days and not work on non-caffeine days, and they tend to alternate. Anecdotally, I’ve observed that I wake up earlier on work days: the fact that I’m anticipating work means I have a hard time waking up briefly and then going back to sleep. I don’t think this is related to caffeine, because when I have a no-caffeine rest day followed by another no-caffeine rest day, I have no problem sleeping in.

  4. Other determinants include:

    • Are there birds singing right outside my window?
    • Is the sun shining? (I have blackout curtains, but the light that seeps through the cracks can still wake me up.)

  5. I would like to take a moment to pat myself on the back for the fact that during this two-year period, there were only 23 days where I took fewer than 4,000 steps. And I went to the gym on half of those days, and I had the flu for half of the other half, so really it was only 6 days or something.