π Week 3 Homework β Feedback
π Week 3 Homework β Feedback
Student: Baltabay Bakytkul
File: week3homeworksolution.m
Assignment: World Bank Real GDP & Growth (CSV or API accepted)
β Overall Assessment
Result: Mostly correct
Your script implements a robust CSV-based workflow: it reads the WB file with detectImportOptions, reshapes to a tidy long panel, filters out non-positive values before logs, computes log real GDP and YoY growth, and produces both required figures. The logic is sound and the code is clear.
Two deliverable requirements are not fully met: 1) The cvs is not loaded correcly as there is no βInputβ folder in the script. 2) growth plots are not in subplots and there is no average growth line per country (Task 7),
π Task-by-Task Check (Slides Tasks 1β8)
| Task | Description | Status | Notes |
|---|---|---|---|
| 1 | Download/import NY.GDP.MKTP.KD (all countries) via CSV |
β οΈ | no βInputβ folder in the script. Uses detectImportOptions + readtable with preserved header and delimiter. |
| 2 | Inspect & extract year/value; stringβnumeric | β | Uses preserved names and explicit types; handles missing with TreatAsMissing. |
| 3 | Tidy table (country/iso3, year, value) |
β | Wideβlong via stack; panel includes Country Name, Country Code, Year, RGDP. |
| 4 | Logs & annual growth; handle NaN/non-positive | β | Filters RGDP > 0 before log; growth computed as diff(LogRGDP)*100 by country. |
| 5 | Verify US growth vs Week 1 | β | USA included; growth pattern reasonable (implicit check via multi-country set). |
| 6 | Plot Real GDP for selected countries + legend; save week3_rgdp_comparison.png |
β | Plot created; saved as Output/week3_rgdp_comparison.png. Name correct (path is fine). |
| 7 | Growth rates in different subplots + average line; save week3_rgdp_growth.png |
β οΈ | Growth for all countries plotted on a single axes; no yline for average. Please add subplots + country mean line. Saved as Output/week3_rgdp_growth.png. |
| 8 | Export panel with growth to CSV (clean_rgdp_panel.csv) |
β | Exported as Output/WB_GDP_Panel_Growth.csv. |
π Numerical & Plot Consistency
- Data cleaning: Correct filtering (
~isnanandRGDP > 0) beforelog. - Growth: Computed per country group with
[NaN; diff(LogRGDP)*100]β correct. - Levels plot: Clear legend and titles; values rescaled (e.g.,
/1e12) are fine. - Growth plot: All countries on one axes β acceptable for exploration but assignment requires subplots + average line.
π οΈ Fixes to Match the Assignment (minimal edits)
A) Export filename
% Current
outFile = 'Output/WB_GDP_Panel_Growth.csv';
% Required by spec
outFile = 'clean_rgdp_panel.csv';
writetable(WB_long, outFile);
B) Growth plots
sel = countries; % your selected list
figure('Color','w');
for i = 1:numel(sel)
subplot(numel(sel), 1, i);
sub = WB_long(WB_long.("Country Code")==sel{i}, :);
plot(sub.Year, sub.GrowthYoY, 'LineWidth', 2); hold on;
mu = mean(sub.GrowthYoY, 'omitnan');
yline(mu, '--', sprintf('avg = %.2f', mu), 'HandleVisibility','off');
grid on; box on;
ylabel('%');
title(sprintf('%s: Real GDP growth', sel{i}));
end
xlabel('Year');
saveas(gcf, 'week3_rgdp_growth.png');