Determine your Fitbit stride length using a GPS watch

I have been carrying my Fitbit One for a little over two years with me and it keeps tracking my daily steps. It also tracks my distance covered by multiplying those steps using the stride length which you can either provide explicitly or implicitly setting your heights. In the winter of 2012 I bought my first Garmin Forerunner 410 (replaced by a Garmin Forerunner 920XT) GPS watch to help me track my running (and other outdoor) activities. Since then I have worn it at every activity. Additionally before every running session I started a Fitbit activity to measure my step count. Over the last 18 month I have recorded 69 runs using both, the Fitbit and the watch. I put the data in a csv file so I could load it into R. Then I performed a linear regression to determine my stride length.

<img src="" alt="Fitbit Stride Length Regression" class="alignnone size-full wp-image-215" srcset=" 1200w, 300w, le viagra de 1024w, 624w” sizes=”(max-width: 600px) 100vw, 600px” data-recalc-dims=”1″ />

In an ideal world, where the GPS watch would perform with a 100% accuracy and the Fitbit would recognize every single step taken, the regression fit would meet the origin. Unfortunately neither of them is that accurate. Our model gives us an intercept of 398.46m with a slope of 1.00421m and an adjusted R^2 of 0.97505 Based on that I have covered a whole lap of a competitive running track before I made a single step. 😉

I have noticed that the placement of the Fitbit has a huge impact on the amount of steps recorded. Attached to the pocket of my running shorts it seems to miss certain steps. I get much better results attaching it directly at my waist. Overall I am quite satisfied with the accuracy provided by the Fitbit. If you do a lot of interval training or vary your stride from session to session your result will be far more off.

The code for the regression is on Github:
.gist table { margin-bottom: 0; }

Analyzing Sleep with Sleep Cycle App and R

I have been tracking my sleep for almost two years now using my Fitbit. I started with the Fitbit Ultra and then moved on the the Fitbit One after it came out. In October 2013 I found out about the Sleep Cycle (Link) app for the iPhone. For weeks, Sleep Cycle was listed as the best-selling health app in Germany, where currently (as of January 2014) it is in second place. The program promises, to wake you up in the morning without being tired. This is indeed possible if the alarm goes off in light sleep and not in deep sleep. It also allows you to set some kind of sleep music (white noise) to assist you to fall asleep. After reading all the positive reviews on the AppStore I decided to give it a try.

The app promises to wake you up in a time frame up to 30 minutes prior to the alarm you set if it detects your movement in the morning. Even more important to me than the actual smart alarm feature was the possibility to collect some data while sleeping. In the morning you are presented with a chart of your sleep pattern of last night:
Sleep Cycle Screenshot of last night

The app also allows to export the database as a comma separated file containing: time you went to bed, time you woke up, sleep quality in %, wake up mood and user defined sleep notes. This gives you the opportunity to do some more analysis. I decided to fire up R and create my own charts.

So far I have used the app to track 100 nights of sleep and decided to peak into the data. Let’s take a look how long I slept each night:
Sleep Duration over time

It looks like the longer I slept the higher the sleep quality is. A scatter plot of the data gives:
Sleep time vs. sleep quality

The chart takes also the sleep notes into consideration. You can see clearly that sleeping away from home results in lower sleep quality. The same applies for exercising (note: I tagged a sleep with exercising when I worked out late in the evening). On the contrary taking a melatonin (dosage 3mg) increased the sleep quality.

Averaging the sleep quality by month shows, that the January worse than the previous month. One explanation is a vacation I took, where I did not sleep so well at all.
Average sleep quality by month

The R code for the data wrangling and the charts:

Five years of Weight Tracking

After I moved back from New Jersey in June 2008 I started to track my body weight more seriously. My routine usually consists of getting up and after finishing the morning bathroom I would step on my scale. That way I try to ensure that the condition for each weighing are as similar as possible. I recorded my weight on paper and eventually would put everything into a spreadsheet for further analysis.

In January 2011 I upgraded my bathroom scale to the Withings WiFi Body Scale. That way I could automate the process of tracking my weight by just stepping on it. No more writing on paper and eventually transferring everything into spreadsheets.

The people at Withings provide an API so external services could access your weight data. A nice way to get better charts is through Trendweight. Just link your Withings account to the web site and they will generate nice JavaScript charts of your weight/body fat/lean mass. Another great feature is the export functionality where you can export a comma separated version of your data including trend values for total weight as well as fat %, fat mass, and lean mass.

Using the exported data we can fire up R to look at the data:

The generated chart shows my weight loss in 2009, where I started cycling again after years of absence. From my lowest in the Fall of 2009 I gradually gained weight throughout 2010, 2011 until 2012, where I hit the 100 kg mark around Christmas time:

Body Weight 2008 - 2013

That was enough and I decided it was time to start working out again. So far, I am at a good downwards trend. I have to keep up that momentum. My next goal is to get between 80 kg and 85 kg and then maintain my weight. The color of the dots reflect my body fat percentage and there seems to be a strong correlation between body fat and my actual weight:

Body Weight vs. Body Fat Percentage

Doing a simple linear regression gives us an adjusted R-squared of 0.8419

Downloading Fitbit Data using Google Spreadsheets

One of the most important features in quantified self is the ability to export your data in an open format. Fitbit lets you download your personal data if you subscribe to a premium membership. Alternatively they provide an API at that allows developers to interact with Fitbit data in their own applications, products and services.

In a blog post at Mark Levitt shows a way how to export your Fitbit data into Google Spreadsheets. I explored to API myself adding and removing some of the fields to get more insights to the data.

In a future post I will delve into the data in order to understand some of my own physical activity patterns.

Update 14 November 2014: I removed the Active Score since it has been dropped by the Fitbit API