Home Page > > Details

Assignment 2

---

title: "Assignment 2"

author: "YOUR NAME"

date: "March 8, 2021 (due March 15, 2021)"

output: pdf_document

---

 

```{r setup, include=FALSE}

knitr::opts_chunk$set(echo = TRUE)

```

 

Note: This is an individual assignment. No discussion with a fellow student is allowed. Honor code is in place.

 

## Question 1

 

Suppose you want to get the moments and quantiles of the population defined by a Gamma(lam|shape = 1,rate = .5) distribution (lam is the name of the random variable in this population). Use simulation to answer the following questions. 

 

1. What is the mean of this population? 

2. What is the sd of this population?

3. What are the (.025,.5,.975) quantiles of this population?

4. What are mean, sd and (025,.5,.975) quantiles of the (1/lam) population?

```{r}

# write your code here

 

 

```

 

## Question 2

 

Suppose that a random variable $Y$ takes the value 1 if the weekly return of the market index (say the SP 500 index) is positive and the value 0 otherwise. Let the population distribution of weekly returns be described by the distribution Pr(Y = 1|p) = p, Pr(Y = 0|p) = 1-p, where the parameter p is unknown.  Now suppose that one analyst believes that p = .52 and another analyst believes p = .50. You have been asked to figure out which value of p is better supported by the data. You assume that each analyst is equally qualified and decide to look at the previous 26 weeks of data. You find that in the sample data $y_{1:n}$, 15 weeks had positive returns and 11 weeks had non-positive returns. Now answer the following questions.  

 

1. What is the likelihood function given the sample data? 

2. What is the posterior distribution of p given the sample data? Which analyst is better supported by the data?

 

Now suppose that you look at this same question six months later. In those 26 weeks, 13 weeks have a positive return, and 13 weeks have a non-positive return. What is your new assessment about which analyst has a better handle on the value of p?

 

 

## Question 3

 

Suppose that the weekly returns $R$ on the SP500 index can be described by a $N(\mu,\sigma^2)$ distribution where $\sigma^2$ is known to equal $.01^2$. Your goal is to learn about $\mu$. Suppose that the data for the previous 52 weeks is the following

```{r}

set.seed(1);

r = .001 + .01*rnorm(52)

```

You decide to use a discrete uniform prior for mu on the support seq(from = -.0025,to = .0025,by = .0005) 

 

1. Calculate the posterior distribution of $\mu$ given this information.

```{r}

# write your code here

r = .001 + .01*rnorm(52)

```

 

2. What is the posterior mean and sd of $\mu$?  Use simulation to find these moments

```{r}

# write your code here

 

```

 

Contact Us - Email:99515681@qq.com    WeChat:codinghelp
Programming Assignment Help!