Feedback on Week 9 Homework: Numerical Approximation & Simulation

Student: Sebastiano Bacchi Assignment: Week 9 - Monte Carlo OLS & Numerical Integration

Overall Assessment

Grade: ✅ (Pass)

Your submission is excellent. You have correctly implemented all parts of the assignment. Your solution for the Simpson’s rule parity requirement—choosing odd numbers for $N$ directly—was a clever and valid approach to avoid grid adjustment logic.

Task-by-Task Check

Part 1: Monte Carlo OLS

  1. Function Definition: ✅ montecarlo_ols is correctly defined.
  2. DGP Logic: ✅ The Data Generating Process correctly generates random variables inside the loop.
  3. OLS Logic: ✅ regress is used correctly.
  4. Execution: ✅ The script iterates over the required sample sizes.
  5. Visuals: ✅ Histograms are generated, saved, and even compared in a combined plot.
  6. Statistics: ✅ Empirical moments are calculated and displayed in a table.
  7. Interpretation: ✅ Correct interpretation of unbiasedness and consistency.

Part 2: Numerical Integration

  1. Utility Function: ✅ CRRA utility correctly defined.
  2. Trapezoidal Rule: ✅ Correctly implemented using trapz.
  3. Simpson’s Rule: ✅ Correctly implemented. You used $N \in {49, 199, 999, \dots}$ which ensures an odd number of grid points (even number of intervals), satisfying the requirement for Simpson’s 1/3 rule without needing conditional logic.
  4. Grid Loop: ✅ The integration is performed over the grid sizes.
  5. Visuals: ✅ A clear convergence plot is generated and saved.
  6. Interpretation: ✅ Good comparison of the convergence speed of the two methods.

Technical Implementation

  • Code Organization: Very clean and modular. The use of addpath is good practice.
  • RNG Placement: You placed rng(123) inside the montecarlo_ols function. While this ensures the exact same numbers for every call (which might be intended for debugging), strictly speaking, a Monte Carlo simulation usually sets the seed once outside the function so that repeated calls generate different independent samples. However, for this exercise, it does not invalidate the results.
  • Visuals: The combined histograms and convergence plots are well-designed.

Style & Clarity

  • Formatting: The use of table for displaying results is professional.
  • Comments: The code is well-commented and easy to follow.

Suggestions for Improvement

  1. RNG Scope: Consider moving rng(123) to the main script rather than inside the function, unless you specifically want every call to montecarlo_ols to produce identical output.

Summary

This is a strong submission. You solved the technical challenges effectively and presented the results with high-quality visuals and formatting.

Tasks Correct: 13/13