Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Download the HW 4 R file Download HW 4 R file # = = = = = = = = = = = = =

Download the HW4 R file Download HW4 R file
# ==================== Data Pulling ====================
library(tidyquant)
library(dplyr)
library(tidyr)
library(lubridate)
# We pull the market index (price level) and the stock prices of
# 1. Walmart
# 2. Target
# 3. Home Depot, and
# 4. Lowes.
# daily
dat<-tq_get(c('^GSPC','WMT','TGT','HD', 'LOW'),
get = "stock.prices", complete_cases = TRUE)
# monthly
tb<-tq_get(c('TB3MS'), get = "economic.data", complete_cases = 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()
dat<-dat %>%
select(symbol,date,adjusted)%>%
spread(symbol,adjusted)%>%
rename(SP500=`^GSPC`) # variable name starting with punctuation or number need to
dat %>% head()
# ==================== Code Chunk 1: Calculation of Risk Premiums ====================
# Code Chunk 1:
# 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<'2024-03-01' and date>='2014-03-01'
# ==================== Code Chunk 2: Stylized Facts ====================
# Code Chunk 2:
# Calculate annualized average returns and the annualized volatility for
# the risk premiums.
# stylized facts: Annual Average Return and Annual Volatility
# ==================== Code Chunk 3: CAPM ====================
# Code Chunk 3:
# 3.1 Fit CAPM for TSLA using regression in R: What is the beta?
# 3.2 Plot the CAPM
and upload the file to the posit cloud R project environment. Follow the instructions in the file to pull prices of SP500(market index), Walmart, Target, Home Depot, and Lowes. The pulling source should provide data going back to 2014. Pull treasury bill data at the monthly frequency. Finish the following steps and answer the question.
Steps
1. 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).
2. Calculate the stylized facts for the stock risk premiums.
3. Calculate betas for each stock and produce the CAPM scatter plots.
Question
What is the Sharpe ratio of SP500?
Note that
1. The Sharpe ratio is usually defined as
where is the mean of the risk premium and is the volatility (standard deviation) of the return.
2. The in-class 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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Income Tax Fundamentals 2013

Authors: Gerald E. Whittenburg, Martha Altus Buller, Steven L Gill

31st Edition

1111972516, 978-1285586618, 1285586611, 978-1285613109, 978-1111972516

More Books

Students also viewed these Finance questions

Question

How should an outlier or extreme outlier in a sample be handled?

Answered: 1 week ago