stock.prices Import S&P500 since 1999.economic.data Import real U.S. GDP growth since 2000.stock.prices
economic.data
Merge
Plot
stock.prices Import S&P500 since 1999.Hint: Google tidyquant::tq_get() to find example codes.
Hint: Calculate yearly returns; create a new variable, year; and drop date.
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.
Hint: Create a new variable, year; convert price to decimal number; and drop date.
Hint: Google dplyr::left_join() to find example codes.
Hint: See the code in 4.2.1 Scatterplot in the textbook.
Yes they are related there are similarities that when the stock market grows, economic growth grows aswell. So watch the stock market closesly can help you follow the economy. They have a postitive relationship with a upward moving line.
Hint: Use message, echo and results in the chunk options. Refer to the RMarkdown Reference Guide.