code consistent with analysis in Part 1; have not uploaded the data yet