I have historical data for my own calorie intake and weight over the past few years. I'd like to calculate my TDEE from this data. Can anyone point me towards an appropriate mathematical model? Googling around I've found some papers (like this) that predict future weight gain as a function of an increase in calorie intake, but I am not sure that is quite what I want -- I plan to continue measuring my weight and calorie intakes going forward, so I'm not interested in trying to project a long way into the future.
I am aware of this TDEE calculator that does something similar, but I'd like to get a better understanding of the math from first principles.