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
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
In this exercise you will write your custom function which accepts a vector of dependent variables and a matrix of regressors and computes the OLS estimator as well as its standard error.
Write a function which accepts a vector y
and a matrix X
(without the column of ones) as inputs and which returns a matrix where the first row carries the estimated regression coefficients and the second row carries their standard errors.
Check your function works appropriately by comparing to MATLAB's regress
function.
Extension 1 - Constant in the regression: Extend the function to accept a boolean argument constant
which determines whether a constant should be included in the regression.
Extension 2 - Using structure array objects to return estimated values): Read the MATLAB reference page on structure arrays to learn about struct
objects. Modify your OLS function such that it returns a struct object estimates
with sub-objects estimates.params
and estimates.se
which contain the parameter estimates and standard errors, respectively.
Let be a vector of data on the dependent variable and let be a matrix with data on the regressors (where the first column is a vector of ones).
The OLS estimator of the regression coefficients is defined as.
Under the assumption of spherical errors, and estimate of the variance-covariance matrix of the estimator can be obtained as
where
In this exercise you will simulate a capital evolution in a simple canonical OLG model.
Tip: Create a vector of zeros of appropriate size, then loop through the elements of the vector and fill in the values of capital per worker.
When you have finished you can plot the resulting vector with the command plot(k)
where k
is the vector holding the evolution of capital. How many periods does it take the economy to reach its steady state (i.e. capital per worker does not change anymore)? Now try out to simulate the economy for different parameter values. Does a steady state exist and how long does it take to get there?
In the canonical overlapping-generations (OLG) model, the evolution of the capital stock per worker is described by the following law of motion.
In this exercise you will implement a simple algorithm to find the minimum of a non-differentiable function by bisection minimization.
Here is a plot of this function with the respective minimum
Now two cases are possible
The standard errors of the elements of are defined as the square root of the diagonal elements of .
Write a script that calculates a vector that contains the evolution of capital for periods when initial capital per worker is for the following parameter values.
We would like to store the values of for in a vector. Initialise the vector at the beginning of your code by creating a vector of NaN
or zero
values.
Think about how you can use a loop to calculate the values of iteratively. How does this loop look like? Where does it start and where does it end. How do you save a single value that you computed for in the vector you created in the step before?
where is the capital per worker, is the population growth rate, is the discount factor, is the capital share in the production function and is the TFP parameter from the production function.
Code up the algorithm that is described in the theory section below to find the minimum of on the interval .
Tips: Use a while loop which iterates on the algorithm steps 1-4 until convergence is achieved. Use variables to keep track of the old and new candidate values for .
In this exercise, you will find the minimum of the following non-differentiable function on the interval .
To find the minimum of on the interval, use the following algorithm:
Pick the point in the middle of the interval . This splits the interval into two intervals, the left interval and the right interval
In each half, pick as a candidate for a minimum and as the middle point of the respective interval
Evaluate and
(a) If i.e. the minimizer is in the right interval. If this is true, set the new interval equal to the right interval.
(b) If , the minimizer is in the left interval. If this is true, set the new interval equal to the left interval.
Using the new interval , repeat steps 1-4 until the absolute difference between the new and old candidate is smaller than 1e-5
.
Parameter
Value
4
0.4
0.9
0.02