For a couple of years I've had some trouble sleeping. I'm not sure how much of this is due simply to age or the disruption of having a small child. However, lately I find that even when my daughter sleeps soundly, I often find myself waking too early.
I've taken the usual medical advice and found little improvement. GPs seem unwilling to investigate after they've done the standard checks and decided there's nothing seriously wrong with me. Frustrated, I decided to do some work on it myself. Part of my day job is data analysis and I figured that if I can record the right data I might be able to write some code to work out what is causing me to lose sleep. Or, as Mark Watney might say,
I'm gonna have to data science the shit outta this!
I started a couple of months ago, simply with a spreadsheet recording rather subjectively, thirteen different aspects of my day which I thought might influence my sleep. Things I thought might make a difference to my sleep but are hard to pin down without recording data due to the many confounding factors.
Things like exercise, evening meal size, evening screen time, daylight hours, worry etc. Where no simple measurement scale exists, I estimate a number from one to five. So my ten minute cycle to the station and back counts as 2/5 for exercise. Only a 100km+ ride gets a 5/5. As I said, it's a bit subjective, but hopefully enough to be useful. There's no way I'm going to carry a light meter round with me or start weighing my meals. As it is, recording the data takes barely two minutes a day. The following morning I record roughly how much sleep I think I got, in hours. I have set the spreadsheet to calculate the average over the last five days.
What might be a bit more accurate is a gadget I've acquired recently, an EMFit QS. This intends to measure both my sleep and heart rate throughout the night, producing all kinds of numbers describing how well I've slept and recovered from exercise. I'm not sure I've fully understood how to use it or whether I've got it set up right yet, but I'm adding some of the numbers to my spreadsheet in the hope it will give me some clues.
I haven't yet decided on what techniques I'll use to analyse this data and spot patterns, but I intend to start with a straightforward correlation matrix before moving on to something more sophisticated that can look at results from previous days in case for example, the exercise or food I ate two days ago could influence my sleep tonight.
I'll share any code I write on my github account and explain what I've tried here.