Week 9
Week 9 – Numerical Approximation & Simulation
Learning Outcomes
By the end of this week, students will be able to:
- Implement numerical differentiation and integration in MATLAB.
- Understand and use MATLAB’s random number generation functions.
- Apply Monte Carlo simulation techniques to economic problems.
- Simulate sampling distributions of estimators.
- Interpret simulation results in the context of econometric inference.
Suggested Readings
- Greenwood & Marto, Numerical Methods for Macroeconomists, Ch. 8 (Numerical approximation).
In-Class Activities
- Numerical differentiation: Forward, backward, and central differences for a Cobb–Douglas production function.
- Numerical integration: Trapezoidal and Simpson’s rule to compute present value of a stream of income.
- Random number generation: Draw samples from uniform and normal distributions; set seeds for reproducibility.
- Monte Carlo simulation:
- Generate repeated samples from a simple regression model ( y = \beta_0 + \beta_1 x + u ).
- Estimate OLS coefficients in each sample.
- Plot the sampling distribution of ( \hat{\beta}_1 ) and compare to the theoretical distribution.
Homework / Practice
- Write a function
montecarlo_olsthat:- Takes sample size
n, number of replicationsR, and true parameters as inputs. - Returns the simulated sampling distribution of the slope coefficient.
- Takes sample size
- Use the function to investigate how increasing
nchanges the sampling distribution’s variance. - Numerically integrate a CRRA utility function over a given consumption range and compare results from trapezoidal and Simpson’s rules.
Files
- Slides Week 9 – Slides from lecture.
- codes_week9 on Matlab online
- week9.m – Example script from lecture.
- week9_homework_solution.m – Solution file for the homework.
- week9_challenge_solution.m – Solution file for the in class challenge.
Homework submission
- Submit your homework here
- Please upload your homework as a single zip file. Access it’s now open with any email address! But remember to name your file with your full name and or student ID.
- The submission should include the .m file used to produce the results.
- You can modify you submission until the beginning of week 10.