# errorMetricFunctions: Error Metric Function In forecTheta: Forecasting Time Series by Theta Models

 Error Metric R Documentation

## Error Metric Function

### Description

This function implements some of the more used error metrics. These metrics are "sMAPE", "MAPE", "MAE", "MSE" and they respectively versions with median "sMdAPE", "MdAPE", "MdAE", "MdSE".

### Usage

```	errorMetric(obs, forec, type="sAPE", statistic="M")
```

### Arguments

 `obs` A vector or a matrix with the real values. `forec` A vector or a matrix with the estimated values. `type` The error type of "sAPE", "APE", "AE" and "SE". `statistic` The statistic to be returned. Use "M" or "Md" for return the mean or median of the errors. If "N" so a vector with all errors will be returned.

### Details

The metric sMAPE is obtained using `type = "sAPE"` and `statistic = "M"`

The metric sMdAPE is obtained using `type = "sAPE"` and `statistic = "Md"`

The metric MAPE is obtained using `type = "APE"` and `statistic = "M"`

The metric MdAPE is obtained using `type = "APE"` and `statistic = "Md"`

The metric MAE is obtained using `type = "AE"` and `statistic = "M"`

The metric MdAE is obtained using codetype = "AE" and `statistic = "Md"`

The metric MSE is obtained using `type = "SE"` and `statistic = "M"`

The metric MdSE is obtained using `type = "SE"` and `statistic = "Md"`

### Value

If `statistic="M"` or `statistic="Md"` it is returned the respectively error metric result. If `statistic="N"` so is returned a vector with all errors points according to the chosen error type.

### Author(s)

Jose Augusto Fiorucci and Francisco Louzada

`forecTheta-package`, `groe`

### Examples

```##############################################################

y1 = 2+ 0.15*(1:20) + rnorm(20,2)
y2 = y1+ 0.3*(1:30) + rnorm(30,2)
y =  as.ts(c(y1,y2))

out <- dotm(y=as.ts(y[1:40]), h=10)

### sMAPE metric
errorMetric(obs=as.ts(y[41:50]), forec=out\$mean)

### sMdAPE metric
errorMetric(obs=as.ts(y[41:50]), forec=out\$mean, statistic = "Md")

### MASE metric
meanDiff1 = mean(abs(diff(as.ts(y[1:40]), lag = 1)))
errorMetric(obs=as.ts(y[41:50]), forec=out\$mean, type = "AE", statistic = "M") / meanDiff1
```

forecTheta documentation built on Nov. 12, 2022, 1:09 a.m.