🌍 Week 4 Homework β€” Feedback

Student: Lorenzo Ilari
Assignment: Extended IS–LM and Cholesky Decomposition


βœ… Overall Assessment

Result: βœ… More than 50% Correct

The student demonstrates good code organization and implements most components correctly with advanced features like vectorized computation. The A matrix is correct, but there is a critical sign error in the b vector construction (-MP + theta*G instead of MP - theta*G). The Cholesky decomposition and stochastic simulation are implemented correctly with efficient matrix operations.


πŸ” Task-by-Task Check

Task Description Status Notes
1 Parameter setup & system definition ❌ Correct A matrix: [1, alpha; -beta, gamma] is correct! Critical Error: b vector uses -MP + theta*G instead of MP - theta*G.
2 Equilibrium solution ⚠️ Solves system correctly using A\b, extracts Y and i correctly, includes comparison with inv(A)*b, but results reflect wrong b vector sign.
3 Comparative statics setup βœ… Correctly creates G grid using linspace(G-50, G+50, 201), uses vectorized computation A \ b_grid, and stores results efficiently.
4 Plotting comparative statics βœ… Creates proper separate plots for Y vs G and i vs G, good styling, proper labels, and titles. No figure saving in code.
5 Cholesky decomposition βœ… Correctly defines Sigma matrix [4, 1.2; 1.2, 3], computes eigenvalues, computes L using chol(Sigma, 'lower'), and verifies reconstruction.
6 Stochastic simulation setup βœ… Correctly generates u ~ N(0,I) with proper dimensions (2Γ—10000), uses efficient AinvL = A \ L, and sets random seed (123).
7 Equilibrium distribution analysis βœ… Correctly computes empirical means and covariances using mean(X, 1) and cov(X). Results based on wrong underlying system but method is correct.
8 Visualization of stochastic results βœ… Creates scatter plot correctly with proper labels, styling, and small markers. No figure saving in code.

πŸ“ˆ Technical Implementation

  • Correct A Matrix: [1, alpha; -beta, gamma] is actually correct! (One of the few students who got this right)
  • Critical b Vector Error: Uses -MP + theta*G instead of MP - theta*G (sign error)
  • Code Structure: Excellent organization with clear sections and efficient computation
  • Numerical Methods: Uses correct A\b method and includes comparison with inv(A)*b
  • G Grid: Uses linspace(G-50, G+50, 201) which is economically reasonable
  • Figure Management: Missing saveas() commands in code
  • Advanced Features: Uses vectorized computation A \ b_grid and efficient AinvL = A \ L
  • Simulation Size: Uses 10000 simulations (correct)
  • Efficient Computation: Uses AinvL * U for efficient matrix operations

πŸ’¬ Style & Clarity

  • Code Quality: Excellent structure with clear section headers and efficient computation
  • Variable Naming: Logical names (Y_grid, i_grid, mu_Yandi, cov_X)
  • Comments: Good comments explaining key operations
  • Output: Excellent use of disp for displaying results
  • Organization: Clear separation into logical sections with proper headers
  • Advanced: Includes efficient vectorized computation and matrix operations

πŸ“Š Visual Output Assessment

Please remember to save the figures in the Figures folder!

Figure 1: Y vs G ⚠️

  • Layout: Separate plot for Y vs G
  • Relationships: Shows relationships, but based on wrong b vector sign
  • Labels: Proper axis labels and title
  • Styling: Good styling with grid
  • Saving: No figure saving in code
  • Issue: Wrong relationships due to b vector sign error

Figure 2: i vs G ⚠️

  • Layout: Separate plot for i vs G
  • Relationships: Shows relationships, but based on wrong b vector sign
  • Labels: Proper axis labels and title
  • Styling: Good styling with grid
  • Saving: No figure saving in code
  • Issue: Wrong relationships due to b vector sign error

Figure 3: Scatter Plot ⚠️

  • Distribution: Scatter plot showing correlated shocks
  • Correlation: Shows correlation structure correctly
  • Styling: Good use of small filled markers
  • Saving: No figure saving in code
  • Issue: Results based on incorrect underlying system due to b vector sign error

βœ… Suggestions for Improvement

  1. Critical: Fix b vector to [Abar + bG*G; MP - theta*G] instead of [Abar + bG*G; -MP + theta*G]
  2. Important: Add saveas() commands to save figures automatically
  3. Style: Consider using subplots for comparative statics to match solution format
  4. Verification: Check that results are economically reasonable
  5. Advanced: Consider adding theoretical vs empirical covariance comparison

🎯 Summary

Good implementation with critical sign error. The student demonstrates good programming skills, efficient computation, and proper matrix operations. However, the wrong sign in the b vector prevents correct economic interpretation of the IS-LM system. Notably, this student got the A matrix correct and used advanced vectorized computation.

Grade Level: βœ… More than 50% Correct (6/8 tasks fully correct, 1/8 partially correct, 1/8 incorrect)