GitHub

@@ -464,7 +464,9 @@ def simple_ols(X, Y, constant=False):

464464

return β_hat, σ_hat

465465

```

466466467-

### Exercise 1

467+

```{exercise-start}

468+

:label: apl_ex1

469+

```

468470469471

Look at the equation,

470472

@@ -474,11 +476,60 @@ $$

474476475477

Verify that this equation is a regression equation.

476478477-

### Exercise 2

479+

```{exercise-end}

480+

```

481+482+

```{solution-start} apl_ex1

483+

:class: dropdown

484+

```

485+486+

To verify that it is a **regression equation** we must show that the residual is orthogonal to the regressor.

487+488+

Our assumptions about mutual orthogonality imply that

489+490+

$$

491+

E\left[\epsilon_{i,t}\right]=0,\quad E\left[\epsilon_{i,t}u_{t}\right]=0

492+

$$

493+494+

It follows that

495+496+

$$

497+

\begin{aligned}

498+

E\left[\sigma_{i}\epsilon_{i,t}\left(R_{t}^{m}-R^{f}\right)\right]&=E\left[\sigma_{i}\epsilon_{i,t}\left(\xi+\lambda u_{t}\right)\right] \\

499+

&=\sigma_{i}\xi E\left[\epsilon_{i,t}\right]+\sigma_{i}\lambda E\left[\epsilon_{i,t}u_{t}\right] \\

500+

&=0

501+

\end{aligned}

502+

$$

503+504+

```{solution-end}

505+

```

506+507+508+

```{exercise-start}

509+

:label: apl_ex2

510+

```

478511479512

Give a formula for the regression coefficient $\beta_{i, R^m}$.

480513481-

### Exercise 3

514+

```{exercise-end}

515+

```

516+517+

```{solution-start} apl_ex2

518+

:class: dropdown

519+

```

520+521+

The regression coefficient $\beta_{i, R^m}$ is

522+523+

$$

524+

\beta_{i,R^{m}}=\frac{Cov\left(R_{t}^{i}-R^{f},R_{t}^{m}-R^{f}\right)}{Var\left(R_{t}^{m}-R^{f}\right)}

525+

$$

526+527+

```{solution-end}

528+

```

529+530+

```{exercise-start}

531+

:label: apl_ex3

532+

```

482533483534

As in many sciences, it is useful to distinguish a **direct problem** from an **inverse problem**.

484535

@@ -522,51 +573,12 @@ E[(a + b R_t^m) R^m_t)] &= 1 \\

522573

E[(a + b R_t^m) R^f_t)] &= 1

523574

\end{align*}

524575525-

### Exercise 4

526-527-

Using the equations above, find a system of two **linear** equations that you can solve for $a$ and $b$ as functions of the parameters $(\lambda, \xi, E[R_f])$.

528-529-

Write a function that can solve these equations.

530-531-

Please check the **condition number** of a key matrix that must be inverted to determine a, b

532-533-

### Exercise 5

534-535-

Using the estimates of the parameters that you generated above, compute the implied stochastic discount factor.

536-537-538-539-

## Solutions

540-541-

### Solution to Exercise 1

542-543-

To verify that it is a **regression equation** we must show that the residual is orthogonal to the regressor.

544-545-

Our assumptions about mutual orthogonality imply that

546-547-

$$

548-

E\left[\epsilon_{i,t}\right]=0,\quad E\left[\epsilon_{i,t}u_{t}\right]=0

549-

$$

550-551-

It follows that

552-553-

$$

554-

\begin{aligned}

555-

E\left[\sigma_{i}\epsilon_{i,t}\left(R_{t}^{m}-R^{f}\right)\right]&=E\left[\sigma_{i}\epsilon_{i,t}\left(\xi+\lambda u_{t}\right)\right] \\

556-

&=\sigma_{i}\xi E\left[\epsilon_{i,t}\right]+\sigma_{i}\lambda E\left[\epsilon_{i,t}u_{t}\right] \\

557-

&=0

558-

\end{aligned}

559-

$$

560-561-

### Solution to Exercise 2

562-563-

The regression coefficient $\beta_{i, R^m}$ is

564-565-

$$

566-

\beta_{i,R^{m}}=\frac{Cov\left(R_{t}^{i}-R^{f},R_{t}^{m}-R^{f}\right)}{Var\left(R_{t}^{m}-R^{f}\right)}

567-

$$

576+

```{exercise-end}

577+

```

568578569-

### Solution to Exercise 3

579+

```{solution-start} apl_ex3

580+

:class: dropdown

581+

```

570582571583

**Direct Problem:**

572584

@@ -670,14 +682,36 @@ for i in range(N):

670682671683

Q: How close did your estimates come to the parameters we specified?

672684685+

```{solution-end}

686+

```

687+688+

```{exercise-start}

689+

:label: apl_ex4

690+

```

691+692+

Using the equations above, find a system of two **linear** equations that you can solve for $a$ and $b$ as functions of the parameters $(\lambda, \xi, E[R_f])$.

693+694+

Write a function that can solve these equations.

695+696+

Please check the **condition number** of a key matrix that must be inverted to determine a, b

673697698+

```{exercise-end}

699+

```

700+701+

```{solution-start} apl_ex4

702+

:class: dropdown

703+

```

704+705+

The system of two linear equations is shown below:

674706675-

### Solution to Exercise 4

676707677-

\begin{align}

708+

$$

709+

\begin{aligned}

678710

a ((E(R^f) + \xi) + b ((E(R^f) + \xi)^2 + \lambda^2 + \sigma_f^2) & =1 \cr

679711

a E(R^f) + b (E(R^f)^2 + \xi E(R^f) + \sigma_f ^ 2) & = 1

680-

\end{align}

712+

\end{aligned}

713+

$$

714+681715682716

```{code-cell} ipython3

683717

# Code here

@@ -705,7 +739,21 @@ a, b, condM = solve_ab(ERf, σf, λ, ξ)

705739

a, b, condM

706740

```

707741708-

### Solution to Exercise 5

742+

```{solution-end}

743+

```

744+745+

```{exercise-start}

746+

:label: apl_ex5

747+

```

748+749+

Using the estimates of the parameters that you generated above, compute the implied stochastic discount factor.

750+751+

```{exercise-end}

752+

```

753+754+

```{solution-start} apl_ex5

755+

:class: dropdown

756+

```

709757710758

Now let's pass $\hat{E}(R^f), \hat{\sigma}^f, \hat{\lambda}, \hat{\xi}$ to the function `solve_ab`.

711759

@@ -715,4 +763,7 @@ a_hat, b_hat, M_hat = solve_ab(ERf_hat, σf_hat, λ_hat, ξ_hat)

715763716764

```{code-cell} ipython3

717765

a_hat, b_hat, M_hat

766+

```

767+768+

```{solution-end}

718769

```

Read the original on github.com ↗