Preturn = f * mean(Boeing) + g * mean(GM)+ (1 - f - g) * mean(Exxon)
Pstdev = sdw(f, g, 1 - f - g, Boeing, GM, Exxon)

## remove runs that try to use > 100% of budget
constraint = ifelse(f + g > 1, NA, 1)
Pstdev = Pstdev * constraint

## Minimize risk
minr_Boeing = find_min(Pstdev, f)
minr_GM = find_min(Pstdev, g)
minr_Exxon = find_min(Pstdev, 1 - f - g)

## Maximize sharpe
sharpe = (Preturn / Pstdev) * constraint
maxs_Boeing = find_max(sharpe, f)
maxs_GM = find_max(sharpe, g)
maxs_Exxon = find_max(sharpe, 1 - f - g)

```{r fig.width=7, fig.height=4.67, dpi = 96}
visualize(dataset = "simdat2", xvar = "Pstdev", yvar = "Preturn", type = "scatter", color = "sharpe", custom = TRUE) + 
xlab("Risk (Stdev)") + 
ylab("Expected return")
```

name: Sign contract
variables:
    legal fees: 5000
type: decision
Sign with Movie Company:
    cost: legal fees
    type: chance
    Small Box Office:
        p: 0.3
        payoff: 200000
    Medium Box Office:
        p: 0.6
        payoff: 1000000
    Large Box Office:
        p: 0.1
        payoff: 3000000
Sign with TV Network:
    payoff: 900000

```{r fig.width = 7, fig.height = 4.67, dpi = 144}
visualize(
  simdat2,
  xvar = "Pstdev",
  yvar = "Preturn",
  type = "scatter",
  labs = list(x = "Risk (Stdev)", y = "Expected return"),
  custom = TRUE
) +
  geom_text(
    data = investment_expl,
    label = c("", "Boeing", "GM"),
    size = 8,
    hjust = 0,
    vjust = 0
  ) +
  coord_cartesian(xlim = c(.09, .18), ylim = c(.085, .135))
```

Preturn = f * mean(Boeing) + (1 - f) * mean(GM)

### Simulated data

Formulas:

Preturn = f \* mean(Boeing) + (1 - f) \* mean(GM)

Pstdev = sdw(f, 1 - f, Boeing, GM)

##### # Minimize risk

minr_Boeing = find_min(Pstdev, f)

minr_GM = 1 - minr_Boeing

##### # Maximize sharpe

sharpe = (Preturn / Pstdev)

maxs_Boeing = find_max(sharpe, f)

maxs_GM = 1 - maxs_Boeing

Date: 2019-12-16 15:40:46

Preturn = f * mean(Boeing) + g * mean(GM)+ (1 - f - g) * mean(Exxon)
Pstdev = sdw(f, g, 1 - f - g, Boeing, GM, Exxon)
## remove runs that try to use > 100% of budget
minr_Exxon = find_min(Pstdev, 1 - f - g)
sharpe = (Preturn / Pstdev) * constraint
maxs_Exxon = find_max(sharpe, 1 - f - g)