๐ŸŒ Week 5 Homework โ€” Feedback

Student: Klea Lushaj
Assignment: Solving Nonlinear Equations in Economics


โœ… Overall Assessment

Result: โœ… More than 50% Correct

The student demonstrates understanding of numerical methods and submits all three exercises with detailed output and discussion. Exercise 1 IS-LM implementation has a minor LM equation sign issue and plotting range cuts off the positive interest rate equilibrium (plots Y only up to 700). Exercise 2 has issues with the Z(h) function implementation and likely produces incorrect results. Exercise 3 is implemented correctly with appropriate bisection and damped Newton methods and includes detailed analysis. The code structure is good with clear separation into three files.


๐Ÿ” Task-by-Task Check

Task Description Status Notes ย  ย 
1.1 Parameter setup for IS-LM โœ… All parameters correctly defined ย  ย 
1.2 IS-LM system definition โš ๏ธ System formulation has wrong sign on LM equation ย  ย 
1.3 Solve from two initial guesses โœ… Two guesses provided (x0_1=[500;5], x0_2=[400;10]) ย  ย 
1.4 Plot IS and LM curves โš ๏ธ Creates plot but Y range [300,700] cuts off positive solution ย  ย 
1.5 Verify positive interest rate โœ… Verifies positive interest rate ย  ย 
2.1 Parameter setup for labor supply โœ… All parameters correctly defined ย  ย 
2.2 Define Z(h) function โš ๏ธ Function has potential issues with vectorization ย  ย 
2.3 Loop over sigma values โœ… Correctly loops over sigma โˆˆ {1,2,3,4,5} ย  ย 
2.4 Solve using Bisection method โœ… Implements bisection correctly with sophisticated corner solution detection (chooses boundary with smaller Z )
2.5 Plot h*(sigma) and interpret โš ๏ธ Creates plot but shows incorrect results (you noted โ€œex 2 seems wrongโ€) ย  ย 
3.1 Implement Bisection method โœ… Correct bisection implementation ย  ย 
3.2 Implement Damped Newton method โœ… Implements damped Newton with alpha=0.5 and analytical derivative ย  ย 
3.3 Test from multiple starting guesses โœ… Tests from three guesses (0.2, 0.5, 0.8) ย  ย 
3.4 Record iterations and residuals โœ… Records and displays all iterations and residuals in table ย  ย 
3.5 Compare and discuss convergence โœ… Provides detailed discussion and visualization of convergence ย  ย 

๐Ÿ“ˆ Technical Implementation

  • IS-LM System: โš ๏ธ LM equation has wrong sign: MP - k*x(1) + lambda*x(2)] should be MP - k*x(1) + lambda*x(2) or MP - (k*x(1) - lambda*x(2))
  • Labor Supply Function: Function definition may have issues with vectorization
  • Bisection Method: Correct implementation with proper sign change logic (< 0)
  • Corner Solutions: โœ… Excellent - Sophisticated corner solution detection that identifies which boundary (h=0 or h=1) is closer to being a root by comparing Z(a) vs Z(b)
  • Damped Newton: Correct implementation with alpha=0.5 and analytical derivative
  • Error Handling: Includes sign change checks, proper bounds handling, and advanced corner solution diagnostics
  • Figure Management: โœ… Saves figures as PNG files
  • Advanced Features: Includes detailed discussion, interpretation, visualization of convergence comparison, and comprehensive corner solution reporting

๐Ÿ’ฌ Style & Clarity

  • Code Quality: Good structure with clear separation into three files (exone.m, extwo.m, exthree.m)
  • Variable Naming: Clear names (h_star, sigma_values, x_star_1)
  • Comments: Good comments explaining methodology
  • Output: Appropriate use of fprintf with detailed tables and analysis
  • Organization: Clear separation into three exercises in separate files

๐Ÿ“Š Visual Output Assessment

Figure 1: IS-LM Equilibrium โš ๏ธ

  • Layout: Plot with IS and LM curves and equilibrium point
  • Features: Shows both positive and negative interest rate branches
  • Styling: Appropriate styling with proper labels and legend
  • Saving: โœ… Saves as PNG file (Figurex1.png)
  • Issue: Your note: โ€œAlthough she plots Y up to 700 so missing the positive solution for iโ€ - the plotting range is too narrow

Figure 2: Labor Supply h*(ฯƒ) โŒ

  • Layout: Plot showing h* vs sigma values
  • Features: Shows labor supply for different risk aversion parameters
  • Styling: Appropriate styling with proper labels and value annotations
  • Saving: โœ… Saves as PNG file (Figurex2.png)
  • Issue: Your note: โ€œEx 2 seems wrongโ€ - the plot shows incorrect results

Figure 3: Convergence Comparison โœ…

  • Layout: Plot comparing iteration counts between methods
  • Features: Shows bisection vs Newton for different starting guesses
  • Styling: Appropriate styling with proper labels and annotations
  • Saving: โœ… Saves as PNG file (Figurex3.png)
  • Quality: Good visualization of convergence comparison

โœ… Suggestions for Improvement

  1. Critical: Fix Exercise 1 LM equation sign - should be MP - (k*x(1) - lambda*x(2)) not MP - k*x(1) + lambda*x(2)
  2. Critical: Expand Exercise 1 plotting range to Y up to 900 or 1000 to show the positive interest rate equilibrium
  3. Critical: Check Exercise 2 Z(h) function definition - there may be issues with the formulation
  4. Important: Verify that Exercise 2 results are economically reasonable (h* should be in [0,1])
  5. Style: The code uses sigma=1 in Exercise 3 instead of sigma=2 as intended
  6. Verification: Run Exercise 2 with correct Z(h) function to verify results

๐ŸŽฏ Summary

Good submission with minor errors. The student demonstrates understanding of numerical methods and implements all three exercises with detailed output and discussion. Exercise 1 has a minor LM equation sign issue and plotting range issue. Exercise 2 shows incorrect results likely due to problems with the Z(h) function. Exercise 3 is implemented correctly with proper comparison between bisection and damped Newton methods, including visualization and detailed discussion. The code is well-organized with clear separation into three files and comprehensive output.

Grade Level: โœ… More than 50% Correct (10/15 tasks fully correct, 4/15 partially correct, 1/15 incorrect)