I'm learning now some metrics of goodness about time series forecasting, using the forecast
package, but I'm stuck in something that surely I've not understood well. I have two vectors, of real data, and forecast data, and I'd like to calculate MAPE.
real <- c(1,2,3,0)
pred <- c(2,3,1,0)
accuracy(pred,real)
ME RMSE MAE MPE MAPE
Test set 0 1.224745 1 -27.77778 72.22222
So I decided to try to calculate myself the MAPE, using the docs, so:
mean(abs((real-pred)/real*100))
[1] NaN
And clearly I got NaN
, because I have a (0-0)/0
.
My question is: am I calculating wrong manually the MAPE, or the function has a kind of na.rm = TRUE
?