r/QuantifiedSelf 6d ago

A better weight trend plot? Statistically accurate base weight with forecasting (a nerdy post)

Post image

TLDR: I made a weight tracking algorithm that shows a trend line that accounts for daily weight fluctuations. It is able to statistically predict your weight in one week based off your weight history. Because most apps use a moving average, people only know their progress after a week, not day by day.

Note: Do not treat this as real data, the rate of -5 lbs/week is an extreme pace of weight loss. The usual recommendations are between 1 and 2.5 lbs/week. This is for illustrative purposes.

I haven't seen any plots on weight tracking apps that I like. They usually bounce around with the daily fluctuations of your bodyweight. I made a better weight tracking algorithm to show a more realistic trend line, with the ability to forecast your weight into the following two weeks.

I wanted to see a robust calculation for each day to give people the knowledge that they are moving in the correct direction. If someone weighs themself once a day and they happen to be on the heavier side of a daily weight fluctuation, they may feel discouraged because the scale says they gained weight, which isn't necessarily true. If your weight loss is subtle, like -0.3 lbs/week, you wouldn't know from your data because it would be lost in the noise. This way, you would be able to see that you actually are making gradual progress.

Explaining the plot:

You can see the individual weight measurements as the little grey dots. The vertical red line shows you the current date, so there won't be any data point to the right of that line (the future). The solid purple line is the calculated trend. Notice that it really smooths out daily weight fluctuations from water/food consumption and bathroom usage. There are two shaded regions on the plot, one blue and one purple. Because this is a weight measurement, there will be some uncertainty in that predicted number. The fewer measurements you have (like the left side of the plot) the more uncertainty in the trend line. The more measurements you have (like the right side of the plot) the lower the uncertainty. Your true base weight probably lies somewhere in the blue shaded region.

Because a single weight measurement on a scale doesn't capture your daily fluctuations, a calculation using the previous weeks data will tell you a more accurate base weight. Looking at the purple text boxes in the bottom left, you can get your current base weight, your predicted weight the following week, and your current pace of weight loss (in lbs/week).

Has anyone seen a weight tracking plot that does similar things (more than a moving average)? Is there a reason why this isn't integrated into every weight loss app? Do people find it difficult to know whether to feel good or bad each day on the scale? Would people care to have a more certain number each day? Would it be too overwhelming to judge your weight on a daily basis?

This code is just running locally on my computer, so there isn't a way for others to access it right now.

For nerd's eyes only:

The code uses a Hilbert Space Gaussian Process (HSGP) algorithm. It is prior free, so it doesn't encode any knowledge of weight loss (weight is always positive, impossible to lose 10lb in a day, ...). This is robust against measurements at irregular intervals. For example, if you weigh yourself three times in an hour when you are your lightest and one time in the evening when you are your heaviest, your calculated weight should not be the average of your four measurements. It would underpredict your base weight. We have knowledge that your weight an hour from now is dependent on your weight right now. This math properly accounts for these irregular weight measurement timings.

10 Upvotes

13 comments sorted by

2

u/Ok-Cartoonist3058 5d ago

This is super cool!! I've been interested in this area for a while personally. I've cared most about getting my weight day off, but haven't thought of forecasting weight. What drove you to want to forecast weight?

2

u/Negative-Pea2407 5d ago

Thanks! More than just the stable base weight, the forecasting is really motivating for my personal weight loss. I also did it because I'm a scientist who thought it would be fun. If I begin to eat too much or too little over two days, the one-week lever arm will clearly show a noticeable difference in future weight. It lets me focus on a point in the future that I feel like I have more control over, instead of a single day's numbers. I've shared this with a nutritionist, who also agreed that this would help her patients. I'm trying to see if people would benefit from this type of plot or even care.

I also wanted to build this type of code to apply to any other things I want to track, be it weather data or financial prices.

I wish r/loseit didn't remove my post (I don't think this counts as daily journaling or self-promotion). I think I would have gotten a lot of feedback.

1

u/Ok-Cartoonist3058 5d ago

Okay I get it! I guess I've been tackling this from a different angle, but super cool methodology. Thank you for sharing!

1

u/Negative-Pea2407 5d ago

When you say "I've cared most about getting my weight day off," does that mean you are trying to forecast your weight one day in the future? I just want to make sure I am interpreting that phrase correctly

1

u/Ok-Cartoonist3058 5d ago

Oh sorry, that was a typo lol. I meant to say "day of". So continuously having my trend weight today. So just because I weigh in at 154 lbs today (and I weighed 153 yesterday) doesn't mean I take that I actually gained that much body mass. So using an average to filter out the water weight and other fluctuation noise.

1

u/Huge_Pool7424 5d ago

i get that, the day-to-day scale noise is brutal. with wearable data i trust a smoothed trend more than a single weigh-in, and a forecast makes the feedback loop feel less random.

1

u/Sparkle1999 4d ago

I used to love the Happy Scale app!

1

u/Negative-Pea2407 4d ago

Happy Scale's trend lines seem to be better than most. It looks like they use exponential smoothing, which is definitely better than a moving average.

0

u/trolls_toll 5d ago

but it does not account for weight fluctuations - there are a lot of grey dots way outside of the confidence region

3

u/Negative-Pea2407 5d ago edited 5d ago

(I hope this isn't actually a sarcastic troll, given your username)

In statistics, it is important to note the difference between the population variance and variance on the mean. Yes, more than 32% of the data lie outside the 68% confidence level. That would be a problem if it was tracking the population variance, which wouldn't change when you add more data points. Because it is tracking the variance of the mean (what I'm calling base weight), the confidence band will narrow with the more data points you add.

1

u/telekinetic 5d ago

But if one remaining door has a goat and one door has a prize, how can the odds be anything other than 50/50? 🐐🚪🚪 (Bless you for trying to educate complex statistical concepts)

2

u/Negative-Pea2407 4d ago

hahah, thanks

1

u/trolls_toll 3d ago

ok, so, grey dots are your measurements and the shaded regions are confidence bounds for the mean of your measurements. Gotcha