Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Download the HW 4 R file Download HW 4 R file: # = = = = = = = = = = = = =
Download the HW R file Download HW R file:
# Data Pulling
librarytidyquant
librarydplyr
librarytidyr
librarylubridate
# We pull the market index price level and the stock prices of
# Walmart
# Target
# Home Depot, and
# Lowes.
# daily
dattqgetcGSPCWMTTGTHD 'LOW'
get "stock.prices", completecases TRUE
# monthly
tbtqgetcTBMS get "economic.data", completecases TRUE
# always remember to consider the timing of risk free rate
# when offset risk asset's returns.
# data of different tickers are stacked together
dat head
datdat
selectsymboldate,adjusted
spreadsymboladjusted
renameSPGSPC # variable name starting with punctuation or number need to
dat head
# Code Chunk : Calculation of Risk Premiums
# Code Chunk :
# This is the data construction step.
# Please manipulate the data pulled from yahoo and FRED to get
# risk premium data set.
# calculate risk premiums
# please require date date and date
# Code Chunk : Stylized Facts
# Code Chunk :
# Calculate annualized average returns and the annualized volatility for
# the risk premiums.
# stylized facts: Annual Average Return and Annual Volatility
# Code Chunk : CAPM
# Code Chunk :
# Fit CAPM for TSLA using regression in R: What is the beta?
# Plot the CAPM
and upload the file to the posit cloud R project environment. Follow the instructions in the file to pull prices of SPmarket index Walmart, Target, Home Depot, and Lowes. The pulling source should provide data going back to Pull treasury bill data at the monthly frequency. Finish the following steps and answer the question.
Steps
Construct the data set of risk premiums.
Please follow the instruction and keep only observations within the required date range specified in the code file
Calculate the stylized facts for the stock risk premiums.
Calculate betas for each stock and produce the CAPM scatter plots.
Question
What is the Sharpe ratio of SP
Note that
The Sharpe ratio is usually defined as
where is the mean of the risk premium and is the volatility standard deviation of the return.
The inclass example of data construction creates the new variables as risk premium directly. So you will need to figure out what is the return and calculate standard deviation correctly. Please also pay attention to the dates and make sure your dates correctly include all the dates in the specified range.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started