Symmetric Mean Absolute Percentage Error (SMAPE) is an accuracy metric used for measuring the performance of a forecasting model, especially when you’re interested in symmetrical treatment of over-forecasting and under-forecasting. While the more traditional MAPE (Mean Absolute Percentage Error) has its uses, SMAPE offers a balanced approach in evaluating forecast accuracy. In this article, we’ll cover:

## Table of Contents

- Introduction to SMAPE
- Why Use SMAPE?
- Limitations of SMAPE
- Calculating SMAPE in R
- Using Base R
- Custom Function Approach

- Interpretation of SMAPE
- Conclusion

## 1. Introduction to SMAPE

SMAPE stands for Symmetric Mean Absolute Percentage Error. Unlike MAPE, which can be biased towards either over-forecasting or under-forecasting, SMAPE treats both symmetrically. The formula for SMAPE is:

Where At is the actual value and Ftâ€‹ is the forecasted value at time t, and n is the number of observations.

## 2. Why Use SMAPE?

**Symmetry**: Unlike MAPE, SMAPE is symmetric, meaning it treats over-forecasts and under-forecasts equally.**Scale-Independence**: SMAPE is independent of the scale of the data, useful when comparing forecasts across different scales.

## 3. Limitations of SMAPE

**Zero Handling**: Similar to MAPE, SMAPE can have issues when the actual value is zero.**Non-Normalized Penalty**: SMAPE does not normalize the error based on the size of the actual or forecasted value, which could be problematic in some cases.

## 4. Calculating SMAPE in R

### 4.1 Using Base R

In Base R, calculating SMAPE is a matter of straightforward vector operations:

```
actual <- c(100, 200, 300, 400, 500)
forecast <- c(110, 195, 290, 405, 480)
smape <- mean(200 * abs(actual - forecast) / (abs(actual) + abs(forecast)))
print(paste("SMAPE: ", round(smape, 2), "%"))
```

### 4.2 Custom Function Approach

You can also write a more customizable function to handle special cases, like when the actual value is zero.

```
custom_smape <- function(actual, forecast) {
smape_value <- mean(200 * abs(actual - forecast) / (abs(actual) + abs(forecast)), na.rm = TRUE)
return(smape_value)
}
smape_custom <- custom_smape(actual, forecast)
print(paste("SMAPE: ", round(smape_custom, 2), "%"))
```

This custom function uses `na.rm = TRUE`

to remove NA values, which can occur when the actual value is zero.

## 5. Interpretation of SMAPE

A lower SMAPE value indicates a better model fit. But remember to consider the limitations and the context of your data before making any conclusions.

## 6. Conclusion

SMAPE offers a symmetrical, scale-independent measure for evaluating forecast accuracy and is computable in various ways in R. By understanding how to calculate and interpret SMAPE, you can make better judgments on the performance of your forecasting models.