test with R code embed

David Harper CFA FRM

David Harper CFA FRM
Subscriber
How does this look ... general:
Code:
library(dplyr)
library(ggplot2)
r_a <- .1; vol_a <- .1
r_b <- .16; vol_b <- .2
r_c <- .25; vol_c <- .4
rho_ab <- 0.3; rho_ac <- 0.2 ; rho_bc = 0.4; rf = 0.6

portfolio <- data.frame(w_a = seq(from = -.5, to = 1.5, by = .05))
portfolio <- portfolio %>% mutate(
    w_b = 1 - w_a,
    r_ab = w_a * r_a + (w_b * r_b),
    variance_ab = (w_a * vol_a)^2 + (w_b * vol_b)^2 + 2*w_a*w_b*vol_a*vol_b*rho_ab,
    vol_ab = sqrt(variance_ab),
    w_c = 1 - w_a,
    r_ac = w_a * r_a + (w_c * r_c),
    variance_ac = (w_a * vol_a)^2 + (w_c * vol_c)^2 + 2*w_a*w_c*vol_a*vol_c*rho_ac,
    vol_ac = sqrt(variance_ac)
)

rich
Rich (BB code):
library(dplyr)
library(ggplot2)
r_a <- .1; vol_a <- .1
r_b <- .16; vol_b <- .2
r_c <- .25; vol_c <- .4
rho_ab <- 0.3; rho_ac <- 0.2 ; rho_bc = 0.4; rf = 0.6

portfolio <- data.frame(w_a = seq(from = -.5, to = 1.5, by = .05))
portfolio <- portfolio %>% mutate(
    w_b = 1 - w_a,
    r_ab = w_a * r_a + (w_b * r_b),
    variance_ab = (w_a * vol_a)^2 + (w_b * vol_b)^2 + 2*w_a*w_b*vol_a*vol_b*rho_ab,
    vol_ab = sqrt(variance_ab),
    w_c = 1 - w_a,
    r_ac = w_a * r_a + (w_c * r_c),
    variance_ac = (w_a * vol_a)^2 + (w_c * vol_c)^2 + 2*w_a*w_c*vol_a*vol_c*rho_ac,
    vol_ac = sqrt(variance_ac)
)

markdown
Markdown (GitHub flavored):
library(dplyr)
library(ggplot2)
r_a <- .1; vol_a <- .1
r_b <- .16; vol_b <- .2
r_c <- .25; vol_c <- .4
rho_ab <- 0.3; rho_ac <- 0.2 ; rho_bc = 0.4; rf = 0.6

portfolio <- data.frame(w_a = seq(from = -.5, to = 1.5, by = .05))
portfolio <- portfolio %>% mutate(
    w_b = 1 - w_a,
    r_ab = w_a * r_a + (w_b * r_b),
    variance_ab = (w_a * vol_a)^2 + (w_b * vol_b)^2 + 2*w_a*w_b*vol_a*vol_b*rho_ab,
    vol_ab = sqrt(variance_ab),
    w_c = 1 - w_a,
    r_ac = w_a * r_a + (w_c * r_c),
    variance_ac = (w_a * vol_a)^2 + (w_c * vol_c)^2 + 2*w_a*w_c*vol_a*vol_c*rho_ac,
    vol_ac = sqrt(variance_ac)
)
 
Top