Unevenly spaced time series analysis

A number of years ago I bought a Withings connected scale. It’s great. You get on every morning, it logs your weight and uploads it to the internet where it can be analyzed.

Recently, I decided to use the Withing API to build a plot that I could include on my homepage to keep an eye on my weight. Something every weight-watcher knows though is your weight fluctuates and so it’s great to keep an average. Unfortunately, unevenly spaced time series do not interact well with simple moving averages, so I found this paper and converted the code into javascript:

The algorithm expects data in a variable called json_data. It’s an array of arrays, each of which is a timestamp and data pair. (This is the form that Highcharts expects.) The key factor is tau, the length of the time window over which you’re averaging. I have it set to a week here which I think is about right for looking at human weight. (3.5 days works quite well too.)

The results are here:



The code in context and a cleaner running example are both available. You can also see the raw data I use to fuel the graph.


Posted

in

by

Tags: