University: National University of Colombia

ORCID: https://orcid.org/0009-0007-4485-0129

INDEX

  1. Libraries
  2. Simulation
  3. Exploratory analysis 3.1. Initial visualization 3.2. Descriptive statistics 3.3. Autocorrelation 3.3.1. Autocorrelograms 3.3.2. Tests
  4. Stationarity test

1.It is crucial to run the following chunk corresponding to the libraries needed for the series.

if (!require(forecast)) install.packages("forecast", dependencies = TRUE)
## Cargando paquete requerido: forecast
## Registered S3 method overwritten by 'quantmod':
##   method            from
##   as.zoo.data.frame zoo
if (!require(tseries)) install.packages("tseries", dependencies = TRUE)
## Cargando paquete requerido: tseries

2.Simulation of an AR(2) Process

An AR(2) process follows the model:

\[ X_t = \phi_1 X_{t-1} + \phi_2 X_{t-2} + \epsilon_t, \]

where \(\epsilon_t\) is a white noise term with zero mean and constant variance.

Coefficients: \(\phi_1 = 0.7\) and \(\phi_2 = -0.3\) were specified.

Sample size: \(n = 200\).

Generation: The series was generated using the arima.sim function with the specified coefficients.

#         
set.seed(123) 
phi <- c(0.7, -0.3) 
n <- 200           
serie_ar2 <- arima.sim(model = list(ar = phi), n = n)

3. Exploratory Analysis

3.1. Initial Visualization: The general behavior of the series is as follows:

plot(serie_ar2, col = "green", lwd = 2, main = "Simulation of an AR(2) Process", xlab = "Time", ylab = "X_t")

3.2. Descriptive Statistics:

summary(serie_ar2)
##      Min.   1st Qu.    Median      Mean   3rd Qu.      Max. 
## -2.948446 -0.804152  0.074633 -0.001858  0.734391  2.920457

3.3. Autocorrelation:

3.3.1. Autocorrelograms:

acf(serie_ar2, main = "Autocorrelation Function (ACF)")

pacf(serie_ar2, main = "Partial Autocorrelation Function (PACF)")

3.3.2. Tests:

# Box-Pierce test
resultado_box_pierce <- Box.test(serie_ar2, lag = 10, type = "Box-Pierce")
print(resultado_box_pierce)
## 
##  Box-Pierce test
## 
## data:  serie_ar2
## X-squared = 55.29, df = 10, p-value = 2.787e-08

Null hypothesis (\(H_0\)): There is no autocorrelation.

p-valor: \(2.787 \times 10^{-8}\), which is extremely small.

Since the p-value is much smaller than any common level of significance (0.01, 0.05), the null hypothesis is rejected. This indicates that there is significant autocorrelation in the residuals up to lag 10.

# Ljung-Box test
resultado_ljung_box <- Box.test(serie_ar2, lag = 10, type = "Ljung-Box")
print(resultado_ljung_box)
## 
##  Box-Ljung test
## 
## data:  serie_ar2
## X-squared = 56.299, df = 10, p-value = 1.804e-08

Null hypothesis (\(H_0\)): There is no autocorrelation.

p-valor: \(1.804 \times 10^{-8}\), which is extremely small.

As with the Box-Pierce test, the very small p-value indicates that there is significant autocorrelation in the residuals up to lag 10.

4. Stationarity Test (ADF)

The Augmented Dickey-Fuller (ADF) test was performed to see if the series is stationary.

Null hypothesis (\(H_0\)): The series is not stationary (it has a unit root).

adf_test <- adf.test(serie_ar2)
## Warning in adf.test(serie_ar2): p-value smaller than printed p-value
print(adf_test)
## 
##  Augmented Dickey-Fuller Test
## 
## data:  serie_ar2
## Dickey-Fuller = -5.937, Lag order = 5, p-value = 0.01
## alternative hypothesis: stationary

Results: The test results, including the \(p\) value and the test statistic, indicated that \(H_0\) is rejected, confirming stationarity.