PrintAIC: Print AIC Values

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

Description

Calculates and outputs AIC value for some models including ARMA, ARIMA, SARIMA, ARMAX, ARIMAX, SARIMAX, ARCH and GARCH. To classify and extracts the best model by AIC values.

Usage

1
2
3
PrintAIC(DataTimeSeries, order = c(p, d = NULL, q = NULL), 
seas = list(order = c(P = NULL, D = NULL, Q = NULL), frequency = NULL), 
type = NULL,xreg=NULL)

Arguments

DataTimeSeries

Univariate time series.

order

If type="ARMA" (or ARMAX) then 'order' is a vector contain two positive integer which are order of ARMA model (or ARMAX model).

If type="ARIMA" (or ARIMAX) then 'order' is a vector contain three positive integer which are order of ARIMA model (or ARIMAX model).

If type="SARIMA" (or SARIMAX) then 'order' is a vector contain three positive integer which are order of ARIMA model (or ARIMAX model) of the non-seasonal part of the SARIMA model (or SARIMAX model).

If type="ARCH" then 'order' is a positive integer which are order of ARCH model.

If type="GARCH" then 'order' is a vector contain two positive integer which are order of GARCH model.

seas

A list contain two part which are 'order' and 'frequency'.

'order' part is a vector contain three positive integer which are order of ARIMA model of the seasonal part of the SARIMA model (or SARIMAX model).

'frequency' part is frequency of observation series.

type

A character string specifying the type of models, must be one of "ARMA", "ARIMA", "SARIMA", "ARCH", "GARCH", "ARMAX", "ARIMAX" or "SARIMAX".

xreg

Optionally, a vector or matrix of external regressors, which must have the same number of rows as x.

Details

The first, function identify type of models according to 'type' parameter. The next, test other parameters. All of parameters are reasonable, function will combine orders of models. And then, to calculate AIC value of each model. The last step, performing ranked and extracting the best model.

Value

mohinh

Calculation results.

best

The best model following AIC value.

Note

You must be careful with 'order' and 'type' parameter of models.

Author(s)

Tran Thi Ngoc Han <tranthingochan01011994@gmail.com>

Mai Thi Hong Diem <maidiemks@gmail.com>

Hong Viet Minh <hongvietminh@gmail.com>

References

Nguyen Thi Diem My va Hong Viet Minh, Phan tich chuoi thoi gian voi su ho tro cua package AnalyzeTS.

Hong Viet Minh, Luan van tot nghiep dai hoc: Phan tich so lieu thong ke voi ngon ngu R.

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
#----A time series--------------------------------
sl<-ts(c(180,165,110,126,125,134,163,153,122,171,171,155
,175,248,99,187,173,147,184,108,171,195,192,163))

#----The ARMA models--------------------------------
PrintAIC(sl,order=c(1,4),type="ARMA")

#----The ARIMA models--------------------------------
PrintAIC(sl,order=c(1,1,4),type="ARIMA")

#----The SARIMA models--------------------------------
PrintAIC(sl,order=c(1,1,4),seas=list(order=c(0,0,1),
frequency=4),type="SARIMA")

#----The ARCH models--------------------------------
PrintAIC(sl,order=c(4),type="ARCH")

#----The GARCH models--------------------------------
PrintAIC(sl,order=c(1,4),type="GARCH")

#----The ARIMAX models--------------------------------
#A factor
date<-as.factor(c("Tue","Wed","Thu","Fri","Mon","Tue","Wed",
"Thu","Fri","Mon","Tue","Wed","Thu","Fri","Mon","Tue","Wed",
"Thu","Fri","Mon","Tue","Wed","Thu","Fri","Mon","Tue","Wed",
"Thu","Fri","Mon","Tue","Wed","Thu"))
#Observation series.
coffee<-c(5,6,8,4,3,7,6,0,3,2,3,4,9,1,3,8,7,8,2,3,8,6,4,
4,6,7,6,5,2,3,8,4,4)
coffee<-ts(coffee,start=c(1,2),frequency=5)
Mon<-1*(date=="Mon")
event<-data.frame(Mon)
PrintAIC(coffee,order=c(2,2),xreg=event,type="ARMAX")

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

$Models
        ARMA models      AIC values  Sort by AIC
Model 1   ARMA(0,1) ...AIC = 241.72 .......... 2
Model 2   ARMA(0,2) ...AIC = 243.61 .......... 3
Model 3   ARMA(0,3)  ...AIC = 244.9 .......... 5
Model 4   ARMA(0,4) ...AIC = 246.78 .......... 8
Model 5   ARMA(1,0)  ...AIC = 241.7 .......... 1
Model 6   ARMA(1,1)  ...AIC = 243.7 .......... 4
Model 7   ARMA(1,2) ...AIC = 245.41 .......... 6
Model 8   ARMA(1,3) ...AIC = 246.52 .......... 7
Model 9   ARMA(1,4) ...AIC = 248.46 .......... 9

$Best
       The best ARMA model
  ARMA(1,0) ...AIC = 241.7

$Models
        ARIMA models      AIC values  Sort by AIC
Model 1 ARIMA(0,1,1) ...AIC = 234.01 .......... 1
Model 2 ARIMA(0,1,2) ...AIC = 235.42 .......... 2
Model 3 ARIMA(0,1,3) ...AIC = 237.42 .......... 4
Model 4 ARIMA(0,1,4) ...AIC = 238.77 .......... 6
Model 5 ARIMA(1,1,0) ...AIC = 240.62 .......... 8
Model 6 ARIMA(1,1,1) ...AIC = 235.48 .......... 3
Model 7 ARIMA(1,1,2) ...AIC = 237.42 .......... 5
Model 8 ARIMA(1,1,3) ...AIC = 239.32 .......... 7
Model 9 ARIMA(1,1,4) ...AIC = 240.78 .......... 9

$Best
          The best ARIMA model
  ARIMA(0,1,1) ...AIC = 234.01

$Models
                    SARIMA models      AIC values  Sort by AIC
Model 1 SARIMA(0,1,1)*(0,0,1),s=4 ...AIC = 235.74 .......... 2
Model 2 SARIMA(0,1,2)*(0,0,1),s=4 ...AIC = 237.42 .......... 3
Model 3 SARIMA(0,1,3)*(0,0,1),s=4 ...AIC = 238.77 .......... 5
Model 4 SARIMA(0,1,4)*(0,0,1),s=4 ...AIC = 240.72 .......... 7
Model 5 SARIMA(1,1,0)*(0,0,1),s=4 ...AIC = 235.48 .......... 1
Model 6 SARIMA(1,1,1)*(0,0,1),s=4 ...AIC = 237.55 .......... 4
Model 7 SARIMA(1,1,2)*(0,0,1),s=4 ...AIC = 239.36 .......... 6
Model 8 SARIMA(1,1,3)*(0,0,1),s=4 ...AIC = 240.78 .......... 8
Model 9 SARIMA(1,1,4)*(0,0,1),s=4 ...AIC = 242.76 .......... 9

$Best
                      The best SARIMA model
  SARIMA(1,1,0)*(0,0,1),s=4 ...AIC = 235.48

$Models
        ARCH models      AIC values  Sort by AIC
Model 1     ARCH(1) ...AIC = 305.25 .......... 4
Model 2     ARCH(2)  ...AIC = 292.7 .......... 3
Model 3     ARCH(3) ...AIC = 281.79 .......... 2
Model 4     ARCH(4) ...AIC = 271.12 .......... 1

$Best
      The best ARCH model
  ARCH(4) ...AIC = 271.12

Warning messages:
1: In sqrt(pred$e) : NaNs produced
2: In sqrt(pred$e) : NaNs produced
3: In sqrt(pred$e) : NaNs produced
4: In sqrt(pred$e) : NaNs produced
$mohinh
         GARCH models      AIC values  Sort by AIC
Model  1   GARCH(1,0) ...AIC = 303.16 .......... 4
Model  2   GARCH(1,1) ...AIC = 305.16 .......... 5
Model  3   GARCH(1,2) ...AIC = 295.36 .......... 3
Model  4   GARCH(1,3) ...AIC = 285.56 .......... 2
Model  5   GARCH(1,4) ...AIC = 275.69 .......... 1

$best
        The best GARCH model
  GARCH(1,4) ...AIC = 275.69

Warning messages:
1: In garch(DataTimeSeries, order = c(i1, i2), trace = FALSE) :
  singular information
2: In garch(DataTimeSeries, order = c(i1, i2), trace = FALSE) :
  singular information
3: In sqrt(pred$e) : NaNs produced
4: In sqrt(pred$e) : NaNs produced
5: In sqrt(pred$e) : NaNs produced
$Models
        ARMAX models      AIC values  Sort by AIC
Model 1   ARMAX(0,1) ...AIC = 153.47 .......... 3
Model 2   ARMAX(0,2) ...AIC = 152.25 .......... 2
Model 3   ARMAX(1,0) ...AIC = 153.48 .......... 4
Model 4   ARMAX(1,1) ...AIC = 154.12 .......... 6
Model 5   ARMAX(1,2) ...AIC = 154.21 .......... 7
Model 6   ARMAX(2,0)    ...AIC = 152 .......... 1
Model 7   ARMAX(2,1) ...AIC = 153.82 .......... 5
Model 8   ARMAX(2,2) ...AIC = 155.82 .......... 8

$Best
     The best ARMAX model
  ARMAX(2,0) ...AIC = 152

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