程序代写代做 INTRODUCTION

INTRODUCTION

In this lab, you will use R to use the bootstrap to compute standard errors for CER model estimates of five Northwest stocks in the INTROCOMPFIN package: Amazon (amzn), Boeing (ba), Costco (cost), Nordstrom (jwn), and Starbucks (sbux). You will get started on the class project (see the Final Project under Assignments on Canvas for more details on the class project). This notebook walks you through all of the computations for the bootstrap part of the lab. You will use the following R packages

– BOOT
– INTROCOMPFINR
– PERFORMANCEANALYTICS PACKAGE.
– ZOO
– XTS

Make sure to install these packages before you load them into R. As in the previous labs, use this notebook to answer all questions. Insert R chunks where needed. I will provide code hints below.

# Load packages and set options

suppressPackageStartupMessages(library(IntroCompFinR))
suppressPackageStartupMessages(library(corrplot))
suppressPackageStartupMessages(library(PerformanceAnalytics))
suppressPackageStartupMessages(library(xts))
suppressPackageStartupMessages(library(boot))
suppressPackageStartupMessages(library(zoo))
options(digits = 3)
Sys.setenv(TZ=”UTC”)

LOADING DATA AND COMPUTING RETURNS

Load the daily price data from INTROCOMPFINR, and create monthly returns over the period Jan 1998 through Dec 2014:

data(amznDailyPrices, baDailyPrices, costDailyPrices, jwnDailyPrices, sbuxDailyPrices)
fiveStocks = merge(amznDailyPrices, baDailyPrices, costDailyPrices, jwnDailyPrices, sbuxDailyPrices)
fiveStocks = to.monthly(fiveStocks, OHLC=FALSE)

Next, let’s compute monthly continuously compounded returns using the PERFORMANCEANALYTICS function Return.Calculate()

fiveStocksRet = na.omit(Return.calculate(fiveStocks, method = “log”))
head(fiveStocksRet, n=3)

We removed the missing January return using the function na.omit().

PART I: CER MODEL ESTIMATION

Consider the CER Model for cc returns

where Rit denotes the cc return on asset i (i = AMZN, ⋯, SBUX).

1. Using sample descriptive statistics, give estimates for the model parameters μi, σi², σi, σi, j, ρi, j. “`{r} muhat.vals = apply(fiveStocksRet,2,mean) sigma2hat.vals = apply(fiveStocksRet, 2, var) sigmahat.vals = apply(fiveStocksRet, 2, sd) cbind(muhat.vals,sigma2hat.vals,sigmahat.vals)

covmat = var(fiveStocksRet) covmat cormat = cor(fiveStocksRet) cormat covhat.vals = covmat[lower.tri(covmat)] rhohat.vals = cormat[lower.tri(cormat)] 2. For each estimate of the above parameters (except $\sigma_{i,j}$) compute the estimated standard error. That is, compute $\widehat{\mathrm{SE}}(\hat{\mu}_{i})$, $\widehat{\mathrm{SE}}(\hat{\sigma}_{i}^{2})$, $\widehat{\mathrm{SE}}(\hat{\sigma}_{i})$, and $\widehat{\mathrm{SE}}(\hat{\rho}_{ij})$. Briefly comment on the precision of the estimates. We will compare the bootstrap SE values to these values.{r} nobs = nrow(fiveStocksRet) se.muhat = sigmahat.vals/sqrt(nobs) cbind(muhat.vals,se.muhat) # ES error for variance and SD se.sigma2hat = sigma2hat.vals / sqrt(nobs/2) se.sigmahat = sigmahat.vals / sqrt(2*nobs) cbind(sigma2hat.vals,se.sigma2hat,sigmahat.vals,se.sigmahat) se.rhohat = (1-rhohat.vals^2) / sqrt(nobs) cbind(rhohat.vals, se.rhohat) “` Estimation for mean is precise, except BA. Estimated SE values for volatility are small compare to estimates. Estimate volatility well.Estimated Standard errors for correlations are small compare to estimates. Standard error is smallest for largest correlation estimate.

PART II: BOOTSTRAPPING THE CER MODEL ESTIMATES

1. For each estimate of the above parameters (except σi, j) compute the estimated standard error using the bootstrap with 999 bootstrap replications. That is, compute $\widehat{\mathrm{SE}}_{boot}(\hat{\mu}_{i})$, $\widehat{\mathrm{SE}}_{boot}(\hat{\sigma}_{i}^{2})$, $\widehat{\mathrm{SE}}_{boot}(\hat{\sigma}_{i})$, and $\widehat{\mathrm{SE}}_{boot}(\hat{\rho}_{ij})$. Compare the bootstrap standard errors to the analytic standard errors you computed above.

2. Plot the histogram and qq-plot of the bootstrap distributions you computed from the previous question. Do the bootstrap distributions look normal?

3. For each asset, compute estimates of the 5% value-at-risk based on an initial $100, 000 investment. Use the bootstrap to compute values as well as 95% confidence intervals. Briefly comment on the accuracy of the 5% VaR estimates.