Feedback on Week 9 Homework: Numerical Approximation & Simulation

Student: Lorenzo Ilari Assignment: Week 9 - Monte Carlo OLS & Numerical Integration

Overall Assessment

Grade: ✅ (Pass)

Your submission is good and covers most of the requirements. The Monte Carlo simulation part is well-executed. In the numerical integration part, there is a technical issue with the implementation of Simpson’s rule regarding the number of grid points, and the convergence plot is missing.

Task-by-Task Check

Part 1: Monte Carlo OLS

  1. Function Definition: ✅ montecarlo_ols is correctly defined.
  2. DGP Logic: ✅ Correct generation of random variables inside the replication loop.
  3. OLS Logic: ✅ regress is used correctly.
  4. Execution: ✅ Loops over sample sizes correctly.
  5. Visuals: ✅ Histograms with normal fits are generated correctly.
  6. Statistics: ✅ Empirical mean and variance are calculated and printed.
  7. Interpretation: ✅ (Implicit in the printed results).

Part 2: Numerical Integration

  1. Utility Function: ✅ CRRA utility correctly defined.
  2. Trapezoidal Rule: ✅ Correctly implemented using trapz.
  3. Simpson’s Rule: ⚠️ Parity Issue. Simpson’s 1/3 rule requires an odd number of grid points (which corresponds to an even number of intervals). You used $N \in {50, 200, 1000}$, which are even. Your formula (h/3) * (uc(1) + 4*sum(...) + 2*sum(...) + uc(end)) implicitly skips the second-to-last point (index $N-1$) when $N$ is even, leading to an incorrect calculation.
  4. Grid Loop: ✅ Integration performed over grid sizes.
  5. Visuals: ⚠️ Missing Convergence Plot. You plotted the utility function $u(c)$ itself, but the assignment asked for a plot of the integral value (or error) vs. $N$ to visualize convergence.
  6. Interpretation: ✅ (Implicit in results table).

Technical Implementation

  • Code Organization: Clean and logical.
  • Simpson’s Rule: To fix the parity issue, you should either choose odd $N$ (e.g., 51, 201) or add a check to remove the last point if $N$ is even (e.g., if mod(N,2)==0, N=N-1; end).

Style & Clarity

  • Output: Results are displayed clearly in the command window.
  • Comments: Code is readable.

Suggestions for Improvement

  1. Check Assumptions: When using numerical formulas like Simpson’s rule, always verify the requirements (like odd/even points) against your input parameters.
  2. Visualizing Results: Plotting the final results (the integrals) against the parameter ($N$) provides more insight into the method’s performance than plotting the function itself.

Summary

You have a solid handle on the simulation and basic integration logic. Paying closer attention to the specific constraints of numerical algorithms (like Simpson’s rule parity) will improve the accuracy of your work.

Tasks Correct: 11/13