Fitting Models to Data

By Mark Ciotola

First published on February 27, 2019

What Is Fitting?

For the moment, let assume that we have a validated, precisely known data set. However, we don’t know the relationship between the data, its trends or driving tendencies. So we decide to develop a model to gin a deeper understanding. Generating a model is easy. Personal income = (5 * personal height) + 6. There. Done! Yet to what extent is it a valid model? There are tools for that. In fact, modeling is often a process of adjusting the model function and parameters until the model fits the data well. Fitting models to data typically involves adjusting parameters, including initial conditions, so that values comprising the model are closer to data values. Sometime the underlying function itself needs to be changed, as long as that does not violate the principle under which the model was derived.

Total Error Minimization Techniques

Basic Notation

The following notation will be used for the below methods.

• $$Y_t$$ value of a time series at period $$t$$
• $$\widehat{Y}_t =$$model value of $$Y_t$$
• $$e_t = Y_t – \widehat{Y}_t$$ = residual, or model error

Error, or residual, for each forecast period. $$e_t = Y_t-\widehat{Y}_t$$

• $$e_t =$$ model error in time $$t$$
• $$Y_t=$$ actual value in period $$t$$
• $$\widehat{Y}_t=$$ model value for time period $$t$$

Mean Absolute Deviation

Mean Absolute Deviation (MAD) involves averaging the magnitudes of the absolute value of each error. It is useful for expressing error in the same units as the underlying data. $$MAD = \frac{1}{n}\sum_{t=1}^{n} \lvert Y_t – \widehat{Y}_t \rvert$$

Mean Squared Error

The Mean Squared Error (MSE) technique is minimizing the sum of the squares. For each term of data, calculate the value the model would produce (e.g. for each point of time). Take the square of difference between calculated and actual value. Add up all of those squares. Adjust your unknown parameters to produce the smallest value for the sum of the squares. This will be your best fit model. This technique penalizes large errors, so it may not be practical with unreliable data. $$MSE = \frac{1}{n}\sum_{t=1}^{n} \big(Y_t – \widehat{Y}_t \big)$$

Mean Absolute Percentage Error

Mean absolute percentage error (MAPE) is useful when expressing errors as a percentage is desired. This technique may be especially useful for efficiency-discounted exponential growth (EDEG) models where there is often tremendous variation the y value. $$MAPE = \frac{1}{n}\sum_{t=1}^{n} \frac{\lvert Y_t – \widehat{Y}_t \rvert}{Y_t}$$

Characteristic Minimization Goals

Instead of reducing total error, you might with to minimize the difference as regards a particular characteristic. For example, a priority might be to match your model’s peak with that of the data. Or you may wish to match particular events in time.

Reference

Presentation of fitting quantitative techniques adapted from John E. Hanke and Dean W. Wichern, Business Forecasting, Eighth Edition. Pearson Prentice Hall 2005.