Feedback on Week 9 Homework: Numerical Approximation & Simulation
Feedback on Week 9 Homework: Numerical Approximation & Simulation
Student: Kamila Murzabulatova Assignment: Week 9 - Monte Carlo OLS & Numerical Integration
Overall Assessment
Grade: ✅ (Pass)
Your submission is excellent. You went beyond the basic requirements by calculating the coverage probability for the OLS confidence intervals, which demonstrates a deeper understanding of the statistical concepts. Your handling of the Simpson’s rule parity issue by adjusting the grid size is also a valid and practical solution.
Task-by-Task Check
Part 1: Monte Carlo OLS
- Function Definition: ✅
montecarlo_olsis correctly defined. - DGP Logic: ✅ Data generation is correct.
- OLS Logic: ✅ You used the normal equations
(X'*X)\(X'*y)correctly. - Execution: ✅ Loops over sample sizes.
- Visuals: ✅ Histograms with normal approximation are correctly generated.
- Statistics: ✅ Empirical mean and variance calculated.
- Interpretation: ✅ (Implicit in results). The addition of the coverage probability calculation is a great touch.
Part 2: Numerical Integration
- Utility Function: ✅ CRRA utility correctly defined.
- Trapezoidal Rule: ✅ Correctly implemented using
trapz. - Simpson’s Rule: ✅ Correctly handled. You identified that Simpson’s rule requires an odd number of points. Your solution to increase $N$ by 1 (
N2 = N + 1) when $N$ is even allows you to apply the rule correctly. - Grid Loop: ✅ Integration performed over grid sizes.
- Visuals: ✅ Convergence plot (integral values vs $N$) is included.
- Interpretation: ✅ Good comparison.
Technical Implementation
- Code Structure: Clean and organized.
- Struct for Results: Storing results in a structure array
results(i)is a very good coding practice for managing simulation data.
Style & Clarity
- Output: The formatted output for coverage and variance is very clear.
- Comments: Code is well-commented.
Suggestions for Improvement
- RNG Placement: Similar to other feedback, placing
rng(123)inside the function fixes the seed for every call, which technically means you aren’t getting new random numbers if you were to call it multiple times in the same script (though for this specific loop structure it doesn’t matter since you call it once per $N$). Moving it to the main script is generally safer.
Summary
A high-quality submission that demonstrates strong coding skills and statistical understanding.
Tasks Correct: 13/13