Name:
Andrew ID:
Collaborated with:

This lab is to be completed in class. You can collaborate with your classmates, but you must identify their names above, and you must submit your own lab as an Rmd file on Blackboard, by 11:59pm on the day of the lab.

There are Homework 10 questions dispersed throughout. These must be written up in a separate Rmd document, together with all Homework 10 questions from other labs. Your homework writeup must start as this one: by listing your name, Andrew ID, and who you collaborated with. You must submit your own homework as a knit HTML file on Blackboard, by 11:59pm on Tuesday November 15. This document contains 23 of the 45 total points for Homework 10.

Split-apply-combine practice with the debt data

Investigating correlations in the debt data

Hw10 Q4 (8 points). There are 4 countries whose correlations, between GDP growth rate and debt-to-GDP ratio, are less than -0.5. Identify them, and define debt.df.low to be the subset of rows of debt.df corresponding to the data from these 4 countries. Then, using a single call to d_ply() on debt.df.low, produce a separate scatter plot for each country of the GDP growth rate versus debt-to-GDP ratio, over the years in which these were observed. You should thus have 4 plots in total, arranged in a 2 x 2 plotting grid. Each plot should have appropriately labeled x- and y-axes, and should have an appropriate title portraying the country’s name. Also, on each plot, draw the line-of-best-fit (linear regression line, from regressing growth onto ratio) in red, on top of the scatter points.

Hw10 Bonus.* Using just one line of code, in which you call one of the d*ply() functions, create a matrix whose entries are GDP growth by year (rows) and country (columns). Check that it has dimension 64 x 20. Show the first 6 rows and 6 columns.

Economists: which ones are right?

Hw10 Q5 (8 points). Add a next.growth column, as you did in the last question, but now to the whole debt.df data frame. Make sure that you do not accidentally put the first growth value for one country as the next.growth value for another. So, to check your answers, the next.growth for France in 2009 should be NA, not 9.1670. (Hint: write a function to encapsulate what you did in the last question, and then use ddply().) Show the first 5 and last 5 rows of the modified debt.df data frame.

Hw10 Q6 (7 points). Plot next year’s GDP growth against this year’s debt ratio, over all the data in debt.df, with appropriate axes labels and an appropriate title. Report the coefficients from regressing next year’s growth rate on the current year’s debt ratio, again over all the data in debt.df. Add this regression line to your plot.

Then, plot next year’s GDP growth against the current year’s GDP growth. Similarly, report the coefficients from regressing next year’s growth rate onto this year’s growth rate, and add this regression line to your plot.

Can you tell, from comparing the latter two regressions, whether current growth or current debt is a better predictor of future growth?

Hw10 Bonus. Add a new column called delta.growth to the debt.df data frame, giving the difference between next year’s GDP growth rate and this year’s GDP growth rate. Then, report the coefficients from regressing the change in GDP growth on the current GDP growth rate and the current debt-to-GDP ratio, over all the data in debt.df.

Some economists have claimed that there is a “tipping point”, or even a “point of no return”, when the ratio of government debt-to-GDP crosses 90%, above which growth slows dramatically or even becomes negative. Add an indicator column high.debt to the debt.df data frame, that takes the value TRUE when the debt-to-GDP ratio is over 90% and FALSE otherwise. Now regress the change in GDP growth on the current GDP growth rate, the current debt-to-GDP ratio, as well as the indicator that the debt is above 90%. Report the coefficients. What does the coefficient of the indicator variable high.debt tell you about the claim?