---
title: "ECOM 2001 Term Project: (AMD, UL, IP)"
author: "Raj Gunesh (Staff)"
date: "Due May 25, 2025 at 23:59 AWST"
output: bookdown::pdf_document2 
header-includes:
toc: false
geometry: margin = 1.5cm
papersize: a4
pagestyle: empty
fontsize: 12 pt 
---

```{r setup, include=FALSE}
options(knitr.kable.NA = '', scipen = 1, digits = 3)
knitr::opts_chunk$set(echo = TRUE, message= FALSE, warning = FALSE, tidy.opts = list(width.cutoff = 90), tidy = TRUE)

rm(list=ls(all=TRUE)) # this code clears all output from your Environment
```


The objective is to maximise

$$
r = w_1r_1 + w_2r_2
$$

subject to

w_1 + w_2 = 1, \text {where } w_1, w_2 > 0

$$
h(r) = \mathbb E(r) - \mathbb Var(r)
$$

\
**Note**
\
$$
\mathbb E(r) = w_1 \mathbb E(r_1) + w_2 \mathbb E(r_2)
\\
\mathbb Var(r) = w_1^2\mathbb Var(r_1) + w_2^2 \mathbb Var(r_2) + 2w_1w_2 \mathbb Cov (r_1,r_2)
$$

$$
h (r) = (w_1 \mathbb E(r_1) + w_2 \mathbb E(r_2)) - (w_1^2\mathbb Var(r_1) + w_2^2 \mathbb Var(r_2) + 2w_1w_2 \mathbb Cov(r_1,r_2))
$$

$$
= w_1 \mathbb E(r_1) + w_2 \mathbb E(r_2) - w_1^2\mathbb Var(r_1) - w_2^2 \mathbb Var(r_2) - 2w_1w_2 \mathbb Cov(r_1,r_2)
$$
\
Substituting $w_1$ by (1 - $w_2$), we obtain

$$
h(r) = w_1 \mathbb E(r_1) + (1 - w_1) \mathbb E(r_2) - w_1^2\mathbb Var(r_1) - (1 - w_1)^2 \mathbb Var(r_2)\\ - 2w_1(1 - w_1) \mathbb Cov(r_1,r_2)
$$

$$
= w_1 \mathbb E(r_1) + \mathbb E(r_2) - w_1 \mathbb E(r_2) - w_1^2 \mathbb Var(r_1)\\ - (1 - 2w_1 + w_1^2) \mathbb Var(r_2) - 2w_1 \mathbb Cov(r_1,r_2) + 2w_1^2 \mathbb Cov(r_1,r_2)
$$

$$
= w_1 \mathbb E(r_1) + \mathbb E(r_2) - w_1 \mathbb E(r_2) - w_1^2 \mathbb Var(r_1) \\\\ - \mathbb Var(r_2) + 2w_1 \mathbb Var(r_2) - w_1^2 \mathbb Var(r_2) - 2w_1 \mathbb Cov(r_1,r_2) + 2w_1^2 \mathbb Cov(r_1,r_2)
$$


$$
= -w_1^2 \mathbb Var(r_1) - w_1^2 \mathbb Var(r_2) + 2w_1^2 \mathbb Cov(r_1,r_2) + \\\\ w_1 \mathbb E(r_1) - w_1 \mathbb E(r_2) + 2w_1 \mathbb Var(r_2) - 2w_1 \mathbb Cov(r_1,r_2) + \\\\ \mathbb E(r_2) - \mathbb Var(r_2) 
$$

$$
= w_1^2(- \mathbb Var(r_1) - \mathbb Var(r_2) + 2 \mathbb Cov (r_1,r_2)) + \\ w_1(\mathbb E(r_1) - \mathbb E(r_2) + 2 \mathbb Var(r_2)  - 2 \mathbb Cov (r_1,r_2)) + \\ (\mathbb E(r_2) - \mathbb Var(r_2)) 
$$
\
Differentiating with respect to $w_1$, we obtain

$$
\frac{d}{dw_1}[h(r)] = 2w_1(- \mathbb Var(r_1) - \mathbb Var(r_2) + 2 \mathbb Cov (r_1,r_2)) + \\ (\mathbb E(r_1) - \mathbb E(r_2) + 2 \mathbb Var(r_2)  - 2 \mathbb Cov (r_1,r_2))
$$
\
Equating to 0 and solving for $w_1$, we have

$$
2w_1(- \mathbb Var(r_1) - \mathbb Var(r_2) + 2 \mathbb Cov (r_1,r_2)) + \\ (\mathbb E(r_1) - \mathbb E(r_2) + 2 \mathbb Var(r_2)  - 2 \mathbb Cov (r_1,r_2)) = 0
$$
\
and
\

$$
w_1 = - \frac{(\mathbb E(r_1) - \mathbb E(r_2) + 2 \mathbb Var(r_2)  - 2 \mathbb Cov (r_1,r_2))}{2(- \mathbb Var(r_1) - \mathbb Var(r_2) + 2 \mathbb Cov (r_1,r_2))}
$$

