Diabetes and Data. What more can we learn? Part 1.

Diabetes and Data. What more can we learn? Part 1.
Diabetes and Data. What more can we learn? Part 1.

As people with diabetes, using CGMs, AIDs and pumps, we are walking, talking data sources.

But we don’t just have diabetes data. On top of that, devices like smart watches provide sleep, heart rate and steps data. And that data is more nuanced than simple numbers.

Diatribe’s 42 factors that affect Diabetes

If we start with the Diatribe 42 factors, there are a number of clear biological areas that are believed to affect diabetes. We have the ability to measure a significant proportion of these, and the easiest to extract data for are sleep time and light activity amounts and patterns. Garmin devices also offer up a stress option, but the data is based on heart rate variability, so needs more investigation into suitability.

I’ve been looking at this data over a period from 27th February to 15th March (so roughly six weeks) to see what relationships or patterns can be found in the data. Is any one set of data a predictor of another? The period of time is fairly consistent around behaviour both in the week and at weekends, as well as around work/non-work periods.

Data sources and capture

Data has been captured through the following variety of devices:

  • Dexcom ONE CGM
  • AndroidAPS
  • Garmin Venu 2

The data that I’m looking at for relationships is:

  • Total daily dose
  • Time in Range
  • Step count
  • Step distribution
  • Daily sleep hours

Some of the analysis requires various graphing techniques whilst a lot of it is basic correlation and regression, to see if there is any relationship and if there is, how strong it might be.

So that’s where we’ll start. The first part of this n=1 review looks only at total daily dose outcomes. Part two will look at time in range.

Is there any relationship between hours of sleep or step count and Total Daily Dose?

Let’s start with a simple set of graphics that show distribution of these inputs and outputs over an average week.

These “box and whisker” plots display the mean value as a cross, the median value as the line across the box and the box represents the range between 25% and 75% of data points. The “whiskers” are the maximum and minimum values, and therefore range.

Box and whisker plot showing sleep hours by day of the week
Sleep hours distribution by day
Steps distribution per day
Total daily dose box and whisker plot by day of the week
TDD distribution by day

These graphs show that my daily hours of sleep are generally a couple of hours longer on a Friday night and Saturday night than on a week night.

We can also see that step counts are marginally greater at the weekend, but not of the same magnitude as the difference in sleep.

Finally, the total daily dose data at the weekend generally shows both a tighter distribution and a lower average compared with during the week, where the mean progressively increases, along with the range of TDDs.

Superficially, it looks as though there is a link between these inputs and outputs, however, taking a deeper dive into this, we see that the relationship looks a lot less obvious.

TDD and Sleep

Scatter plot of TDD vs sleep hours

The points on the graph are much more widely distributed, even though the linear trendline appears to show a relationship.

Regression statistics for TDD in relation to sleep hours also don’t show a strong relationship, with a correlation coefficient of -0.5. The p-value of this n=1 dataset is 0.0007, which suggests that even though the correlation isn’t all that strong, it never the less, has some significance.

TDD and Step count

Total Step count

Scatter plot of step count and TDD

The scatter plot TDD in relation to step count above shows a lot of variation in the data, and when the data is analysed, this is reflected.

The correlation coefficient is very low (-0.198) and the p-value is 0.187, considerably higher than 0.05.

While the images of daily step count and TDD appear to have quite a bit in common, the analysis suggests that it is a very weak and non-significant relationship, and shouldn’t really be relied upon.

Step count patterns

The step count data, as I have shown, shows a weak correlation to total daily dose, however, when you look at the patterns in step count, you see a different story.

Whilst average daily step count isn’t vastly different on a day to day basis, the distribution typically is. Most weekdays I walk to and from work, but am mostly sedentary in between. The graph below shows the “Bidaily” distribution of steps.

Bidaily step distribution

There are clear start and end of day lumps, with 10 hours in the middle when I don’t do very much.

This contrasts significantly with weekends and days when I’m not working, which looks a lot more like the following graph.

Distributed Step count

This shows a much more evenly distributed step count, even though the two totals in the graphs are not widely different.

If we refer back to the plot in the earlier section, it’s clear that mean and median step counts vary by very little and as we determined in the last section, actual step numbers seem not to play a large part in TDD. But what happens when we look at the data using these patterns?

Here we can see that the mean TDD and perhaps more importantly, the variation of TDD, is much lower with a distributed pattern than a bidaily pattern.

Again, running a regression on the underlying data, whilst the correlation between step count pattern and TDD is higher than the others we’ve tested (0.6), which suggests a moderate correlation, it has a very low p-value (0.000027), which suggests there’s a high level of significance.


What this data analysis appears to show is that there may be a form of relationship between sleep data and TDD, and also step pattern data and TDD. The question arises as to whether there is anything else involved, and what might an experiment to determine that look like? We already know that food is going to play a part in TDD values, as are specifics of exercise.

It also opens up the question as to whether patterns within the period of sleep (REM and Deep sleep amounts) also play a part?

Looking at the box and whisker charts for TDD and sleep, the variation in TDD as the week progresses is fairly clear. Is it possible that the continued exposure to a reduced sleep factor plays a part in this? Could there be some sort of weighted average of “sleep hours” that indicates an increased resistance with respect to number of days with reduced sleep?

We already have the Diabetes UK sponsored research that showed how “activity snacking” (regular walking breaks) helps to improve glucose management. The data presented here seems to tie in with that research. It also raises questions over the validity of doing 10,000 steps per day if it’s in a couple of bouts of 4,000 rather than regularly distributed over the day, and if it has any effect on diabetes management?

Or are all of these items simply correlations that reflect environmental factors? Is it possible that I’m more likely to go out for dinner on a Thursday evening that affects TDD levels the next day? Is what I eat on a Friday really the driver of the variation?

Without further experimentation, the answers to these questions can’t be  provided.

The other aspect this opens up is if a link is really proven, how might this data be integrated into AID algorithms? Garmin data isn’t always easily integrated, but access to things like Fit and Health on Android and Apple are relatively easily integrated and clearly documented. Could variation in sleep and step patterns be used to indicate to an AID system when it should raise and lower insulin profiles? Could it be used to indicate to MDI users when they might need to change basal rates (when using InPen for example)?

The next part of this investigation looks at whether these factors influence time in range, and again, what those relationships look like. This may help answer the last question, above, as to the validity of this data in adjusting insulin.


  1. Just one quick thought about the relation sleep to TDD:
    The more you sleep the less time you have for eating – maybe this is one obvious reason for this relation.
    Example: you sleep longer on weekends and skip one meal completely, e.g. breakfast. You then stick to two meals only, lunch and dinner which then results in less TDD.
    Just a thought to think about.

Leave a Reply

Your email address will not be published.