Take the 2-minute tour ×
Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. It's 100% free, no registration required.

I know how to calculate a line of best fit with a set of data.
I want to be able to exponentially weight the data that is more recent so that the more recent data has a greater effect on the line.

How can I do this?

share|improve this question
    
Now, if only you could be more precise on how you expect "exponential weighing" to be done to your data... –  J. M. Jul 30 '11 at 2:53

2 Answers 2

up vote 2 down vote accepted

Hmm, you make it much general, by just saying "exponential". So just a general answer:

Define $d_i=now-time_i$ the time-difference of the i'th data-point to "now". If $d_i$ can be zero, add one: $d_i=1 + now - time_i$

Then use the concept of "weighting" for each datapoint: assume a weight $w_i = \exp(1/d_i) $ which is handled as $w_i$'th multiplicity of that datapoint. Unweighted, each datapoint occurs in the correlation/regression formula with multiplicity $1$ and, for instance the number of cases N is just the sum $ N = \sum_{i=1}^n 1 $ . Weighting means here to replace N by W: , $ W = \sum_{i=1}^n w_i $ and analoguously in the computation of mean, variance and covariance include the weight instead of "1" in the formulae.

(While I'm writing this I just see, that the was an answer of Ross crossing, so this may be redundant meanwhile...)

share|improve this answer

Most linear least squares algorithms let you set the measurement error of each point. Errors in point $i$ are then weighted by $\frac{1}{\sigma_i}$. So assign a smaller measurement error to more recent points. One algorithm is available for free in the obsolete version of Numerical Recipes, chapter 15.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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