The MacroFactor expenditure algorithm V3 is here, and we’re excited for you to try it out.
The expenditure algorithm is at the heart of the MacroFactor coaching system. It’s what allows the app to adjust your weekly Calorie and macronutrient targets to keep you on track toward your goals. Its power comes from the fact that it relies on solid physiological principles to be inherently self-correcting, unlike energy expenditure estimates coming from static calculations or wearable devices. If you eat 2500 Calories per day and maintain your weight, that means you burn around 2500 Calories per day. If you gain weight while eating 2500 Calories per day, that means you burn less than 2500 Calories; if you lose weight, that means you burn more than 2500 Calories. And, if you lose weight slowly, that means you only burn slightly more than 2500 Calories; whereas if you lose weight very rapidly, that means you burn way more than 2500 Calories.
This is a simple concept that’s easy to grasp, but it gets a lot messier when you actually need to analyze data and estimate the energy expenditure of a given individual, based on their weight and nutrition information.
Signal and noise – stability and responsiveness
The main problem is that nutrition and especially weight data are noisy. In other words, they contain trends that can be used to accurately estimate your energy expenditure, but they also contain a lot of messiness that conceals those trends.
A basic principle of trend analysis is that you can’t simultaneously maximize both stability and responsiveness. If you zoom way out, you can generate very stable predictions about the previous behavior of the noisy system. For example, if MacroFactor used an entire year of back-looking weight and nutrition data to estimate your expenditure, each new day of data would have relatively little impact on the analysis, resulting in an expenditure calculation that didn’t change much, thus providing very stable nutrition recommendations week to week. However, if your expenditure did change considerably – if you started a new weight loss goal, if you switched from losing weight to intentionally bulking, or if your exercise and activity levels experienced a large shift – the app would be far too slow to adapt appropriately.
On the flip side, analyzing just one week of data would result in a very choppy experience due to the noisiness of the underlying data. For example, you might maintain a consistent lifestyle and eat 2500 Calories per day in back-to-back weeks, but in one week, you randomly gain two pounds, and in the next week, you lose those two pounds again. If you treated those two weeks as self-contained units, a naive analysis of your weight and nutrition data would suggest that you were burning about 1500 Calories per day in the first week, and about 3500 Calories per day in the second week. Clearly that’s absurd. But, if your actual energy expenditure did change rapidly, this weekly analysis would adapt far more quickly than a yearly analysis.
So, that’s the basic push and pull. I’m sure you don’t want your calorie targets increasing or decreasing by 500+ calories every week, but you also don’t want the app to take six months to adapt to a change in your diet or activity levels. However, analytical approaches that increase stability tend to decrease responsiveness, and analytical approaches that increase responsiveness tend to decrease stability. So, major algorithmic improvements – improvements that enhance stability without compromising responsiveness (like the jump from V1 and V2), that enhance responsiveness without compromising stability, or that simultaneously improve both responsiveness and stability – are surprisingly difficult.
The first breakthrough: mitigating false signals
A challenge when dealing with weight data is that forward-looking predictions and back-looking calculations are often at odds.
Here’s what I mean:
If I told you that someone was previously weight-stable, and they started losing two pounds per week, would you predict that:
- Their energy expenditure will decrease
- Their energy expenditure won’t change
- Their energy expenditure will increase
You’d probably choose A: their energy expenditure will decrease. It’s well-understood that energy expenditure tends to decrease during weight loss, due to metabolic adaptations, decreases in non-exercise physical activity, and the simple fact that you’re now fueling a smaller body.
However, what if I told you instead that someone was previously weight-stable, they decreased their energy intake by just 250 Calories per day, and they started losing two pounds per week?
That would imply that their energy expenditure was increasing. Losing two pounds per week requires a pretty large energy deficit – certainly much more than 250 Calories per day. So, their rate of weight loss, in combination with their nutrition data, would suggest that their energy expenditure was rising, rather than falling.
In a vacuum, you’d expect energy expenditure to increase with weight gain and decrease with weight loss, and you’d expect more rapid rates of weight gain to result in more rapid increases in energy expenditure, and more rapid rates of weight weight loss to result in more rapid decreases in energy expenditure. However, at any given level of energy intake, faster rates of weight gain imply lower total energy expenditures, and faster rates of weight loss imply higher total energy expenditures.
Changes in energy expenditure as a result of weight change: predictions based on weight alone vs. implications when combined with nutrition data | ||
Predictions based solely on weight change | Implications at a given level of energy intake | |
Weight gain | Predicted Increase | Implied Decrease |
Weight loss | Predicted Decrease | Implied Increase |
Faster rates of weight gain | Faster Increase Predicted | Larger Decrease Implied |
Faster rates of weight loss | Faster Decrease Predicted | Larger Increase Implied |
The time when this tension is felt most acutely is when starting a new weight gain or weight loss phase. When you shift from losing weight to gaining weight, it’s not uncommon to gain 5+ pounds basically overnight. It’s not “real” weight gain – your body is just storing more glycogen (and associated water), and you have an increased amount of food (and associated water) in your digestive tract. The opposite occurs when you shift from gaining to losing weight – you might lose 5+ pounds within the first week or two, but again, that’s not 5 pounds of “real” weight loss (i.e. your body isn’t metabolizing 5 pounds of stored body fat) – it’s mostly water weight.
So, in these scenarios, your actual energy expenditure is likely to move in concert with your weight – increasing as you gain weight, and decreasing as you lose weight. But, when these large shifts in weight are analyzed in the context of more modest increases or decreases in energy intake, that would (erroneously) lead you to conclude that people initially experience a large decrease in energy expenditure when they start gaining weight, and a large increase in energy expenditure when they start losing weight.
This is a challenge we’re well-aware of, and V2 of the expenditure algorithm used some clever tricks to mitigate the counterintuitive and frustrating impact of these large, short-term weight shifts on users’ calculated expenditure. But, we knew this was an area where we had room for improvement, and it seemed like an instance where we might be able to “beat” the typical stability versus responsiveness tradeoff, since we understood the exact way and the typical degree to which naive calculations would depart from physiological reality.
Ultimately, this is where the breakthrough originated. To avoid giving away our “secret sauce,” I don’t think I should divulge any more details, because they would necessarily hint at some of the novel techniques we developed. But, we soon realized that our solution to this limited problem generalized to other common and frustrating scenarios that dieters and athletes often face. From there, we found that these new techniques also performed better than expenditure V2 on synthetic datasets and our own data exports, and we finally realized we were dealing with a pretty significant leap forward. The techniques we developed allow V3 of the expenditure algorithm to be slightly more responsive than V2 (picking up on upward or downward trends that prove to be real and durable 1-5 days sooner than V2), while also being considerably more stable: day-to-day expenditure updates are generally about 35% smaller.
To illustrate, here’s about 2 years of my expenditure data with both the V2 and V3 algorithms.
Early on, my expenditure decreased quite a bit as I lost about 50 pounds. As you can see, both V2 and V3 picked up on the same long-term trend, but V3 did so with fewer and smaller bumps and detours along the way. V3 also wasn’t was impacted by this early weight loss plateau and subsequent “whoosh” of water weight:
Then, for about a year, I maintained my weight and maintained a pretty consistent lifestyle. V2 doesn’t do a bad job of reflecting this fact – it never deviated by more than about 8-10% above or below the long-term trend. But, V3 did a better job of maintaining a more stable calculated expenditure during this period when, in hindsight, I know my energy expenditure was actually very stable. As you can see, the peaks aren’t as high and the valleys aren’t as low with V3.
Finally, any time there were significant trend reversals, V3 picked up on them about three days sooner than V2.
Overall, the situations where V2 and V3 differ the most are situations where short-term weight fluctuations would lead to inferences about expenditure changes that differ from more reliable trends. So, the following scenarios will have a smaller impact on your estimated expenditure with V3 of the expenditure algorithm:
- Momentary fluid retention from a carb- and salt-rich meal
- An increase in fluid retention from starting creatine supplementation
- Momentary fluid retention associated with ovulation or menses
- Momentary fluid losses from reducing carb intake
- Getting a big water weight “whoosh” after a weight stall
- Shedding water weight that was previously retained during ovulation or menses
The second breakthrough: handling missing data
After recognizing that we were dealing with an entirely new version of the expenditure algorithm, the boring work began. Eureka moments are exciting, but they’re followed by months of fine-tuning, prodding at edge cases, and meticulously testing the limits of data quality and completeness the algorithm can handle before it starts behaving in non-ideal ways.
But, during this process, we happened to stumble across an unforeseen benefit of one of the analytical techniques we developed for V3 of the expenditure algorithm: with a small tweak, it could be adapted to allow the algorithm to be far more tolerant of missing data.
When doing robustness testing on V2 of the expenditure algorithm, we found that we needed about 80-85% nutrition data completeness for the algorithm to still perform well and produce accurate updates. If the algorithm continued trying to update with more than one day of missing nutrition data per week, its performance would start dropping rapidly. So, with two or more days of missing nutrition data per seven-day period, we found it was simply better to pause updates until data completeness returned to an acceptable level (i.e., until the most recent seven-day period included at least six days of nutrition data).
However, V3 can still perform admirably with about three times as much missing data. Below, you can see the result of using a random number generator to delete half of my nutrition data at random (basically just a fancy automated coinflip, where I keep a day of nutrition data if it lands on heads, and delete it if it lands on tails). I performed the procedure 10 times, and you can see how my expenditure calculation would look each time, compared to my “real” calculation with 100% nutrition data completeness.
As you can see, it still does quite well. With half of my nutrition data missing, the algorithm may be slightly more conservative with adjustments during periods when my expenditure was increasing or decreasing fairly quickly, but it never deviated too far from the “real” calculation, and it never behaved erratically by increasing or decreasing way more than it “should” have. And keep in mind, with this “coinflip” approach to deleting data, there would be instances where the “coin” landed on “tails” for 5+ days in a row, so there are plenty of weeks with two or fewer days of nutrition data in these simulations.
Now, to be clear, I ran this test using the “raw” version of the algorithm with no guardrails whatsoever. In practice, we found that pausing updates could still be helpful in certain contexts. But, with expenditure V3, updates will only pause if you have more than three days of missing nutrition data in a seven-day period.
Though V3 of the expenditure algorithm is more tolerant of missing data, we do still generally recommend trying to log or estimate your intake whenever possible. But, V3 of the expenditure algorithm is able to handle missing data better because it can make reasonably accurate inferences about your energy intake on days you don’t log. We can compare its behind-the-scenes calorie predictions (how much it would estimate people ate if they didn’t log their food for the day) against people’s actual intake on the days they did log, and we find that its energy intake estimates are generally within about 15-20% of the actual values (which is why expenditure V3 can still provide accurate expenditure updates with significant amounts of missing nutrition data).
So, if there are some occasional days where you currently log your food but you really would prefer not to – when you’re on vacation, on holidays, when you plan to have a big night out with friends, etc. – V3 of the expenditure algorithm will better accommodate you. It’ll know if you ate a bit more or a bit less than normal, and it’ll have a pretty good idea of how much more or less than normal you ate on days you don’t log. This allows MacroFactor to more accurately calculate your expenditure, and pause your expenditure updates less frequently during periods when you don’t log your food every day. Though, you do still need to be mindful to avoid partial logging.
Your estimated expenditure will probably be a bit lower (and that’s a good thing)
We caught and corrected a small bug that was present in previous versions of the expenditure algorithm.
To explain how it got there, I first need to explain a little bit about the energy surpluses and deficits required to gain or lose weight.
You may have heard of the “3500 Calorie rule” – the idea that a total deficit of 3500 Calories is required to lose 1 pound, and a total surplus of 3500 Calories is required to gain one pound.
The 3500 Calorie rule is a decent general heuristic, but it’s not strictly true in all cases. Fat has an energy density of about 39.5MJ/kg (or about 4282 Calories per pound), and lean tissue has an energy density of about 7.6MJ/kg (or about 824 Calories per pound). So, the “3500 Calorie rule” tacitly assumes that, when you gain or lose weight, about 78% of the weight you gain or lose is fat tissue, and about 22% of the weight you gain or lose is lean tissue.
Those aren’t bad assumptions in many situations, but there are also situations where they can deviate from reality. For example, if you start lifting weights and gain a pound of muscle without gaining any fat, gaining that pound only required a total energy surplus of about 824 Calories, not 3500. You could even gain two pounds of muscle, lose a pound of fat, and wind up gaining a pound of body weight while being in a net energy deficit of 2643 Calories.
So, we tried to apply that information to be a bit clever. Most people who use MacroFactor with a weight gain goal are actively exercising, and exercising has a dramatic impact on the composition of the weight you gain. At most reasonable rates of weight gain, instead of predominantly gaining fat as you gain weight, you predominantly gain muscle as you gain weight. So, that was baked into the assumptions of V1 and V2 of our algorithms: the surplus implied by gaining X pounds per week was smaller than the deficit implied by losing X pounds per week.
However, we realized that this set of assumptions – while technically correct in a vacuum – could have some unintended consequences. Namely, it led to small but consistent overestimates in users’ calculated expenditures as a result of weight fluctuations. Just to illustrate, if your energy intake is stable and your weight is relatively stable, but you lose 0.5lbs in a week, that suggests that you may be burning a bit more energy than you’re consuming, so your estimated expenditure needs to increase a bit. If you regain that same 0.5lbs the next week, that suggests that you may be burning a bit less energy than you’re consuming, so your estimated expenditure needs to decrease a bit. But, if we assume that the energy expenditure implied by a given rate of weight loss is larger than the surplus implied by a given rate of weight gain, the estimated expenditure increase in week 1 would be a bit larger than the estimated expenditure decrease in week 2. Extrapolate that out over time, and you wind up with a slight upward bias.
I ran a quick simulation to illustrate this effect. In this simulation, the individual has a constant energy expenditure of 2500 Calories per day, they eat 2500 Calories per day, and they’re as weight-stable as anyone could ever hope to be: they weigh 200lbs, and experience totally normal, totally random weight fluctuations with a standard deviation of ±1 pound (in other words, their scale weight is between 199 and 201lbs about 2/3rds of the time, and between 198 and 202lbs about 95% of the time). Here are the results:
As you can see, assuming that the energy surplus implied by gaining weight at a given rate is smaller than the energy deficit implied by losing weight at the same rate (blue line) leads to a small but consistent overestimate of energy expenditure. The effect is small (about 80 Calories), but it’s persistent. However, assuming that the energy surplus implied by gaining weight is equivalent to the energy deficit implied by losing weight (red line) leads to an estimate of energy expenditure that never strays too far from the truth (2500 Calories per day).
With larger typical weight fluctuations, the resulting overestimate is larger, and with smaller weight fluctuations, the effect is smaller. Furthermore, if you’re consistently losing weight, the effect is smaller, and if you’re consistently gaining weight, the effect is larger.
So, we corrected this issue in V3 of the expenditure algorithm. As a result, most people will have an estimated energy expenditure that’s a bit lower with V3 than with V2.
Depending on the magnitude of your typical weight fluctuations, and whether you’re gaining, losing, or maintaining weight, the independent impact of this change should be around 0-130 Calories per day for most people. You personally might experience a larger decrease, or you might even experience an increase in your estimated expenditure when switching from V2 to V3, but any additional impact would be the result of smoothing out the larger periodic fluctuations present in V2. In my data above, my estimated expenditure with V3 is, on average, about 23 Calories lower than with V2. But, it was up to 215 Calories lower at one point, and up to 120 Calories higher at another point, since the periodic fluctuations are so much larger in V2 than V3.
These changes have additional upsides for people with weight gain goals
If you have a weight gain goal, you may be concerned that this change will lead to less accurate nutrition recommendations for bulking. In the previous section, I explained that gaining weight consisting primarily of muscle mass does require a smaller energy surplus than the energy deficit required to lose weight (primarily consisting of fat mass) at the same rate. But, the impact of this change fully washes out for you.
To illustrate, let’s assume that you’re gaining half a pound per week while consuming 3000 Calories per day, and you want to keep gaining half a pound per week.
If we assume that you’re gaining 100% muscle mass, that would imply that you’re in an energy surplus of just 59 Calories per day, and your energy expenditure is 2941 Calories per day. So, how much do you need to eat to keep gaining half a pound per week? 3000 Calories per day.
If we assume that the 3500 Calorie rule applies (in other words, tacitly assuming that you’re gaining predominantly fat), that would imply that you’re in an energy surplus of 250 Calories per day, and your energy expenditure is 2750 Calories per day. So, how much do you need to eat to keep gaining half a pound per week? You guessed it: 3000 Calories per day.
In other words, your estimated energy expenditure will be a bit lower, but the implied energy surplus required to keep gaining weight at your desired rate will also be higher, and those two changes will fully cancel each other out, resulting in the same Calorie recommendations for your desired rate of weight gain.
In fact, this change actually comes with even more upside for people who are using MacroFactor to gain weight. Previously, some users reported that MacroFactor seemed to be a bit too conservative with Calorie increases for people with weight gain goals. In hindsight, that should have been foreseeable – a slower rate of Calorie increases was an unintended consequence of assuming that gaining weight at X rate implied a smaller energy surplus than the energy deficit implied by losing weight at X rate.
To illustrate, let’s assume that someone currently has a calculated expenditure of 2500 Calories per day, they want to lose a pound per week, and a cumulative energy deficit of 3500 Calories is required to lose a pound. To lose a pound per week, they need to be in a daily deficit of 500 Calories, so we’d recommend that they aim to consume 2000 Calories per day. But, if they start eating 2000 Calories per day, and they only lose half a pound per week, that would imply that their energy expenditure has decreased, and may be closer to 2250 Calories per day. Since their data suggests there’s a fairly large gap (250 Calories) between the expenditure implied by their current energy intake and rate of weight loss (2250 Calories per day), and our previous estimate of their energy expenditure (2500 Calories per day), their calculated energy expenditure – and therefore their energy intake recommendations – will decrease fairly quickly.
Now, let’s assume that someone currently has a calculated expenditure of 2500 Calories per day, they want to gain a pound per week, and a cumulative energy surplus of just 2000 Calories is required to gain a pound. To gain a pound per week, they need to be in a daily surplus of 286 Calories, so we’d recommend that they aim to consume 2786 Calories per day. But, if they start eating 2786 Calories per day, and they only gain half a pound per week, that would imply that their energy expenditure has increased, and may be closer to 2643 Calories per day. Since their data suggests there’s a smaller gap (143 Calories) between the expenditure implied by their current energy intake and rate of weight gain (2643 Calories per day), and our previous estimate of their energy expenditure (2500 Calories per day), their calculated energy expenditure – and therefore their energy intake recommendations – will increase at a slower rate than the rate at which energy intake recommendations would decrease in the weight loss example above.
But, if we change one assumption – gaining a pound requires an energy surplus of 3500 Calories, rather than 2000 Calories – that difference goes away. The rate at which energy intake recommendations will increase when people fall short of their desired rate of weight gain will be the same as the rate at which energy intake recommendations will decrease when people fall short of their desired rate of weight loss.
Just how well do MacroFactor’s algorithms work?
At the most basic level, MacroFactor’s algorithms work by making predictions, monitoring how well observed outcomes conform to those predictions, and then updating those predictions based on the observed differences between predictions and outcomes. To illustrate, if MacroFactor estimates that you have an energy expenditure of 2500 Calories per day, and you consistently eat 2000 Calories per day, it would predict that you’ll lose weight at a rate of about 1 pound per week. But, if it then observes that you’re actually losing weight at a rate of 1.2 pounds per week, that would imply that its prior prediction was a slight underestimate, and your energy expenditure is likely greater than 2500 Calories per day, so your estimated energy expenditure will increase.
To judge how well MacroFactor’s algorithms work, we can retroactively compare its predictions to subsequent outcomes. Just to provide an example, in June of 2021, I consumed an average of 2960 Calories per day, and MacroFactor estimated that my energy expenditure was about 3380 Calories per day. At that level of energy intake, MacroFactor would predict that I should lose about 3.6 pounds that month, given its estimate of my energy expenditure. In fact, I lost about 3.4 pounds that month. Since MacroFactor’s predictions were quite accurate, my estimated energy expenditure didn’t change very much. But, if I would have lost 7 pounds, my estimated expenditure would have increased by quite a bit, and if I only lost 1 pound, my estimated expenditure would have decreased by quite a bit.
There are various ways you could analyze and quantify the accuracy of MacroFactor’s predictions (and by extension, the accuracy of its nutrition recommendations): Do you look at a week of data? A month of data? Do you look at average error? Root mean square error? Mean absolute percentage error? Correlation coefficients? We look at all of those things, and this section almost turned into a litany of numbers that some people wouldn’t understand, and even fewer people would care about. But, as the old saying goes: a picture is worth a thousand words (and maybe a thousand numbers). So, here it is: this is my actual weight data from the past 3 years, overlaid with how MacroFactor’s V3 expenditure algorithm predicted that my weight would change on a rolling weekly basis, given its estimates of my energy expenditure, and my actual energy intake. I think it speaks for itself.
Based on our testing, not only is the V3 expenditure algorithm both more responsive and more stable than V2 – it’s also about 10% more accurate. The absolute errors in its predicted rates of weight change are about 15% smaller on a weekly basis, and about 5% smaller on a monthly basis.
What’s next?
One final benefit of the V3 algorithm is that it’s structurally and functionally more modular and robust (both theoretically and practically) than V1 or V2 were. This means that it will be generally easier to modify and improve, and it means that it will more easily accommodate additional inputs without deviating from the core DNA that has defined all versions of MacroFactor’s expenditure calculation and coaching functionality. So, V3 is not only a big leap forward right now – it also gives us a stronger foundation to continue building and improving upon, which should accelerate the rate at which we’re able to innovate and make further progress in this domain.
Looking back, V1 of the expenditure algorithm is still better than anything we’ve seen from other apps in this space, and V2 was a sizable improvement over V1. With V3, we’re taking another big step forward, providing an even more accurate and more stable expenditure calculation to form the bedrock of MacroFactor’s one-of-a-kind coaching experience.