stock.prices

economic.data

Merge

Plot

Q1. stock.prices Import S&P500 since 1999.

Hint: Google tidyquant::tq_get() to find example codes.

Q2. Prepare the imported stock prices for merge.

Hint: Calculate yearly returns; create a new variable, year; and drop date.

Q3 economic.data Import real U.S. GDP growth since 2000.

Hint: Find the symbol in FRED. Select in the list of related variables, Percent Change from Preceding Period, Annual, Not Seasonally Adjusted.

Q4. Prepare the imported economic data for merge.

Hint: Create a new variable, year; convert price to decimal number; and drop date.

Q5. Merge the two data sets.

Hint: Google dplyr::left_join() to find example codes.

Q6. Plot the relaionship between stock returns and GDP growth?

Hint: See the code in 4.2.1 Scatterplot in the textbook.

Q7. Describe the relationship between the stock markets and economic growth.

There is evidence that the stock markets leads the economy.

Q8 Hide the messages, the code and its results on the webpage.

Hint: Use message, echo and results in the chunk options. Refer to the RMarkdown Reference Guide.

Q9 Display the title and your name correctly at the top of the webpage.

Q10 Use the correct slug.