View source: R/identification.R
arimaSimComp | R Documentation |
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.
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 )
dates |
optional: a vector or an array with the dates as |
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 |
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 |
sma |
the MA coefficients of the seasonal part of the ARIMA model in order. Works the same way as |
lag.max |
maximum number of lags at which to calculate the ACF. Default is |
plot |
if |
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.
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. |
grid.arrange
, ggplot
.
#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
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.