av.res: The criterion to evaluate forecasting model

Description Usage Arguments Details Value Note Author(s) References Examples

Description

Calculating to return answer which are 7 criterion to evaluate forecasting models, which are ME (Mean error), MAE (Mean absolute error), MPE (Mean percentage error), MAPE (Mean absolute percentage error), MSE (Mean squared error), RMSE (Root of mean square error), and U (Theil's U statistic).

Usage

1
av.res(Y = NULL, F = NULL, E = NULL, r = 3)

Arguments

Y

A data frame of univariate time series.

F

A data frame of interpolat time series.

E

A data frame of residual time series.

r

Display results returned to the specified number of decimal places (default 3). (See round2str for details of r paramicter.)

Details

The Yt is 'observation series'. The Ft is 'Forecasting series'. The et is 'residual series'. The n is size of sample. The accuracies are calculated by theory:

ME = sum(et)/n

MAE = sum(|et|)/n

MPE = sum((et/Yt)*100)/n

MAPE = sum((|et|/Yt)*100)/n

MSE = sum(et*et)/n

RMSE = sqrt(sum(et*et)/n)

U = RMSE of the forecast/RMSE of the naive forecast.

Value

ME

Mean Error.

MAE

Mean Absolute Error.

MPE

Mean Percent Error (unit: %).

MAPE

Mean Absolute Percent Error (unit: %).

MSE

Mean Square Error.

RMSE

Root of Mean Square Error.

U

Number Theil U.

min.model

The best model follow a criterion to evaluate forecasting model.

Note

This function just receive data frame. You must translate your series to data frames before send to function.

Author(s)

Nguyen Thi Diem My <myntdhg@gmail.com>

Hong Viet Minh <hongvietminh@gmail.com>

References

http://www.tailieu.tv/tai-lieu/bai-giang-quy-trinh-du-bao-khao-sat-du-lieu-va-lua-chon-mo-hinh-22414/

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#----------The moving average models-------------------------
library(TTR)
data(enrollment)
sma5<-ts(SMA(enrollment,5),start=1971)
dsma5.5<-ts(SMA(SMA(enrollment)),start=1971)
cma5<-as.ts(CMA(enrollment,5))
ses.002<-as.ts(SES(enrollment,0.002))

#Translate series to data frame
actual<-data.frame(enrollment)
forecasted<-data.frame(sma5,dsma5.5,cma5,ses.002)

#Comparing forecasting models
av.res(Y=actual,F=forecasted,r=5)


#----------The liner and arima models-------------------------
#Loading data
#data(enrollment)

#Liner model
#t<-1:length(enrollment)
#lm.model<-lm(enrollment~t)

#Arima modle
#arima.model<-arima(enrollment,order=c(1,1,0))

#Translate residual series to data frame
#actual<-data.frame(enrollment)
#residual.models<-data.frame(lm=lm.model$resid,arima=arima.model$resid)

#Comparing forecasting models
#av.res(Y=actual,E=residual.models)


#----------The fuzzy time series models-------------------------
#Following example(fuzzy.ts1)
#Comparing fuzzy time series models for lh time series
#from example of fuzzy.ts1 function
#av.res(Y=data.frame(lh),F=data.frame(chen10,singh10,heuristic10,chenhsu6))

#Following example(Gfuzzy.ts1)
#Comparing fuzzy time series models for lh time series
#from example of Gfuzzy.ts1 function
#av.res(Y=data.frame(lh),F=KQ3)

#Following example(Gfuzzy.ts2)
#Comparing fuzzy time series models for enrollment time series
#from example of Gfuzzy.ts2 function
#av.res(Y=data.frame(enrollment),F=g.fuzzy1$interpolate)

Example output

Loading required package: MASS
Loading required package: TSA
Loading required package: leaps
Loading required package: locfit
locfit 1.5-9.1 	 2013-03-22
Loading required package: mgcv
Loading required package: nlme
This is mgcv 1.8-20. For overview type 'help("mgcv-package")'.
Loading required package: tseries

Attaching package: 'TSA'

The following objects are masked from 'package:stats':

    acf, arima

The following object is masked from 'package:utils':

    tar

Loading required package: TTR
Loading required package: urca

Attaching package: 'AnalyzeTS'

The following object is masked from 'package:base':

    pmax

             sma5      dsma5.5 cma5 ses.002 min.model
ME   5.619444e+02 3.068102e+03  NaN     NaN        NA
MAE  8.630778e+02 3.068102e+03  NaN     NaN        NA
MPE  3.137230e+00 1.602847e+01  NaN     NaN        NA
MAPE 5.093620e+00 1.602847e+01  NaN     NaN        NA
MSE  1.012005e+06 9.500398e+06  NaN     NaN        NA
RMSE 1.005984e+03 3.082272e+03  NaN     NaN        NA
U    1.600970e+00 6.124350e+00  NaN     NaN        NA
Warning messages:
1: In .cbind.ts(list(e1, e2), c(deparse(substitute(e1))[1L], deparse(substitute(e2))[1L]),  :
  non-intersecting series
2: In .cbind.ts(list(e1, e2), c(deparse(substitute(e1))[1L], deparse(substitute(e2))[1L]),  :
  non-intersecting series

AnalyzeTS documentation built on Dec. 9, 2019, 1:07 a.m.