π Week 3 Homework β Feedback
π Week 3 Homework β Feedback
Student: Davide Magnini
Assignment: World Bank Real GDP & Growth (CSV version)
β οΈ Overall Assessment
Result: β οΈ Partially correct
The studentβs code correctly attempts to load and process the World Bank dataset once the directory is changed manually, but it fails during the import stage and cannot proceed to compute logs or growth rates.
The main structure follows the expected flow but is not reproducible and contains errors that prevent successful execution.
π Main Issues (compared to the reference CSV solution)
- Non-reproducible directory change
- The script uses a hard-coded
cdto access the data file, which makes the code machine-dependent. - Fix (as in the reference solution): Use relative paths and avoid changing the working directory:
% Reference approach opts = detectImportOptions('WB-WDI_time_series.csv'); T = readtable('WB-WDI_time_series.csv', opts);This keeps the code portable and consistent with the Week 3 template.
- The script uses a hard-coded
- Column names not read correctly
- All columns appear as
Var1,Var2, β¦ because the header line was not recognized. - In the reference solution, this is handled by MATLABβs
detectImportOptions, which automatically detects the variable names and data types. - Fix:
opts = detectImportOptions('WB-WDI_time_series.csv'); T = readtable('WB-WDI_time_series.csv', opts);After this step, the variables should include
CountryName,CountryCode,IndicatorName,IndicatorCode, and year columns.
- All columns appear as
- Indexing error (
split_name{4})- The error
Index exceeds the number of array elements. Index must not exceed 1.occurs because
split_namehas fewer elements than expected. - The reference solution does not extract country names from the filename β it reads them directly from the dataset (
CountryNamecolumn). - Fix (align with reference):
% Extract country names directly country_list = unique(T.CountryName);
- The error
- Data cleaning and transformation missing
- After loading, the student script does not proceed to reshape or clean the data.
- In the reference, the following steps are implemented:
- Convert wide data to long format (year/value per country).
- Drop missing or non-positive values before taking logs.
- Compute log and annual growth rate:
wb_table.log_gdp = log(wb_table.value); wb_table.growth = [NaN; diff(wb_table.log_gdp)] * 100;
- These steps are essential to obtain correct growth rates.
- Plots and outputs missing
- Figures (
week3_rgdp_comparison.png,week3_rgdp_growth.png) and the CSV export (clean_rgdp_panel.csv) are not created because the script stops at the import error.
- Figures (
π Deliverables Check
| Deliverable | Status | Comment |
|---|---|---|
clean_rgdp_panel.csv |
β | Not generated |
week3_rgdp_comparison.png |
β | Not generated |
week3_rgdp_growth.png |
β | Not generated |
| Log and growth computation | β | Not implemented due to import failure |
π¬ Style & Clarity
- The code layout is clean and easy to follow.
- However, missing semicolons cause unnecessary Command Window output.
- The script name is still
week3_homework_starter.mβ it should be renamed toweek3_homework_solution.mbefore submission.
β Suggested Fixes (based on the reference CSV solution)
- Load the data properly using import options ```matlab opts = detectImportOptions(βWB-WDI_time_series.csvβ); T = readtable(βWB-WDI_time_series.csvβ, opts);