1.4 Simulations

The workhorse for simulations from ARIMA models is arima.sim. To generate an AR(1) and an MA(1) processes using the function , one can use.

ar1 <- arima.sim(n = 100, model = list(ar = 0.9))
ma1 <- arima.sim(n = 100, model = list(ma = 0.8))

Define the following function to generate an ARCH(1) process.

arch.sim1 <- function(n, a0 = 1, a1 = 0.9) {
    y <- eps <- rnorm(n)
    for (i in 2:n) y[i] <- eps[i] * sqrt(a0 + a1 * y[i - 1]^2)
    ts(y)
}
a0 <- 0.05
a1 <- 0.8
n <- 2000
y1 <- arch.sim1(n, a0, a1)

Use the second-order summaries functions to analyse the obtained process, the process of the squared values and the process of the absolute values.

Do it again with the following function, which has Student distributed variables as driving noise.

arch.sim2 <- function(n, df = 100, a0 = 1, a1 = 0.9) {
    y <- eps <- rt(n, df = df) * sqrt((df - 2)/df)
    for (i in 2:n) y[i] <- eps[i] * sqrt(a0 + a1 * y[i - 1]^2)
    ts(y)
}
a0 <- 0.05
a1 <- 0.8
n <- 2000
y1 <- arch.sim2(n, a0 = a0, a1 = a1)

1.4.1 Exercise 3: Simulated data

  1. Simulate 500 observations from an AR(1) process with parameter values \(\alpha \in \{0.1, 0.5, 0.9, 0.99\}\).
  2. Repeat for MA processes of different orders. There is no restriction on the coefficients of the latter for stationarity, unlike the AR process.
  3. Sample from an ARCH(1) process with Gaussian innovations and an ARCH(1) process with Student-\(t\) innovations with df=4. Look at the correlogram of the absolute residuals and the squared residuals.
  4. The dataset EuStockMarkets contains the daily closing prices of major European stock indices. Type ?EuStockMarkets for more details and plot(EuStockMarkets) to plot the four series (DAX, SMI, CAC and FTSE). Use plot(ftse <- EuStockMarkets[,"FTSE"]) to plot the FTSE series and plot(100*diff(log(ftse))) to plot its daily log return. Play with the ARCH simulation functions to generate some similar processes.
  5. Simulate a white noise series with trend \(t\) and \(\cos(t)\), of the form \(X_t=M_t+S_t+Z_t\), where \(Z_t \sim \mathsf{N}(0,\sigma^2)\) for different values of \(\sigma^2\). Analyze the log-periodogram and the (partial) correlograms. What happens if you forget to remove the trend?
  6. Do the same for multiplicative model with lognormal margins, with structure \(X_t=M_tS_tZ_t\).
  7. For steps 5 and 6, plot the series and test the assumptions that they are white noise using the Ljung-Box test. Note you need to adjust the degrees of freedom when working with residuals from e.g. ARMA models.