SMAPE: Symmetric mean absolute percentage error

View source: R/SMAPE.R

SMAPER Documentation

Symmetric mean absolute percentage error

Description

Calculates the relative difference between X (forecast) and y (historical data) [Armstrong,1985]. Beware:Averaging has to be done by the user!

Usage

SMAPE(X, Y, epsilon = 10^-10,na.rm=FALSE,Silent=FALSE)

Arguments

X

Either a value or numerical vector of [1:n]

Y

Either a value or numerical vector of [1:n]

epsilon

Optional, if both x and y are approximately zero the output is also zero. Default is 10^-10

na.rm

Optional, function does not work with non finite values. If these cases should be automatically removed, set parameter TRUE

Silent

Optional, TRUE: No Warnings or errors are given back. Default is FALSE

Details

This function was taken from DatabionicSwarm::RelativeDifferences and slightly adjusted:

The nominator is contrary to [Ultsch, 2008] in absolute values of X and Y resulting in the problem that SMAPE ist not symmetric regarding different forecasts since over- and under-forecasts are not treated equally (see example for further details).

Contrary to other approaches in this cases the range of values lies between [-100,100] in percent. The approach is only valid for positive and negative values of X and Y. The relative difference R is defined with

SMAPE=100/n * \frac{abs(Y-X)}{(abs(X)+abs(Y))}

Negative value indicate that X is higher than Y and positive values that X is lower than Y.

Value

SMAPE

Note

Contrary to the relative differences, SMAPE is not symmetric.

Author(s)

Michael Thrun

References

[Ultsch,2008] Ultsch, A.: Is Log Ratio a Good Value for Measuring Return in Stock Investments? GfKl 2008, pp, 505-511, 2008. [Armstrong,1985] Armstrong, J. S.: Long-range Forecasting: From Crystal Ball to Computer, 2nd. ed. Wiley, ISBN 978-0-471-82260-8, 1985.

See Also

DatabionicSwarm::RelativeDifferences

Examples

#usage with vectors, x forecast, y test data
x=c(100,110)
y=c(90,100)
mean(SMAPE(x,y))#smape

#example why it is not symmetric
SMAPE(x[1],y[1])

SMAPE(x[2],y[2])

Mthrun/TSAT documentation built on Feb. 5, 2024, 11:15 p.m.