Asking for a friend, who has read this.

Basically my friend weighs daily and has historical data in CSV format. They would like to take that data and overlay it in some form of weekly chart. E.g shows only Monday to Sunday (start day preferably selectable), not several months or years.

We are unsure what format the display should take, but the objective is to see if there is a pattern to weight loss/gain on certain days of the week (e.g, every Tuesday).

My friend has been steadily losing weight for months now, but against that background, there are days when weight is gained and my friend is looking for an identifiable pattern. A very obvious example would be weight gain on Monday after a weekend binge, but this is not the case, just an example. The idea is that if certain weekdays can be identified as problematic then the cause can be identified and behavio(u)r changed.

I could probably manage to create an Excel chart from the data, but how to identify any patterns, probably based on day of the week?

  • 1
    $\begingroup$ When you say 'certain days can be identified' do you mean that Mondays in general are different or do you mean something specific like Monday 1 October 2018 was different? $\endgroup$ – mdewey Oct 18 '18 at 14:22
  • $\begingroup$ Actually, every Tuesday seems to show a difference (we think, from looking at the data). Sorry If that was not clear; I will update the question $\endgroup$ – Mawg says reinstate Monica Oct 19 '18 at 6:21
  • 1
    $\begingroup$ This looks like a case for time series analysis, although... how much data do you have? How long? Are you interested in whether the weight changes through time or are you interested in changes in weight throughout the week? $\endgroup$ – user2974951 Oct 19 '18 at 7:22
  • $\begingroup$ Only 3 or 4 months data. The weight odes change through time; there is a steady trend of loss. The idea is to find if that trend generally reverses on any given day or days of the week. $\endgroup$ – Mawg says reinstate Monica Oct 19 '18 at 8:09

Using differences between succeeding days (more susceptible to noise)

Compute for every week $i$ the seven values $$\begin{array}{rcl} d_{1i} &=& weight_{Monday}-weight_{Sunday} \\ d_{2i} &=& weight_{Tuesday}-weight_{Monday} \\ d_{3i} &=& weight_{Wednesday}-weight_{Tuesday} \\ d_{4i} &=& weight_{Thursday}-weight_{Wednesday} \\ d_{5i} &=& weight_{Friday}-weight_{Thursday} \\ d_{6i} &=& weight_{Saturday}-weight_{Friday} \\ d_{7i} &=& weight_{Sunday}-weight_{Saturday} \end{array}$$

giving you for $n$ weeks 7x$n$ values.

(note the expressions such as $weight_{Monday}-weight_{Sunday}$ must be like the Sunday as in the day before Monday and not six days after Monday. You could avoid this ambiguity by adding subscripts for the week number but I wanted to avoid this clutter, and also this would require defining which day is the beginning of the week).

You can plot these values $d_{ji}$ as a function of the day of the week $i$. This scatter-plot can be made as well with descriptive statistics such as a box-plot or just the computed mean value with an expression of the error of the mean.

If this approach does not give you satisfying results (e.g. the variance is too large to see clear differences between weekdays) then you might try more advanced models. For instance possibly the weight loss may vary from week to week and you could separate this variance (different ways to do this) such that the differences between the weekdays becomes more clear.

Using differences from a trendline (better with relation to noise)

Personally I would end up using some model for the overall trend, some function of time $f(t)$ (a linear function would be most easy, in the article that you mention it is a moving average), and then add specific (systematic) "error"/effect terms for the weekdays $g(weekday)$ in addition to the random error $\epsilon$. For example:

$$weight(t) = f(t) + g(weekday) + \epsilon $$

In this case you will plot the residuals (the difference of the measurement with the trend line), as a function of weekday. I feel that this is a better way than looking at daily differences since taking differences will emphasize the noise.


For this example I needed a dataset of day-to-day body weight measurements. I took the data from https://medium.com/technology-liberal-arts/the-data-diet-how-i-lost-60-pounds-using-a-google-docs-spreadsheet-80adce62cf5c which links to a google-docs measurement where I saved the yearly measurements columns as a csv.

Then using the R-code below (you can just as well do this in Excel, but it will be a bit more laborious) you will get the image below

# get data and packages
data <- read.csv("~/Desktop/weight data.csv", header=TRUE)

# data for analysis
w <- data$X2011[-60]
t <- 1:365
t2 <- t^2
d <- 1+(t+4)%%7 # monday = 1  .... jan 1 2011 starts is a saturday = 6

# plotting the entire year and models
plot(t,w, xlab = "time [day of year 2011]", ylab = "weight [pounds]")
title("plot of data and trend for entire year 2011")

# linear model
mod <- lm(w~1+t+t2)

# moving average
psg <- sgolayfilt(w, p=1, n=7)

# plotting the weekdays

      # boxplot(residuals(mod) ~ d)   
      # this quadratic model is not so good 
      # (large variance in weekdays due to temporal variations with period larger than a week)

dt <- as.factor(d)
levels(dt) <- c("Monday","Tuesday","Wednesday","Thursday","Friday","Saturday","Sunday")

boxplot(w-psg ~ dt, outline = FALSE, ylim = c(-4,4), ylab = "weight difference from trend [pounds]" )
points(jitter(d,0.5) ,w-psg , pch = 21, cex = 0.7, bg = "white", col = "black" )
title ("plot of variation from trend as function of weekday")

# you could do some analysis of significance for the weekday factor  
mod2 <- lm(w-psg ~ 0 + dt)

# this is what you would get when you use the differential between succeeding days
dw <- w[-1]-w[-365]
dd <- d[-1]


Off-topic note about the interpretation

The idea is that if certain weekdays can be identified as problematic then the cause can be identified and behavio(u)r changed.

This may be problematic, and at least very tricky/difficult, as variations in weight may not need to be associated with variations in fat (which is, I imagine, the main target) and could be weight losses due to intestinal content, salt and water, muscle glycogen and water.

For instance, if your friend makes a long distance run (>2hrs) he will lose a lot of muscle glycogen and associated water (will be about 2kg) and the next day this will be higher again. That does not make this next day a bad day.

If your friend has a day of eating only bananas or only juice (what those trendy diets advocate) then he will lose a lot of sodium salts and associated water that is being held by the salt, as well (in the case of the juices) a lot of dietary fiber in the intestines. This will record as a day with a lot of weight loss, but it is not a good kind of weight loss.

If your friend has particular days of eating a lot of vegetables (which is good because of low energy and high nutritional value), then those days will actually relate to an increase of weight. That is because vegetables contain a lot of dietary fiber and will make the intestinal content more heavy.

  • 2
    $\begingroup$ (+1) especially for the so-called off-topic bit about interpreting what the results actually mean. $\endgroup$ – mdewey Oct 26 '18 at 13:32
  • 1
    $\begingroup$ Wow! This is a vefy impressive answer! $\endgroup$ – Mawg says reinstate Monica Oct 27 '18 at 8:02

I would plot this with the $x$-axis showing the days of the week and plot a separate line for each week with weight on the $y$-axis. I might also compute the mean for Mondays, Tuesday, and so on and plot that as well with a contrasting symbol. If I was interested in finding days which stood out from the trend I would subtract the mean for Monday from each Monday and so on and plot those differences.

There are also lots of analyses you could do but (a) you asked for display ideas, (b) a picture is worth a thousand words. Even if I was going to wheel up the statistical heavy artillery I would plot the data first.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.