stock.prices Import Dow Jones Industrial Average and NASDAQ indexes since 1999.economic.data Import real U.S. GDP growth since 2000.stock.prices
economic.data
Merge
Plot
stock.prices Import Dow Jones Industrial Average and NASDAQ indexes 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.
Because of the steeper slope, Dow Jones has a stronger correlation to the economy than NASDAQ. NASDAQ doesn’t have a bad correlation either, and Dow Jones’ yearly returns stops at 25 percent while NASDAQ exceeds 75 percent.
Hint: Use message, echo and results in the chunk options. Refer to the RMarkdown Reference Guide.