How I Generated the Models and Charts for My Activity/Sleep/Writing Correlations

In case anyone was curious about how I generated the models and charts in the previous post, I used Mathematica. It took only a few lines of code to calculate the models and generate the charts. Here is the code I used:

data = Import["C:/Users/rubin/Downloads/WritingWalking.xlsx"][[1]];
data2 = Import["C:/Users/rubin/Downloads/WritingWalking.xlsx"][[3]];
data3 = Import["C:/Users/rubin/Downloads/WritingWalking.xlsx"][[4]];
sleepdata =
Import["C:/Users/rubin/Downloads/WritingWalking.xlsx"][[5]];

lm = LinearModelFit[data, x, x];
lm2 = LinearModelFit[data2, x, x];
lm3 = LinearModelFit[data3, x, x];
lmsleep = LinearModelFit[sleepdata, x, x];

Show[ListPlot[data], Plot[lm[x], {x, 0, 2500}],
AxesLabel -> {"Words", "Steps"}]
Show[ListPlot[data2], Plot[lm2[x], {x, 0, 2500}],
AxesLabel -> {"Words", "Steps"}]
Show[ListPlot[data3], Plot[lm3[x], {x, 0, 800}],
AxesLabel -> {"Words", "Steps"}]
Show[ListPlot[sleepdata], Plot[lmsleep[x], {x, 0, 2000}],
AxesLabel -> {"Minutes", "Words"}]

That’s it. The data itself comes from two sources:

  1. Step and sleep data come from my FitBit device. I exported the data for the 300 days in question to an Excel spreadsheet.
  2. Word count data come from my Google Writing Tracker scripts.

Comments

This site uses Akismet to reduce spam. Learn how your comment data is processed.