arimaSimComp: Simulate ARIMA Model and Compare ACF and PACF

View source: R/identification.R

arimaSimCompR Documentation

Simulate ARIMA Model and Compare ACF and PACF

Description

Simulate an ARIMA model of a specified size, showing its ACF, PACF and time series plot, and compare it with a time series sample if wanted.

Usage

arimaSimComp(
  dates,
  sample,
  order = c(0, 0, 0),
  seasonal = c(0, 0, 0),
  n = 10000,
  period = 1,
  ar,
  ma,
  sar,
  sma,
  lag.max,
  plot = T
)

Arguments

dates

optional: a vector or an array with the dates as character of each observation of the time series. This vector can be generated using the function dateSeq.

sample

optional: a vector or an array with the values of the time series without differencing.

order

a specification of the non-seasonal part of the ARIMA model: the three components (p, d, q) are the AR order (p and q maximum of 3), the order of differencing, and the MA order. See 'Details'.

seasonal

a specification of the seasonal part of the ARIMA model: the three components (P, D, Q) are the AR order (P and Q maximum of 3), the order of differencing, and the MA order.

n

the size of the simulation, 10000 by default since that size makes the simulation very similar to the theorical ARIMA model, which can be seen in the ACF and PACF representations.

period

the period of the seasonal part of the ARIMA model.

ar

the AR coefficients of the non-seasonal part of the ARIMA model in order. For example ar = c(0.5, 0.7), 0.5 coefficient of the first lag, 0.7 coefficient of the second lag. See 'Details'.

ma

the MA coefficients of the non-seasonal part of the ARIMA model in order. Works the same way as ar parameter.

sar

the AR coefficients of the seasonal part of the ARIMA model in order. For example sar = c(-0.3, 0.6), -0.3 coefficient of the period-th lag, 0.6 coefficient of the period*2-th lag. See 'Details'.

sma

the MA coefficients of the seasonal part of the ARIMA model in order. Works the same way as sar parameter.

lag.max

maximum number of lags at which to calculate the ACF. Default is period*round((length(sample)/4)/period).

plot

if TRUE, it will show all the plots in execution.

Details

The function uses arima.sim to simulate the ARIMA model. The order of differencing specified in order and seasonal parameters will affect only the sample, which will be differenced if those orders are greater than 0.

If a multiplicative ARIMA model is chosen the coefficients product of the non-seasonal and seasonal part will be calculated automatically with the coefficients of the main lags.

Value

A list containing the following components:

simplot

A plot of the simulated model as specified.

sampplot

A plot of the original sample time series if given.

diffsampplot

A plot of the differenced sample time series if specified so.

acfPlot

An ACF plot of the simulated model and (if specified) the time series given differenced as specified.

pacfPlot

A PACF plot of the simulated model and (if specified) the time series given differenced as specified.

See Also

grid.arrange, ggplot.

Examples

#Easy example with AirPassengers 
dates <- dateSeq(from = time(AirPassengers)[1], to = time(AirPassengers)[length(AirPassengers)], 
                 by="month")

arimaSim <- arimaSimComp(dates, sample = log(AirPassengers), order = c(0, 1, 1), seasonal = c(0, 1, 1),
             ma = c(-0.4), period = 12, sma = c(-0.6), plot = F)
arimaSim 

#Example without a sample
arimaSim2 <- arimaSimComp(order = c(0, 0, 2), seasonal = c(0, 0, 1), period = 12, ma = c(-0.5, 0.4),
             sma = c(-0.6), plot = F)
arimaSim2

danipequelangos/CBJTSA documentation built on Oct. 16, 2022, 7:19 p.m.