🌍 Week 6 Homework — Feedback

Student: Ignazio Nunzi
Assignment: Solow Model Calibration: Grid Search vs Optimization Tools


✅ Overall Assessment

Result:More than 50% Correct

Comprehensive submission with all three optimization methods correctly implemented and excellent code organization. Includes bonus bootstrap analysis demonstrating advanced understanding. However, two required elements are missing: (1) No timing measurements (tic/toc) for comparing computation speeds, and (2) Missing comparison comments discussing speed, robustness, and similarity of results. The code structure is excellent with multiple figures and a summary table comparing all three methods.


🔍 Task-by-Task Check

Task Description Status Notes
1.1 Parameter structure setup All parameters correctly defined (alpha, delta, n, g, A0, K0)
1.2 Data generation or loading Synthetic data with noise correctly generated
2.1 Objective function definition Correct: sum((solow_simulate(s, params, T) - y_data).^2)
3.1 Create grid s ∈ [0.05, 0.5] Grid created with 200 points using linspace
3.2 Compute SSE for each grid point Uses arrayfun() correctly to compute SSE for all grid points
3.3 Find minimum and extract s_hat_grid Correctly finds minimum using min() and extracts value
4.1 Implement sigmoid function Correct: sigmoid = @(x) 1./(1 + exp(-x))
4.2 Create objective wrapper Correct: obj_x = @(x) obj(sigmoid(x))
4.3 Call fminsearch and convert result Correctly calls fminsearch and converts x back to s using sigmoid
5.1 Set bounds [0, 1] correctly Bounds set to [0.001, 0.999] (acceptable, slightly tighter than [0,1])
5.2 Call fmincon with proper syntax fmincon correctly called with proper syntax and options
6.1 Display computation times Missing: No tic/toc measurements for any method
6.2 Display optimization results Excellent - displays results table comparing all three methods with SSE values
6.3 Comment comparing methods Missing: No written comparison comments (2-3 lines) discussing speed, robustness, similarity
7.1 Plot objective with all three optima Final plot (lines 264-296) correctly shows all three optima with different markers/colors
7.2 Plot model fit (data vs model) Multiple plots showing data vs fitted model for all three methods
7.3 Save figures in Figures/ folder Figures correctly saved in PNG format

📈 Technical Implementation

  • Grid Search: Correctly implemented using arrayfun() for efficient computation
  • fminsearch with Sigmoid: Properly reparameterized using sigmoid function
  • fmincon with Bounds: Correctly implemented with proper options and bounds
  • Helper Function: solow_simulate() correctly implements Solow dynamics
  • Objective Function: Correct SSE formulation in multiple places
  • Error Handling: Includes try-catch for bootstrap iterations
  • Figure Management: Creates multiple figures for different comparisons
  • Advanced Features: ✅ Excellent - Includes bonus bootstrap analysis (1000 draws) with confidence intervals, growth rate comparison, and comprehensive results table

💬 Style & Clarity

  • Code Quality: Excellent organization with clear sections and labeled steps
  • Variable Naming: Clear and descriptive (s_hat_grid, s_hat_fminsearch, s_hat_fmincon)
  • Comments: Good documentation with section headers and explanations
  • Output: Uses fprintf and table display for clear results presentation
  • Organization: Well-structured with numbered steps matching homework requirements
  • Documentation: Includes comments explaining bootstrap methodology

📊 Visual Output Assessment

Figure 1: Objective Function with All Three Optima ✅

  • Layout: Plot showing SSE vs s with all three optima marked
  • Features: Shows grid search (red circle), fminsearch (magenta diamond), fmincon (green square), and true s (black triangle)
  • Styling: Good styling with proper labels, legend, and grid
  • Saving: ✅ Saves to Figures/ directory
  • Quality: Excellent - clearly distinguishes all three methods

Figure 2: Model Fit Comparison ✅

  • Layout: Plot showing observed data vs fitted model for all three methods
  • Features: Shows data and all three fitted paths (grid, fminsearch, fmincon) with legend
  • Styling: Appropriate styling with proper labels, legend, and grid
  • Saving: ✅ Saves to Figures/ directory
  • Quality: Excellent visualization comparing all three methods

Bonus: Bootstrap Distribution ✅

  • Layout: Histogram showing bootstrap distribution of s_hat with confidence intervals
  • Features: Shows bootstrap distribution, point estimate, and 95% CI
  • Styling: Appropriate styling with reference lines
  • Note: This is bonus work demonstrating advanced understanding

✅ Suggestions for Improvement

  1. CRITICAL: Add timing measurements (tic/toc) for all three methods to enable speed comparison:
    tic;
    % ... grid search code ...
    time_grid = toc;
       
    tic;
    % ... fminsearch code ...
    time_fminsearch = toc;
       
    tic;
    % ... fmincon code ...
    time_fmincon = toc;
       
    fprintf('Time (Grid search): %.4f seconds\n', time_grid);
    fprintf('Time (fminsearch): %.4f seconds\n', time_fminsearch);
    fprintf('Time (fmincon): %.4f seconds\n', time_fmincon);
    
  2. CRITICAL: Add comparison comments (2-3 lines) discussing:
    • Which solver is faster (need timing measurements first)
    • Which is more robust
    • Whether they give similar s_hat values
  3. Style: Consider using bounds [0, 1] instead of [0.001, 0.999] to match assignment exactly (though your bounds are perfectly acceptable)

🎯 Summary

Excellent submission with minor missing requirements. The student demonstrates strong understanding of optimization methods, implementing all three methods correctly (grid search, fminsearch with sigmoid, and fmincon). The code includes excellent organization with clear sections, comprehensive results table, and bonus bootstrap analysis (1000 draws with confidence intervals) demonstrating advanced understanding. However, two required elements are missing: (1) no timing measurements for comparing computation speeds, and (2) missing comparison comments discussing speed, robustness, and similarity of results. The code structure is excellent with multiple figures clearly showing all three optima and model fits.

Grade Level: ✅ More than 50% Correct (12/12 tasks fully correct, 0/12 partially correct, 2/12 incorrect)