Pages

Monday, February 4, 2013

Sleep Record Stats: An analysis of sleep data from nearly three and a half years

Prior to starting high school in 2009, I for whatever reason had the idea to write down my waking and sleep times every day. So I did. And continued to do so for years, even now recording my nightly nappy times into the very same notebook. The result is that I have almost four years of sleep data. I realized well before my first year was up that I had a goldmine of interesting personal data to analyze and that I should type it up "sometime." Three years later, I finally did. I excitedly typed up over 1,200 days of information as I thought of all the cool things I could do with the data. I could analyze it statistically, I could organize it graphically, I could correlate it to other events attentively. Enough fantasizing; it's time to analyze.

Organization

I have been using the same format for recording the data since I've started. In a small notebook, I have two columns on a page with 24 lines. For each line in each column, before I go to bed, I record the date of the day I'm supposed to go to bed (so if I am up after midnight I still record the night's date and not the morning's) and the time I'm going to bed to the right of the date. If I do not fall asleep for a while, I sometimes update the sleep time and go back to bed. If I wake up in the middle of the night, I usually go back to bed without changing anything. If I do not sleep at all and opt instead to stay up all night, I write only the date and leave the sleeping and waking times blank. Rarely will I forget to record a time, but when I do, I usually write down the time I remember, often rounded to the half-hour mark. When I wake up (and plan on staying up) the next day, I record my waking time to the right of my sleeping time. Thus, the format is as follows:
7/10/09   10:55 PM   11:00 AM
This format was based on the understandings that a particular night's sleep is just that, a night's sleep and not a morning's sleep, and that it is expressed as a range of times from the time I fall asleep to the time I wake up. Thus I marked the ends of these ranges next to the date when that night's sleep was supposed to begin. Because I live in the U.S., I used the 12-hour clock instead of the 24-hour clock. This is a standard for readability. I copied this data from the notebook onto a spreadsheet, keeping the same format for individual entries.

Graphing

Now, these aspects of the formatting present problems in graphing as I saw when I began working with them. First of all, when graphing the times as is, it makes no sense that the waking data for a certain day is labeled as being on the previous day. For the purpose of such graphs, I have thus shifted the waking times by one day. Second of all, and more critically, the 12-hour clock cannot carry as much information as the 24-hour clock. The 12-hour clock expresses only one day. The 24-hour clock can go on indefinitely, such as by expressing tomorrow's noon as today's 36:00. This is very useful for the analyzing software to interpret the data. Otherwise the graph will look like this:
Graph of incorrectly parsed and misinterpreted data
I used good ol' free LibreOffice for creating the spreadsheet of data, charting the data, and producing images for the data. As is evident, this graph isn't very useful for anything other than the vague trend apparent on the orange graph. This is because it correctly graphs the times up to 11:59 PM before it begins to interpret AM times in the "Time Slept" column as times in the morning of the same day. I corrected this by replacing every AM time in the "Time Slept" column with its 24-hour counterpart.

I went through several revisions of the graphs before I got it right. The initial graphs revealed numerous absurd outliers that were sometimes quite impossible, such as waking up before I even fell asleep, implying negative sleep. This gave me a bit of unrest, so I fixed it. The most common cause of the problem was a confusion between AM and PM, revealing yet another flaw of the 12-hour system.

After cleaning up the charts, giving them proper labels and trimming the absurdities, I finally produced graphs useful for telling me the trends.

Interpreting Graphs

Below is the combined graph of sleeping and waking times throughout the whole interval, 7/10/09 to 12/7/12. Right-click and open in a new tab to view in full resolution.
Daily waking and sleeping times between 7/10/09 and 12/7/12
A number of observations are immediately apparent.
  1. The sleeping and waking times never intersect.
  2. The sleeping times (blue line) and the waking times (orange line) are correlated.
  3. The waking times vary more widely than the sleeping times.
  4. The most extreme variance occurs around June 2011.
  5. Both graphs rise and fall in a consistent pattern most of the time and rise relatively sharply starting from January 2012.
  6. There is a huge gap in May 2012.
  7. Both times appear erratic, particularly the waking times; the waking times do not maintain consistency within 2 hours for more than a month.
  8. In most cases, where there is a gap in one graph, there is an equivalent gap in the other.
The very first observation is a given for the reasons mentioned earlier. An intersection in the graphs would mean impossibilities like if I woke up before I fell asleep. The rest of the properties of the graph can be explained by details of my life.

First of all, the graphs rise and fall in correlation with school. During the summer, I can sleep and wake up later, which explains the initial state of the graph around 7/10/09. This however drops down when school starts. When school starts, the waking times become quite erratic. This is because the week consists of five school days and the two weekends. I must wake up early for the five school days to catch the 7:00 AM bus but that is not necessary for the two weekends. As a result, I stay up later Friday nights and consequently wake up later the following Saturday mornings. This continues for the entire school year, interrupted only by holidays.

The extended breaks are the most noticeable. During the winter break of 9th grade, I woke up every day around the same time I wake up on weekends. This is apparent by the raised portion of the graph to the left of the 1/10/10 mark. Winter break usually ends after the first week of January. This happens similarly with spring break and summer.

The summer is a bit different though. Because summer is the longest school break, I have enough time to stabilize in preparation for the next school year, hence the downward slope during the summer of 2010. The relatively sharp rise of the graphs starting from January 2012 is in correlation with my transition from school attendance to online schooling. I no longer had to wake up early, so I did not have to prepare for a coming school year. I thus experienced the inverse of a normal summer; instead of stabilizing towards the waking time demanded of me by school, I stabilized in a previously unknown direction. That is, what my waking time equilibrium would be if I had no consistent daily obligations to wake up at a certain time.

Second of all, the graphs rise and fall in correlation with health and fitness. The thick-looking part of the graph around June 2011 also features unusually early wake up times, down to nearly 4:00 AM. This is due to an outdoor workout schedule which ran between June and October. Because it was summer, and because it was Arizona, outdoor workouts were unfeasible after a certain time. Thus, I worked out before sunrise. This explains the early wake up times.

However, the early times are frequent but not consistent; it appears as though I alternated between waking up at dawn and noon. This can be explained by two things. First, the workouts were not a daily occurrence; they were done two or three times a week. Second, the sleeping time graph on average does not consistently dip any lower than it did before to compensate for the extra early wake up times. This means I would be tired after waking up early and sleeping late, and as a result I would wake up later the following day.

Then there's health which accounts for the gap in May 2012. I fractured both my wrists in a parkour injury on the second of May of that year. Consequently, I was rendered incapable of writing for some weeks before most of the pain went away and I learned to write with my forearm cast on. There's a brief time evident in the gap area in which I did record my times, but I must have decided to stop and wait for better handwriting.

There are then two more isolated sections evident after that before the graph returns to normal. That is the time I briefly experienced bouts of insomnia and skipped sleep nearly every other day. There are single day points of data that are not shown on this graph at that time, but can be seen in close-up graphs.

Close-up Graphs

Set 1 [7/10/09 - 1/9/10]
Set 2 [1/10/10 - 7/9/09]
Set 3 [7/10/10 - 1/9/11]
Set 4 [1/10/11 - 7/9/10]
Set 5 [7/10/11 - 1/9/12]
Set 6 [1/10/12 - 7/9/12]
Set 7 [7/10/12 - 12/7/12]
More trends become visible in the close-up graphs. The broken wrists explain the big gap in Set 6, but the smaller gaps cause confusion. Some of the little gaps can be explained by forgetfulness after not having recorded my sleep times for a while. The rest can be explained by missed sleep; I had frequent sleepless nights while in casts.

These smaller, more detailed graph sets make sick days apparent. Some colds rendered me temporarily bedridden, resulting in a series of naps running day and night instead of a simple daily sleeping and waking time. The most common time of the year for such illnesses was around early October, which is indeed apparent by short 2-3 day gaps in Set 1 near 10/09/09 and in Set 3 near 9/25/10.
Observations made in the main graph become more apparent in the close-up graphs. The five low, two high trend for school weeks is clearly present. More details can be seen, such as minor extended weekends (Thanksgiving weekend such as in Set 1 near 11/27/09) and extended breaks (winter break such as in Set 1 near 12/25/09). Interestingly, the pattern in sleeping times appear to be a scaled down version of the pattern in waking times. That is, on school weeks, it is low for most of the week, then raises temporarily for two days. This is most apparent for the first quarter of my freshman year of high school, which is the eight weeks between 8/14/09 and 10/09/09.

Graphs of Duration

Merely analyzing the graphs of the sleeping and waking times themselves provide a nice introduction, but leaves out a lot useful information. Neglected is the lengths of time periods delineated by those sleeping and waking times. That is, the duration of a night's sleep (nightly rest) from the time I go to sleep to the time I wake up the next day, and the duration of my day spent awake (waking day) from the time I wake up to the time I go to sleep in what should be the same day.

Length of nightly rest and waking day between 7/10/09 and 12/7/12
This graph illustrates these variables, which are also affected by school and play a role in productivity. The orange graph represents the length of the waking day, and predictably enough it exhibits an upside-down version of the school week pattern found on the main graph. This time, it is high for five days and low for two. This is because, recalling that the sleeping times were shrunken versions of the waking times and were therefore more narrow and fairly static, the length of the day was longer on school days when I had to wake up early. I still went to bed around the same time as on weekends. Thus, the determining factor in the length of the day was the waking time.

Interestingly, but predictably, the graph appears to be more or less reflected across the twelve hour mark (12:00 PM). This is because there are 24 hours in a day, and the sum of the nightly rest and the waking day must total the length of a day, or if it does not, and instead passes margin to the next day, the next day must make up for it or pass it on again. This is the usual case. One example of this would be if I was awake for 16 hours and slept for 9 hours, a pairing that does not equal 24 hours.

Based on the graph, it would appear the shortest nightly rest was a little less than two hours, while the longest waking day lasted close to 22 hours. Because this data depends on both the sleeping and the waking times, it excludes anomalies like skipped sleep and partial data for a given day. Therefore, 22 hours is the length of the longest "regular" day.

I find it interesting to know these odd facts about my sleep. To search for more, I must delve deeper into the use of statistics.

Statistics

Here are the statistics:
  • Sleeping Time
    • Latest: 6:00:00 AM the next day (30:00:00)
    • Earliest: 5:40:00 PM
    • Mean Average: 11:36:48 PM
      • Standard Deviation: 1:31:26 hours
    • Median: 11:21:30 PM
    • Mode: 12:00:00 AM the next day (24:00:00)
  • Waking Time
    • Latest: 4:16:00 AM
    • Earliest: 1:30:00 AM
    • Mean Average: 8:09:07 AM
      • Standard Deviation: 2:22:55 hours
    • Median: 7:54:00 AM
    • Mode: 6:30:00 AM
  •  Nightly Rest
    • Longest: 16:04:00 hours
    • Shortest: 1:40:00 hours
    • Mean Average: 8:31:39 hours
      • Standard Deviation: 1:58:28 hours
    • Median: 8:21:00 hours
    • Mode: 7:10:00 hours
  • Waking Day
    • Longest: 22:00:00 hours
    • Shortest: 8:48:00 hours
    • Mean Average: 15:30:27 hours
      • Standard Deviation: 2:03:42 hours
    • Median: 15:45:00 hours
    • Mode: 16:01:00 hours

Statistical Graphs

Patterns of fluctuation and reflection become much more clear when the seemingly random variance is neutralized by constant averaging. I calculated for each day after the first week the average of the times for the last seven days, including that day. Thus, each day after the first week has a "weekly average" value based on the times for the past week. The weekly averages for sleeping and waking times are graphed on top of the sleeping and waking times themselves in order to provide a juxtaposition of both the weekly averages to each other and the weekly averages to their respective original graphs.

Daily and average weekly waking and sleeping times between 7/10/09 and 12/7/12
Nothing is really new here other than that the parallel between the graphs is now obvious, most significantly in the rising slope in the second half of the graph and the notable minor events like the two spikes in both graphs from 7/10/10 to 9/10/10 and around 1/10/11. Similarly, the pattern in the nightly rest and waking day graph is emphasized by examining the weekly averages.

Daily and average weekly length of nightly rest and waking day between 7/10/09 and 12/7/12
The reflective pattern becomes more noticeable, especially in the first half of the graph, where the spikes in lengths of nightly rests between 9/10/09 to 7/10/10 are mirrored as dips in lengths of the waking days. Once again, it provides little to no more than a reinforcement of what was suspected in the original graph.

Conclusion

This data is not sufficiently reliable for most scientific standards, lacking controls in what I might consider a "waking time" and a "sleeping time," in what I do if I have forgotten to record my time, and the procedure for handling sleepless nights. It is generally accurate, but by no means consistently precise enough to treat it as precise. Nevertheless, it provides a fascinating look into the relationship between sleeping times, waking times, length of waking days, length of nightly rests, school, health, days of the week, seasons, holidays, and other factors.

I plan to follow this up at the four year mark, 7/10/13, so I may have four-year graph with eight sets of six month graphs instead of a strangely cut off three and a half year period with seven sets. At the four-year mark, I will produce more graphs, make a more thorough analysis, and use more complex methods of statistically analyzing data, such modes of ranges and histograms.

No comments:

Post a Comment