Q1)
a) Generate a random walk process without drift with 100 time periods and plot the
realization.
b) Simulate 50 different realizations of the same random walk model and plot
the first 10 realizations.
[c] Extract the values of the simulated series at time period 30 for all 50
realizations, reshape the data into long format, and generate a histogram for the
combined Y30 values across realizations.
[d] Modify the random walk model by adding a drift term and simulate 50
realizations of this model. Plot the first 10 realizations and observe how drift
influences the process.
Q2]Generate a time series with a deterministic linear trend and random noise for
200 periods. Detrend the series by regressing it on the time variable. Plot both the
original and detrended series. How does detrending affect the overall behaviour of
the time series?
The series becomes stationary after detrending
Q.3 Using any suitable Stata dataset, estimate a time series model where the trend is
unknown. Fit polynomial trends of varying degrees (e.g., linear, quadratic, cubic)
and compare the model fit using the AIC, BIC criterion. How do you determine the
best fitting model, and what insights do the residuals provide about the trend?
Trend generated for the dataset Passengers
The quadratic model has the lowest BIC and hence will be chosen.
Q4]In Stata, simulate 50 realizations of an AR(2) process for 100 time periods using
the following specification:
Yt = −0.7Yt−1 + 0.8Yt−2 + εt
where εt is a normally distributed error term. Plot the first 10 realizations. What
patterns do you observe across the realizations? Explain the behaviour of the AR(2)
process over time.
Short-Term Oscillations: In the early time periods, the influence of the initial values and shocks
is strong, causing oscillatory behavior due to the interplay of the −0.7-0.7−0.7 and 0.80.80.8
coefficients.
Damping Effect: Over time, these influences decay, and the process stabilizes. This decay is
due to the fact that the combined influence of past values gradually becomes weaker, which is
characteristic of a stationary AR(2) process.
Long-Term Stability: In the long term, the AR(2) process exhibits a stable behavior where the
values are around a constant mean. This is expected in a stationary process, where shocks
have a transitory effect that diminishes over time.
Q.5 Simulate a similar AR(1) process for 50 realizations with 100 observations using
the specification:
Yt = 0.5Yt−1 + εt
where εt is a normally distributed error term. Compare the AR(2) and AR(1)
realizations by plotting them together. What are the key differences in their
dynamics, and how does the second lag affect the AR(2) process?
The AR(1) process, which relies solely on the previous period's value, exhibits shorter memory
and smoother behavior with direct stabilization due to a single decay factor. In contrast, the
AR(2) process incorporates both the previous two periods, leading to longer memory and more
complex, oscillatory dynamics due to the interplay between lagged terms. This results in
short-term fluctuations around the mean before eventual damping and stabilization. Adding the
second lag in the AR(2) model introduces richer dynamics and oscillations, unlike the smoother
path of the AR(1) process.
Q.6 Using Stata, simulate 50 realizations of an MA(1) process for 100 time periods
with the following specification:
Yt = 0.5εt−1 + εt
Plot the autocorrelation function (ACF) for one of the realizations (Y1). What is the
theoretical autocorrelation at lag 1, and how does the sample ACF compare?
The autocorrelation at lag 1 for an MA(1) process is the coefficient of ϵt−1which in this case is
0.5. For higher lags (lag>1), the theoretical ACF is 0.
Q.7 In Stata, simulate 50 realizations of an MA(2) process for 100 time periods using
the following specification:
Yt = 1.5εt−1 + 0.3εt−2 + εt
Generate the ACF for one realization (Y1) with 10 lags. How do the sample
autocorrelations behave, and how does this differ from an MA(1) process?
Behavior of Sample ACF:
● The sample autocorrelations for lag 1 and lag 2 in the plot are clearly non-zero, reflecting
the influence of the coefficients θ1=1.5\theta_1 = 1.5θ1=1.5 and θ2=0.3\theta_2 =
0.3θ2=0.3 in the MA(2) process.
● For higher lags (lag 3 onward), the sample ACF values fluctuate around zero, as
expected for an MA(2) process where autocorrelations drop to zero beyond the process
order.
Comparison to MA(1):
● In an MA(1) process, only the lag 1 autocorrelation is non-zero, while all higher lags (lag
2 onward) are zero. In contrast, the MA(2) process introduces a second non-zero
autocorrelation at lag 2.
● The shape of the ACF in an MA(2) process declines more gradually compared to an
MA(1), as there are two significant lags influencing the series.
Q.8 Simulate an MA(1) process for 50 realizations with 10,000 time periodsusing the
specification:
Yt = 0.5εt−1 + εt
Compare the autocorrelations at lag 1 for simulations with 100 observations
and10,000 observations. How does increasing the sample size affect the accuracy of
the estimated autocorrelation, and why?
increasing the sample size leads to more precise and stable estimates of autocorrelation,
aligning the sample ACF more closely with the theoretical values.
Q.9 Simulate a random walk without drift using Stata. Illustrate how the
Dickey-Fuller test results change when you include or exclude a constant and lags.
Simple dfuller without lags ignores autocorrelation in the data and hence again results are
unreliable
Optimal lag length is 1
Q.10 Select a time series dataset of your choice (e.g., stock prices, exchange rates,
commodity prices, or economic indicators from reliable databases, with a minimum
of 50 time periods) and apply ARIMA modeling to it. Follow the steps below to
complete the assignment:
[a] Plot the time series data.
We’ve used the data SP 500 for the analysis
Fluctuations throughout the series, particularly in the middle and end periods. Some recovery in
prices toward the end.
[b] Test the series for stationarity using appropriate tests (e.g., ADF or KPSS).
H0: Series has a unit root
H1: Series is stationary
Since the test statistic is less than the critical value. Thus, we fail to reject the null
hypothesis saying that the series has a unit root.
The optimal lag length is 1.
As the test statistics is less than the critical value. Thus, we fail to reject the null hypothesis
concluding that the series has a unit root. We’ll now check for the trend in the series.
The p-value of the trend variable is greater than the level of significance (0.05). Thus, there is
no significant trend in the model.
H0: Series has a unit root
H1: Series is stationary
Phillips-Perron test for checking the presence of the unit root, meaning they are used to test
stationary. Since the test statistic for Z(rho) and Z(t) is less than the critical value. Thus, we fail
to reject the hypothesis which implies that the series has a unit root.
H0: Series is stationary
H1: Series is not stationary
As the test statistic is greater than the critical values. Thus, we reject the null hypothesis stating
that the series is not stationary.
[c] If the series is non-stationary, apply differencing and check for stationarity
again.
As the series is non-stationary. Therefore, we’ll apply differencing
After first differencing the optimal lag length is 0.
H0: Series has a unit root
H1: Series is stationary
As the test statistic is greater than the critical value. Therefore, we reject the null hypothesis
concluding that the series is stationary.
H0: Series has a unit root
H1: Series is stationary
The Phillips-Perron test also provides us with the same conclusion that the series is
stationary as both Z(rho) and Z(t) test statistics are greater than the critical values.
H0: Series is stationary
H1: Series is not stationary
Since the test stat values are less than the critical value up to several lags. Thus, we fail to
reject the null hypothesis highlighting that the series is stationary.
[d] Based on the ACF and PACF plots, identify potential ARIMA models.
We have the two ACF plots. The left plot is of the series before differencing showing that the
series is non-stationary while the right plot is of the series after differencing which highlights that
the series has turned out to be stationary after first differencing.
The original series (on right) is non-stationary, as indicated by the strong autocorrelation at lag
1 in the PACF. While the differenced series (on left) is likely stationary, with minimal partial
autocorrelation beyond lag 1.
[e] Estimate several ARIMA models, and select the best model using information
criteria such as AIC or SBIC.
ARIMA(0,1,1)
ARIMA(1,1,1)
ARIMA(1,1,0)
ARIMA(0,1,2)
ARIMA(2,1,2)
We’ll select the model with the most significant coefficients, lowest volatility, maximum
log-likelihood, and the lowest SBIC. Here Arima (0,1,1) seems the most appropriate.
[f] Perform diagnostic checks on the residuals to ensure they are white noise.
The Correlogram shows that most ACs are statistically not different from zero because they
lie in the shaded region.
[g] Use the chosen ARIMA model to forecast future values of the time series and
plot the actual vs. predicted values.