Track Heart and Lung Health With A Smart Watch: VO₂ Max Case Study

Author:Murphy  |  View: 27409  |  Time: 2025-03-23 19:37:36

 

In this post, we will look at how Fitbit measures your VO₂ Max, track how it changes over time, and derive useful insights to give a better steer on how to improve it over time. You will also see how I have used a simple concept of multiple regression to better understand how Fitbit derives this measure from speed, and heart rate, and the use of contour plots for further insight.

But before I go any further, I will take a brief detour to explain the importance of tracking your heart and lung health and introduce VO₂ Max.


Why Should I Measure Heart and Lung Health?

No matter how young you currently are, one thing is dead certain: you will enter your "marginal decade"- the last 10 years of your life. This could be your 80s, 90s, or after crossing 100. Whatever the range is, it sure will happen!

I first heard about this concept from Dr. Peter Attia, an American-Canadian physician, who asks his patients to work out the kind of life that they would like to lead when they are in their marginal decade (e.g. having the ability to walk upstairs without getting breathless, able to lift or play with grand-child, etc.). Once the patient details the kind of life they would like, Peter then helps quantify the desired activity levels into Fitness measures. The next step is to "back-cast" it to the present age knowing that whatever you want in old age, you better be at a much higher fitness level at present since there is a certain percentage of decline as we all age.

Forget about improving something if you don't even measure it!

VO₂ Max As a Measure of Fitness

VO₂ Max is one of the most widely used metrics of cardiorespiratory capacity. It measures the maximum volume of oxygen that your muscles can use when Running at the fastest speed that you can sustain for a period of time.

In a scientific, peer-reviewed study (published in JAMA Network) of data from over 100,000 patients followed over several years (1.1 million person-years in total), there was a five-fold difference in the risk of death over a decade between those with low fitness compared to those with elite-level fitness.

Having a high VO₂ Max is not only desirable but essential to ensure adequate strength and energy when you enter your marginal decade.

Smart Watches Can Estimate VO₂ Max

The gold standard method to measure VO₂ Max is in a laboratory with a mask that analyses your breath for O₂ and CO₂ while simultaneously measuring heart rate during intense activity (e.g. running on a treadmill).

And here is some good news for you. _You don't need to go to a laboratory to measure your VOmax. Smartwatches now do a pretty good job. You can improve your VOMax over time._ This is precisely what I did after having my Fitbit for over 2 years now. Let's dive in.


VO₂ Max in Fitbit

Within the Fitbit app, you can check your fitness score by navigating to the ‘Heart Rate" section and clicking on "Cardio Fitness".

Once you see this score, you are more likely to take action and improve over time. The following figure shows how my score changed over the past three years. After I began paying attention to this score, I found the motivation to improve it.

 

Reverse-Engineering Fitbit's VO₂ Max Algorithm

Let's dive deeper now. If you own Fitbit, you can generate the rest of the plots on your own data by following the subsequent steps. If you don't own one yet, you can read the rest to get an idea and return to this post once you own a smartwatch.

Download all data

First off, I downloaded all my Fitbit data. My previous post explains how you can do this.

How Tracking Data Helped Me Consistently Exercise for 2 years

Briefly, you have a full right to your data and you can request to get all of that, at most once every 24 hours from Fitbit. Once you log into your account, you need to select "Request All Data" and then follow the instructions. The downloaded data is all structured, in a mix of JSON and CSV formats. The folder where we have all the relevant data is "Physical Activity".

Data Preprocessing

Our first job is to convert the downloaded raw data into a suitable format in a statistical software package of choice. Currently, both R and Python are good choices. I have chosen R.

The key files we will look at are named "exercise-number" which is in JSON format. The number starts from 0 and then increments by 100. A single session could be any activity recorded, such as walking, running, cycling, etc.

You need a slight bit of manipulation to automatically read these files (check my GitHub repository to get the code). In brief, the data preprocessing steps include the following:

  • clear the workspace and load relevant libraries
  • set relevant parameters (file location, and variable selection)
  • go through each file, retrieve the data, and store it in a single data frame
  • filter the data frame to keep only ‘Run' activities

First Order Multiple Regression

The final data frame consists of several columns including speed, pace, steps, distance, calories, VO₂ Max (as computed by FitBit), and the average heart rate.

 

Next, I attempted to find the coefficients of a simple linear equation where the dependent variable was VO₂ Max, and the independent variables were speed and average heart rate.

lm.fit <- lm(vo2MaxCorrected~speed+averageHeartRate, data=data_all)

You can try several other combinations including adding further data columns. From my investigation though, computing VO₂ Max based on only speed and average heart rate was reasonably accurate with a low residual error (2.933, see summary of the model fit below).

 

This model suggests that both speed and average heart rate are significant. For a given average heart rate, if you complete it at a faster speed, you will end up with a higher VO₂ Max. Conversely, if you can manage a lower heart rate for a given speed, your VO₂ Max will improve.

One other model that I tried was to include ‘distance' in the model. Perhaps not surprisingly, the amount of distance traveled is also independently associated with VO₂ Max computed by FitBit in this data. The residual error reduces slightly further but the coefficient values of average heart rate and speed are comparable to the earlier model when the distance variable was not included.

 

I tried several other combinations including exploring interaction terms but the simple equation does pretty reasonable.

 

This equation tells me that, for a given distance and average heart rate, I can raise my VO₂ Max if I run faster. For a one-unit increase in speed (km/hr), I can increase my VO₂ Max by 2 units.

Let's quantify this further with a 5 km distance example. Completing a 5 km distance in 30 minutes (doable for most folks with little training) is equal to 10 km/hr, or the same as completing one km in 6 minutes. Now, if you increase your speed to 12 km/hr, you will be able to complete the 5 km distance in 25 minutes, or 5 minutes per kilometer. This improvement of completing a 5 km from 30 to 25 minutes will increase your VO₂ Max by 4 units.

Second Order Multiple Regression & Contour Plots

The previous regression model only uses first-order feature values. You can investigate the relationship between VO₂ Max and additional features derived from the data columns (e.g. speed squared, distance squared, distance x speed, etc.). The challenge with such models however is difficulty in interpreting them.

For illustration, here is one more model where I have used second-order features for both speed and average heart rate.

 

This model gives an even smaller standard residual error (2.17) and performs decently. For this model, we can visualize how different combinations of speed and distance affect VO₂ Max with a contour plot.

 

For the contour plot, I have chosen a reasonable range for heart rate (130–180 bpm) and speed (8–15 km/hr) which should be in the realm of most people going from absolute beginners to an amateur level.

 

This contour plot is quite interesting. It clearly shows that, for a given speed, a lower average heart rate will lead to a higher VO₂ Max. Further, for a given average heart rate, an increase in speed will lead to a higher VO₂ Max.

This contour plot also clearly shows me that, over the years, my average heart rate has hovered around 160 (small variance along the heart rate axis) but my speed has substantially improved. To me, this suggests that if you want to improve your VO₂ Max, you must try to increase your pace.

I hope that the above investigation has inspired you to track your own fitness. You can find all the code that I used to generate the plots in my GitHub repository. Feel free to copy/reuse it on your own activity data.

Tags: Data Science Fitness Machine Learning Running Sports

Comment