How To Calculate Mean Absolute Error

In statistics, you make forecasts based on the data you have available. Unfortunately, the forecasts don't always match with the actual values generated by the data. Knowing the difference between the forecasts and the actual values of your data is useful as it can help you refine future forecasts and make them more accurate. To find out how much of a difference there is between your forecasts and the actual value produced, you need to calculate the mean absolute error (also known as MAE) of the data.

Calculate SAE

Before you can calculate the MAE of your data, you first need to calculate the sum of absolute errors (SAE). The formula for SAE is

\(\sum_{i=1}^n|x_i – x_t|\)

which may appear confusing at first if you aren't used to sigma notation. The actual procedure is fairly straightforward, however.

1. Take Absolute Values

Subtract the true value (signified by ​xt) from the measured value (signified by ​xi), possibly generating a negative result depending on your data points. Take the absolute value of the result to generate a positive number. As an example, if ​xi is 5 and ​xt is 7:

\(5 – 7 = -2\)

The absolute value of −2 (signified by | −2|) is 2.

2. Repeat n Times

Repeat this process for each set of measurements and forecasts in your data. The number of sets is signified by ​n​ in the formula, with the

\(\sum_{i=1}^n\)

indicating that the process starts at the first set (​i​ = 1) and repeats a total of ​n​ times. In the previous example, assume that the previous points used were one out of 10 pairs of data points. In addition to the 2 generated before, the remaining point sets generate absolute values of 1, 4, 3, 4, 2, 6, 3, 2 and 9.

3. Add the Values

Add the absolute values together to generate your SAE. For the example, this gives us

\(\text{SAE} = 2 + 1 + 4 + 3 + 4 + 2 + 6 + 3 + 2 + 9 = 36\)

Calculate MAE

Once you calculate the SAE, you have to find the mean or average value of the absolute errors. Use the formula

\(\text{MAE} = \frac{\text{SAE}}{n}\)

to get this result. You may also see the two formulas combined into one, which looks like

\(\text{MAE} = \frac{\sum_{i=1}^n|x_i – x_t|}{n}\)

but there is no functional difference between the two.

1. Divide by n

Divide your SAE by ​n​, which as mentioned above is the total number of point sets in your data. Continuing with the previous example, this gives us

\(\text{MAE} = \frac{36}{10} = 3.6\)

2. Round as Needed

Round your total to a set number of significant digits if required. There is no need for this in the example used above, but a calculation providing figures such as MAE = 2.34678361 or a repeating figure may need rounding to something more manageable like MAE = 2.347. The number of trailing digits used depends on personal preference and the technical specifications of the work you do.

Cite This Article

MLA

Gerard, Jack. "How To Calculate Mean Absolute Error" sciencing.com, https://www.sciencing.com/calculate-mean-absolute-error-6426845/. 14 December 2020.

APA

Gerard, Jack. (2020, December 14). How To Calculate Mean Absolute Error. sciencing.com. Retrieved from https://www.sciencing.com/calculate-mean-absolute-error-6426845/

Chicago

Gerard, Jack. How To Calculate Mean Absolute Error last modified March 24, 2022. https://www.sciencing.com/calculate-mean-absolute-error-6426845/

Recommended