[SOLVED] CAPM Assignment 2 P0

100.00 $

Category:
Click Category Button to View Your Next Assignment | Homework

You will receive the following solution file(s) instantly after successful payment:

zip file icon CAPM-Ass2-t92d7x.zip (64.3 KB)
Assignment Instructions Updated Recently? Submit Below and we will provide new Solution!
Submit New Instructions
🔒 Securely Powered by:
Secure Checkout
5/5 - (2 votes)

wrap: sentence

“`{r setup, include=FALSE} knitr::opts_chunk$set(echo
= TRUE)
“`
No discussion with a fellow student is allowed.

Use the getfinmdat() function in the cbw library to download monthly excess returns on apple (ticker symbo
Call the downloaded object datdf.
Use the data in datdf for Questions 1-3.

## Question 1

Suppose you are interested in estimating the CAPM model $$
ext{prmapple} = eta , ext{prmsp500} + e
$$ where you assume that $e$ is N(0,$sigma^2$).
Assuming that the data you have downloaded can be thought of as a random sample, answer the following

1. What is the dim of datdf?

2. Write a function dnormal that takes as inputs a vector y, mean vector mu and variance parameter sigma The parameter sigma2 is common to each of these densities.

3. Use the dnormal function to write down a function to calculate the loglikelihood function of theta = (beta,
This is the sum of the log of the month-by-month normal densities of prmapple given prmsp500 and the p
The log-likelihood function should take two inputs, theta and datdf, and return the log of the likelihood fun

4. Write down another function that calculates the cost function of theta = (beta,sigma) (this is the negative

5. Use the ucminf function to minimize the cost function over theta = (beta,sigma).
Call this minimizing value thetahat = (betahat,sigmahat).
Use (1,.03) as the starting values.
Ask the ucminf function to output the hessian.

6. Use the cbind function to put thetahat and the standard errors of thetahat in a matrix object.
The se is the sqrt of the diag of the inverse of the hessian.

“`{r}
# write your code here

“`

## Question 2

Suppose you estimate the CAPM model in Question 1 by Bayesian methods.
The difference now is that we treat the parameters theta = (beta,sigma2) as random variables. We put a prior on theta and combine the prior with the likelihood by Bayes theorem to get the posterior dist Use the MCMCregressg function in the cbw package to answer the following questions.

1.
Do a Bayesian estimation of the CAPM model with the data in datdf.
Make sure when you specify the model formula that there is no intercept in the model.
Use the default 15% of the data to form the training sample prior.

2.
What are the posterior mean, sd and the .025 quantiles of beta from this Bayesian estimation?

3.
Is the posterior mean of beta similar to the estimate of beta you got by minimizing the cost function?
Is the posterior sd of beta similar to the se of betahat in Question 1?

4.
The MCMCregressg output sends out draws of sigma2 from the posterior distribution.
Use these draws to calculate the posterior distribution of sigma.
What are the posterior mean, sd and .025 and .975 quantiles of sigma?
How do these compare with the sigmahat and se of sigmahat you got in Question 1?

“`{r}
# write your code here

“`

## Question 3

1. Instead of using a training sample prior, suppose you specify your prior on the parameters. Suppose tha

“`{r}
# write your code here

“`

  • CAPM-Ass2-t92d7x.zip