Week 9 Homework Feedback: Davide Magnini

Assignment: “Week 9: Monte Carlo OLS & Numerical Integration”

Overall Assessment

Grade: ✅ (Pass)

The submission is well-structured, utilizing MATLAB tables for storing results and saving figures correctly to a dedicated folder. The Monte Carlo simulation is implemented correctly. For the numerical integration, the methods are implemented, but the manual Simpson’s rule implementation suffers from the even/odd grid size issue common to this assignment. This likely explains the observation that Trapezoidal was “more accurate” (mathematically, Simpson’s rule is more accurate for smooth functions, provided the grid parity is handled correctly).

Task-by-Task Check

Part 1: Monte Carlo OLS

  1. Function Definition: ✅ montecarlo_ols is correctly defined in a separate file with all parameters (including sigma).
  2. DGP Logic: ✅ Correct generation of $x$ and $u$.
  3. OLS Logic: ✅ Correct.
  4. Execution: ✅ Loops over $n \in {20, 50, 200}$ with $R=2000$.
  5. Visuals: ✅ Nice histograms with normal overlays, saved to Figures/.
  6. Statistics: ✅ Mean and variance computed and stored in tables.
  7. Interpretation: ✅ Good observations in the comments about accuracy increasing with $N$.

Part 2: Numerical Integration

  1. Utility Function: ✅ CRRA with $\gamma=2$ correctly defined.
  2. Trapezoidal Rule: ✅ Correct use of trapz.
  3. Simpson’s Rule: ⚠️ Partial. You implemented the standard formula, but you applied it to even grid sizes ($N=50, 200, 1000$). Standard Simpson’s rule requires an odd number of points (even number of intervals). With an even number of points, your formula implicitly ignores one of the points near the end of the grid, degrading accuracy.
  4. Grid Loop: ✅ Correct loop.
  5. Visuals: ✅ Convergence plot including the exact reference line.
  6. Interpretation: ⚠️ Partial. You correctly noted that Trapezoidal seemed better in your results, but this is actually a symptom of the Simpson implementation bug (parity issue) rather than a property of the methods. Usually, Simpson’s rule converges much faster ($O(h^4)$) compared to Trapezoidal ($O(h^2)$).

Technical Implementation

  • Code Organization: Good. Use of tables is noted.
  • Figures: Correctly saved to Figures/ folder.
  • Documentation: Good comments explaining the code.

Suggestions for Improvement

  1. Fix Simpson’s Rule: Check if N is even. If so, either use c(1:end-1) (making the grid odd) or handle the last interval separately. This will restore the $O(h^4)$ accuracy of Simpson’s rule and likely flip your conclusion about which method is better!

Summary

11/13 tasks correct. A high-quality submission. Fixing the Simpson’s rule parity logic would demonstrate the accuracy of higher-order integration methods.