Please submit your solution as PDF file on OLAT, and name the file as follows: Last name - Assignment 1.pdf In addition, you may upload the R-script or rmd-file corresponding to your solution on a...

1 answer below »
Please submit your solution as PDF file on OLAT, and name the file as follows: Last name - Assignment 1.pdf In addition, you may upload the R-script or rmd-file corresponding to your solution on a voluntary basis. To save time, I recommend to create the assignment with rmarkdown. The necessary syntax is simple and easy to learn. You just have to create headings with hashtags, and include your R code in chunks: ```{r exercise1a} # R-Code here ``` Templates for the YAML-Header can be found on OLAT and on the slides. Exercise 1 1a) Download stock prices Download the adjusted closing prices of the S&P 500 (symbol ˆgspc) from 2009-12-31 to 2020-04-30, and compute the daily log returns. For the ease of interpretation, you can multiply the returns by 100. 1b) Create a subsample Suppose we are at the end of February 2020. Hence, we pretend that we don’t know yet how the stock market will perform in March and April. To this end, create two subsamples of the daily log returns.1 The first subsample shall contain all observations until the end of February 2020, which will be called “training sample” henceforth. The second subsample shall contain all observations from the beginning of March 2020 onwards, and will be called “test sample” below. 1c) Sample moments Compute the first four sample moments of the daily log returns for both the “training sample” as well as the full (!) sample. Briefly interpret your results. 1Hint: ‘window()‘. 1 Exercise 2 2a) Normal distribution Fit a normal distribution to the “training sample” of log returns. 2b) Quantile Compute the 1 % quantile of the fitted distribution, and briefly interpret your result. 2c) Probability density function Plot the estimated probability density function, and add the quantile from above as a vertical line. 2d) Annualized volatility Use the square-root of time-scaling to compute the annualized volatility of the estimated distribution. Exercise 3 Use the parameter estimates from the normal distribution above, and answer the following questions. 3a) Probability of negative returns What is the probability that the daily log return is • ≥ 1 • ≥ 3 standard deviations below the mean? 3b) Expected frequency of negative returns In how many days would you expect to observe a log return that is • ≥ 1 • ≥ 3 standard deviations below the mean? 3c) Expected frequency of extreme returns Assume a year has 250 trading days. In how many years would you expect to observe a log return that is • ≥ 5 • ≥ 6 standard deviations below the mean? In how many lifetimes of the universe would you expect to observe a log return that is ≥ 7.5 standard deviations below the mean, given that the universe is estimated to be roughly 1.38 · 1010 years old?2 2See Weintraub (2011). 2 3d) Observed and expected frequency of extreme returns Use now the “test sample” as well as the estimated normal distribution from above to answer the following questions: • On how many days was the S&P 500’s return in the test sample ≥ 6 standard deviations below the mean? • How many standard deviations was the S&P 500’s return on it’s worst day in the test sample below the mean? When was that day?3 Exercise 4 4a) Student-t distribution Use again the “training sample” to fit either a generalized or a standardized Student-t distribution. 4b) Moments of the Student-t distribution Compute the first four moments of the estimated Student-t distribution, and briefly compare them to the corresponding sample moments above. 4c) Expected probability and frequency of extreme returns Use the “test sample” as well as the estimated Student-t distribution from above. What is the (daily) probability to observe a return which is at most as large as the S&P 500’s worst return in the “test sample”? How often would you expect to observe such a return? Hint: If you have used the rugarch package to fit the Student-t distribution, you can readily use the function pdist(), which implements the standardized Student-t distribution. However, if you have used the QRM package, which estimates the parameters of the generalized Student-t distribution, you have to find a workaround, since it’s cumulative probability function is neither available in base R nor in the QRM package. However, the generalized Student-t distribution is just a transformation of the ordinary Student-t distribution (as shown on the slides). Therefore, one can easily write a user-defined function, which rescales the data before computing the corresponding probabilities based on the cumulative probability function for the ordinary Student-t distribution, pt(): pgst <- function(q,="" mu="0," lambda="1," df){="" q_scaled=""><- (q - mu) / lambda pt(q = q_scaled, df = df) } (q="" -="" mu)="" lambda="" pt(q="q_scaled," df="df)">
Answered Same DayDec 07, 2021

Answer To: Please submit your solution as PDF file on OLAT, and name the file as follows: Last name -...

Mohd answered on Dec 09 2021
143 Votes
assignment 1
assignment 1
Polina Markova
12/8/2020
Convert to date
Create a subsample
library(
readr)
X_GSPC <- read_csv("^GSPC.csv")
##
## -- Column specification --------------------------------------------------------
## cols(
## Date = col_character(),
## Open = col_double(),
## High = col_double(),
## Low = col_double(),
## Close = col_double(),
## Adj_Close = col_double(),
## Volume = col_number(),
## log_return = col_logical()
## )
my_dates_new <- as.Date(X_GSPC$Date,"-01",sep="")
train_data <- subset(X_GSPC, Date < "29-02-20" )
dim(train_data)
## [1] 2402 8
test_data <- subset(X_GSPC, Date > "29-02-20" )
dim(test_data)
## [1] 197 8
logarithmic returns
# Create new column 'log_return' and initiliaze to zero
X_GSPC$log_return <- 0
# Create new column 'log_return1' and initialize to zero
X_GSPC$log_return1 <- 0
# Assign to 'nrows' the total number of rows in the data set
nrows <- nrow(X_GSPC)
# In column 'log_return', save the log returns...
SOLUTION.PDF

Answer To This Question Is Available To Download

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here