🌍 Week 3 Homework β€” Feedback

Student: Michele Nascia
Files: week3_homework_starter.m, RGDP_Growth_Comparison_USA_DEU_ITA.png, RGDP_Growth_Comparison_USA_DEU_ITA.fig, WB_RGDP_Selected_Panel.csv, RGDP.csv
Assignment: World Bank Real GDP & Growth (CSV version)


βœ… Overall Assessment

Result: Mostly correct

  • Data import, cleaning, logs and YoY growth are implemented correctly for the selected countries (ITA, DEU, USA).
  • The submitted figure clearly shows levels (top) and growth rates (bottom), with sensible dynamics (2009 & 2020 recessions visible).
  • Two reproducibility issues required manual intervention before grading: the script name had a suffix (7).m and a hard reference to week3_homework_starter(3).m at line 156. These should be fixed by the student.

πŸ” Task-by-Task Check (Slides Tasks 1–8)

Task Description Status Notes
1 Import NY.GDP.MKTP.KD (all countries) via CSV βœ… Reads CSV; selected countries subset prepared.
2 Inspect & extract (country/iso3, year, value) βœ… Proper year/value extraction and typing.
3 Build tidy table (country/iso3, year, value) βœ… WB_RGDP_Selected_Panel.csv present with long structure.
4 Compute logs & annual growth βœ… Uses diff(log(value))*100 by country; results consistent.
5 Verify US growth vs Week 1 βœ… Pattern matches expected US series.
6 Plot selected countries’ Real GDP + legend; save figure βœ… Levels plotted; saved as RGDP_Growth_Comparison_USA_DEU_ITA.png (naming differs from spec but acceptable content-wise).
7 Plot growth rates in different subplots per country + average line; save figure ⚠️ Growth shown in a single subplot (shared across countries) and no mean line per country.
8 Export panel with growth to CSV βœ… WB_RGDP_Selected_Panel.csv exported (CSV name allowed to differ).

πŸ–ΌοΈ Numerical & Plot Consistency

  • Levels: USA line (dotted) on higher scale; DEU and ITA close and smooth β€” consistent with WB data.
  • Growth: Timing and amplitudes of downturns line up across countries; values look reasonable.

πŸ› οΈ Required Fixes (minimal edits)

1) Reproducibility / file names

  • Rename your main script to week3_homework_solution.m (avoid (...) in filenames).
  • Remove hard-coded references to other script versions:
    % line 156 currently:
    % run('week3_homework_starter(3).m')
    % change to:
    % run('week3_homework_starter.m')  % or integrate code directly in your solution file
    

2) Growth plots


sel = {'ITA','DEU','USA'};
figure('Color','w');
for i = 1:numel(sel)
    subplot(numel(sel),1,i);
    sub = T(strcmp(T.CountryCode, sel{i}), :);
    plot(sub.Year, sub.GrowthYoY, '-o'); hold on;
    mu = mean(sub.GrowthYoY, 'omitnan');
    yline(mu, '--', sprintf('Mean = %.2f%%', mu), 'HandleVisibility','off');
    grid on; box on;
    title(sel{i}); ylabel('Growth (%)');
end
xlabel('Year');
saveas(gcf, 'week3_rgdp_growth.png');

Style & Clarity

  • Add semicolons to suppress Command Window output.
  • Include a brief header comment (purpose, inputs, outputs).
  • Prefer relative paths and avoid run() where possible (keep everything in the main script or call helper functions).