metrics.Rd 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. % Generated by roxygen2: do not edit by hand
  2. % Please edit documentation in R/metrics.R
  3. \name{metrics}
  4. \alias{metrics}
  5. \alias{me}
  6. \alias{mse}
  7. \alias{rmse}
  8. \alias{mae}
  9. \alias{mpe}
  10. \alias{mape}
  11. \alias{all_metrics}
  12. \title{Metrics for Time Series Forecasts}
  13. \usage{
  14. me(fcst)
  15. mse(fcst)
  16. rmse(fcst)
  17. mae(fcst)
  18. mpe(fcst)
  19. mape(fcst)
  20. all_metrics(fcst)
  21. }
  22. \arguments{
  23. \item{fcst}{Dataframe output of `predict`.}
  24. }
  25. \value{
  26. metrics value (numeric)
  27. }
  28. \description{
  29. A time-series forecast requires making a quantitative prediction of future values.
  30. After forecast, we also have to provide accurracy of forecasts to check wether the forecast serves our need.
  31. Metrics for time series forecasts are so useful in telling you how your model is good and helping you determine which particular forecasting models work best.
  32. }
  33. \details{
  34. Here, as a notation, we assume that \eqn{y} is the actual value and \eqn{yhat} is the forecast value.
  35. Mean Error (ME, \code{me})
  36. The Mean Error (ME) is defined by the formula:
  37. \deqn{ \frac{1}{n} \sum_{t=1}^{n} y_{t}-yhat_{t} .}
  38. Mean Squared Error (MSE, \code{mse})
  39. The Mean Squared Error (MSE) is defined by the formula:
  40. \deqn{ \frac{1}{n} \sum_{t=1}^{n} (y_{t}-yhat_{t})^2 .}
  41. Root Mean Square Error (RMSE, \code{rmse})
  42. Root Mean Square Error (RMSE) is define by the formula:
  43. \deqn{ \sqrt{\frac{1}{n} \sum_{t=1}^{n} (y_{t}-yhat_{t})^2} .}
  44. Mean Absolute Error (MAE, \code{mae})
  45. The Mean Absolute Error (MAE) is defined by the formula:
  46. \deqn{ \frac{1}{n} \sum_{t=1}^{n} | y_{t}-yhat_{t} | .}
  47. Mean Percentage Error (MPE, \code{mpe})
  48. The Mean Percentage Error (MPE) is usually expressed as a percentage
  49. and is defined by the formula:
  50. \deqn{ \frac{100}{n} \sum_{t=1}^{n} \frac {y_{t}-yhat_{t}}{y_{t}} .}
  51. Mean Absolute Percentage Error (MAPE, \code{mape})
  52. The Mean absolute Percentage Error (MAPE), also known as Mean Absolute Percentage Deviation (MAPD), is usually expressed as a percentage,
  53. and is defined by the formula:
  54. \deqn{ \frac{100}{n} \sum_{t=1}^{n} | \frac {y_{t}-yhat_{t}}{y_{t}}| .}
  55. }
  56. \examples{
  57. \dontrun{
  58. # Create example model
  59. library(readr)
  60. df <- read_csv('../tests/testthat/data.csv')
  61. m <- prophet(df)
  62. # You can check your models's accuracy using me, mse, rmse ...etc.
  63. print(rmse(m))
  64. }
  65. }