Applied Exercises
This section provides some exercises that are meant to deepen your knowledge in the topics covered in this section and to gain experience solving real-world problems.
Last updated
Was this helpful?
This section provides some exercises that are meant to deepen your knowledge in the topics covered in this section and to gain experience solving real-world problems.
Last updated
Was this helpful?
In this exercise you will simulate a density forecast from a simple AR(1) model.
Using an AR(1) model (see below) and assuming that and , simulate 1000 paths for the process, 20 periods into the future, assuming that the error term is iid .
Using the prctile
function, find the median path for the process.
Create a plot over time of the median path and the and percentiles of the forecast "distribution".
To forecast from an AR(1) model, in general we need to know the parameter values and the last value of the process, . We can then construct the forecast for time as
We can then use the forecasted value for to create a forecast for .
Note that above the error term is ignored as where is the information set at time . We can however use Monte Carlo simulation to incorporate the uncertainty inherent in the model and get a "distribution" of forecasts.
In this exercise you will write a Monte-Carlo simulation to answer a simple question on probabilities.
Write a script that performs a Monte Carlo simulation to find the probability that the sum of the numbers coming up on two (fair) dice is equal to 6.
Perform the simulation 10, 100, 1000, 10,000 times and compare the results to the theoretical answer.
In this exercise you will simulate the large-sample distribution of the OLS estimator.
For each replication, estimate the OLS coefficients, the variance of the error term, and the variance of the OLS coefficients.
Run the following experiments
Check that the OLS estimate has the right mean, i.e. compare the mean of the estimated coefficients to the true coefficients.
Check that the variance of the OLS coefficients is correctly estimated, i.e., compare your estimate to the covariance of the coefficient estimates using the cov
function.
Write a Monte Carlo simulation to explore these large sample properties. Assume that the true model is , where and and
. Let the sample size be 50 and set the number of replications to 2000.
Create the data sets assuming that the regressors are iid
Check that the OLS estimator has the right distribution: Compare the CDF of the normalized estimate of to the CDF of the standard normal distribution
From standard asymptotic theory we know that the OLS estimator is normally distributed with mean equal to the true coefficients and covariance equal to .