Feedback on Week 9 Homework: Numerical Approximation & Simulation

Student: Sofia Bruga Assignment: Week 9 - Monte Carlo OLS & Numerical Integration

Overall Assessment

Grade: ✅ (Pass)

Your submission is very good. You have successfully implemented the Monte Carlo simulation for OLS and the Numerical Integration of the CRRA utility function. Your implementation of Simpson’s rule is particularly noteworthy for correctly handling the grid parity issue.

Task-by-Task Check

Part 1: Monte Carlo OLS

  1. Function Definition: ✅ montecarlo_ols is correctly defined with appropriate inputs and outputs.
  2. DGP Logic: ✅ The Data Generating Process correctly generates $x$ and $u$ using randn inside the replication loop.
  3. OLS Logic: ✅ The OLS estimator is correctly calculated.
  4. Execution: ✅ The script iterates over the required sample sizes ($n \in {20, 50, 200}$).
  5. Visuals: ✅ Histograms are generated and saved for each sample size.
  6. Statistics: ✅ Empirical mean and variance are calculated and printed.
  7. Interpretation: ✅ You correctly identify the consistency of the OLS estimator (variance decreases as $n$ increases).

Part 2: Numerical Integration

  1. Utility Function: ✅ The CRRA utility function is correctly defined with $\gamma=2$.
  2. Trapezoidal Rule: ✅ Correctly implemented using trapz.
  3. Simpson’s Rule: ✅ Excellent implementation. You explicitly check for even $N$ (mod(N,2) == 0) and adjust the grid by removing the last point to ensure an odd number of points (even intervals) before applying the formula. This is the correct way to handle this constraint.
  4. Grid Loop: ✅ The integration is performed over the specified grid sizes.
  5. Visuals: ⚠️ Missing. You generated histograms for Part 1 but did not include a convergence plot for Part 2 (Integral Value vs $N$) to visualize how the two methods approach the true value.
  6. Interpretation: ✅ You provided a correct comparison of the two methods.

Technical Implementation

  • Code Organization: Good structure with a main script and a local function.
  • Simpson’s Rule: Correctly handled the requirement for an odd number of grid points.
  • Figure Management: Figures are saved correctly to a folder.

Style & Clarity

  • Variable Naming: Clear and descriptive.
  • Output: Results are printed clearly to the command window.

Suggestions for Improvement

  1. Convergence Plot: In numerical exercises, it is standard to plot the error or the value of the approximation against $N$ (or $1/N$) to visually demonstrate convergence rates.
  2. Documentation: Adding a header to your function with a brief description of inputs and outputs is a good practice (which you did well in the main script).

Summary

You demonstrated a solid understanding of the numerical methods. Your handling of Simpson’s rule parity shows good attention to detail. The only missing element was the convergence plot for the integration part.

Tasks Correct: 12/13