pe: Calculate percent error between actual and forecast.

Description Usage Arguments Value Examples

View source: R/errors.R

Description

pe takes actual and forecast numeric vectors and returns a numeric vector where forecast is subtracted from the actual and then those errors are divided by the actuals.

Usage

1
pe(y_true = NULL, y_pred = NULL, actual = NULL, forecast = NULL)

Arguments

y_true

Ground truth (correct) target values.

y_pred

Estimated target values.

actual

a numeric vector of actuals.

forecast

a numeric vector of forecasts.

Value

a numeric vector of percent errors.

Examples

1
2
# Examples
pe(1:100, 100:1)

Example output

  [1] -99.00000000 -48.50000000 -31.66666667 -23.25000000 -18.20000000
  [6] -14.83333333 -12.42857143 -10.62500000  -9.22222222  -8.10000000
 [11]  -7.18181818  -6.41666667  -5.76923077  -5.21428571  -4.73333333
 [16]  -4.31250000  -3.94117647  -3.61111111  -3.31578947  -3.05000000
 [21]  -2.80952381  -2.59090909  -2.39130435  -2.20833333  -2.04000000
 [26]  -1.88461538  -1.74074074  -1.60714286  -1.48275862  -1.36666667
 [31]  -1.25806452  -1.15625000  -1.06060606  -0.97058824  -0.88571429
 [36]  -0.80555556  -0.72972973  -0.65789474  -0.58974359  -0.52500000
 [41]  -0.46341463  -0.40476190  -0.34883721  -0.29545455  -0.24444444
 [46]  -0.19565217  -0.14893617  -0.10416667  -0.06122449  -0.02000000
 [51]   0.01960784   0.05769231   0.09433962   0.12962963   0.16363636
 [56]   0.19642857   0.22807018   0.25862069   0.28813559   0.31666667
 [61]   0.34426230   0.37096774   0.39682540   0.42187500   0.44615385
 [66]   0.46969697   0.49253731   0.51470588   0.53623188   0.55714286
 [71]   0.57746479   0.59722222   0.61643836   0.63513514   0.65333333
 [76]   0.67105263   0.68831169   0.70512821   0.72151899   0.73750000
 [81]   0.75308642   0.76829268   0.78313253   0.79761905   0.81176471
 [86]   0.82558140   0.83908046   0.85227273   0.86516854   0.87777778
 [91]   0.89010989   0.90217391   0.91397849   0.92553191   0.93684211
 [96]   0.94791667   0.95876289   0.96938776   0.97979798   0.99000000
Warning messages:
1: In pe(1:100, 100:1) : 'pe' is deprecated. Use 'percent_error' instead.
2: In e(actual, forecast) :
  'e' is deprecated. Use 'absolute_error' instead.

scorer documentation built on May 2, 2019, 3:22 a.m.