Load Packages

require(quantmod)
## Loading required package: quantmod
## Loading required package: xts
## Loading required package: zoo
## 
## Attaching package: 'zoo'
## The following objects are masked from 'package:base':
## 
##     as.Date, as.Date.numeric
## Loading required package: TTR
## Version 0.4-0 included new data defaults. See ?getSymbols.
require(ggplot2)
## Loading required package: ggplot2
require(MASS)
## Loading required package: MASS
require(reshape2)
## Loading required package: reshape2
getRisk <- function(graphDate, ticks, t_bill_rate){
  startDate = as.Date(paste0(graphDate, "-1-1"))
  endDate = as.Date(paste0(graphDate, "-12-31"))
  getSymbols(ticks, src = "yahoo", from = startDate, to = endDate)
  
  ## merge
  dataset <- dailyReturn(get(ticks[1]))
  for (i in 2:length(ticks)) {
    dataset <- merge(dataset, dailyReturn(get(ticks[i])))
  }
  
  names(dataset) <- ticks
  # [VFINX, VBTIX, VGSIX]
  
  dataset_col_mean <- colMeans(dataset[graphDate])
  f_num <- numeric(length(ticks))
  f_num <- f_num + 1/length(ticks)
  f <- as.matrix(f_num)
  
  dataset_col_mean_m <- as.matrix(dataset_col_mean)
  
  t(f) %*% dataset_col_mean_m
  
  # big V 2011
  
  dataset_m <- as.matrix(dataset[graphDate])
  
  V <- cov(as.matrix(dataset[graphDate]),as.matrix(dataset[graphDate]))
  V_matrix <- as.matrix(V)
  
  #var 2010
  f <- as.matrix(f)
  v <- t(f) %*% V_matrix %*% f
  
  #sd 2010
  sqrt(v)
  
  #coefficients 
  ones <- numeric(length(ticks))
  ones <- ones + 1
  ones <- as.vector(ones)
  
  
  a <- t(ones)%*%solve(V)%*%ones
  b <- t(ones)%*%solve(V)%*%as.matrix(colMeans(dataset[graphDate]))
  c <- t(as.matrix(colMeans(dataset[graphDate])))%*%solve(V)%*%as.matrix(colMeans(dataset[graphDate]))
  
  ## frontier parameters
  sig_mv <- 1/sqrt(a)
  sig_mv <- as.numeric(sig_mv)
  
  mu_mv <- b/a
  
  v_as <- sqrt((a*c-b^2)/a)
  
  ### plots
  upper <-function(s) mu_mv + v_as*sqrt((s^2) - (sig_mv^2))
  lower <-function(s) mu_mv - v_as*sqrt((s^2) - (sig_mv^2))
  
  
  # old plot stuff
  #nums <- seq(sig_mv, sig_mv+sig_mv, sig_mv/10)
  #risk <- c(nums, nums)
  #reward <- c(lower(nums), upper(nums))
  #fmv <- (sig_mv^2)*ginv(V_matrix)%*%ones
  
  # including rf
  mu_si <- t_bill_rate
  mu_cl <- t_bill_rate + 0.03
  
  v_st <- v_as*sqrt(1 + ((mu_mv - mu_si)/(v_as*mu_mv))^2)
  v_ct <- v_as*sqrt(1 + ((mu_mv - mu_cl)/(v_as*mu_mv))^2)
  
  sig_st <- sig_mv*sqrt(1 + ((v_as*sig_mv)/(mu_mv - mu_si))^2)
  sig_ct <- sig_mv*sqrt(1 + ((v_as*sig_mv)/(mu_mv - mu_cl))^2)
  
  # mu eff 0 to mu_st
  sig_lower <- seq(0,sig_st, length=3)
  mu_eff_lower <- mu_si + v_st*sig_lower
  
  # mu eff sig_st to sig_ct
  sig_mid <- seq(sig_st, sig_ct, length=3)
  mu_eff_mid <- mu_mv + v_as*sqrt(sig_mid^2 - sig_mv^2)
  
  # mu eff sig_ct to inf
  sig_upper <- seq(sig_ct, 1.3*sig_ct, length=3)
  mu_eff_upper <- mu_cl + v_ct*sig_upper
  
  upper <-function(s) mu_mv + v_as*sqrt((s^2) - (sig_mv^2))
  lower <-function(s) mu_mv - v_as*sqrt((s^2) - (sig_mv^2))
  nums <- seq(sig_mv, sig_mv+sig_mv, sig_mv/10)
  risk <- c(nums, nums)
  reward <- c(lower(nums), upper(nums))
  #fmv <- (sig_mv^2)*ginv(V_matrix)%*%ones
  
  #stacked df
  mu_eff <- cbind(mu_eff_lower, mu_eff_mid, mu_eff_upper)
  mu_eff_melt <- melt(mu_eff)
  risk_levels <- cbind(sig_lower, sig_mid, sig_upper)
  risk_levels_melt <- melt(risk_levels)

  #new plot stuff
  risk_rf <- risk_levels_melt[3]
  reward_rf <- mu_eff_melt[3]
  
  #f values min
    # return means
  
  mu_st <- mu_mv + (v_as^2)*(sig_mv^2)/(mu_mv - mu_si)
  mu_ct <- mu_mv + (v_as^2)*(sig_mv^2)/(mu_mv - mu_cl)
  
  fst <- as.numeric(((sig_mv^2)/(mu_mv-mu_si)))*ginv(V_matrix)%*%(dataset_col_mean_m - mu_si*ones)
  fct <- as.numeric(((sig_mv^2)/(mu_mv-mu_cl)))*ginv(V_matrix)%*%(dataset_col_mean_m - mu_cl*ones)
  
  #f lower
  f_lower <- (sig_lower/sig_st)*fst
  
  mu_ct <- as.numeric(mu_ct)
  #f sig_st to sig_ct
  f_mid <- fst*is.numeric((mu_ct - mu_eff_mid)/(mu_ct-mu_st)) + fct*is.numeric((mu_eff_mid - mu_st)/(mu_ct - mu_st))
  
  # f sig_ct to inf
  f_upper <- (sig_upper/sig_ct)*fct
  
  return(list(risk_rf, reward_rf, risk, reward, f_upper, f_mid, f_upper))
}
plotRisk_abc <- function(graphDate, t_bill_rate){
  t_bill_rate <- t_bill_rate
  ticks1 <- c("VFINX","VBTIX","VGSIX")
  ticks2 <- c("VFINX","VBTIX","VGSIX","DFSTX", "VFITX", "DFEMX")
  ticks3 <- c("VFINX","VBTIX","VGSIX","DFSTX", "VFITX", "DFEMX","GOOGL", "XOM", "UPS")
 
  # double numers indicate risky 
  both <- getRisk(graphDate, ticks1, t_bill_rate)
  x1 = both[[1]]
  y1 = both[[2]]
  x11 = both[[3]]
  y11 = both[[4]]
  
  both2 <- getRisk(graphDate, ticks2, t_bill_rate)
  x2 = both2[[1]]
  y2 = both2[[2]]
  x22 = both2[[3]]
  y22 = both2[[4]]
  
  both3 <- getRisk(graphDate, ticks3, t_bill_rate)
  x3 = both3[[1]]
  y3 = both3[[2]]
  x33 = both3[[3]]
  y33 = both3[[4]]
  
  #rf
  dfA <- data.frame(cbind(x1,y1))
  dfB <- data.frame(cbind(x2,y2))
  dfC <- data.frame(cbind(x3,y3))
  
  #risky
  dfAA <- data.frame(cbind(x11,y11))
  dfBB <- data.frame(cbind(x22,y22))
  dfCC <- data.frame(cbind(x33,y33))
  
  names(dfA) <- c("x1","y1")
  names(dfB) <- c("x2","y2")
  names(dfC) <- c("x3","y3")
  
gg <- ggplot() + 
    geom_point(data = dfA, aes(x = x1, y = y1, shape = "A RF")) + 
    geom_point(data = dfB, aes(x = x2, y = y2, shape = "A and B RF")) +
    geom_point(data = dfC, aes(x = x3, y = y3, shape = "A, B, and C RF")) + 
#     geom_point(data = dfAA, aes(x = x11, y = y11, shape = "A")) + 
#     geom_point(data = dfBB, aes(x = x22, y = y22, shape = "A and B")) +
#     geom_point(data = dfCC, aes(x = x33, y = y33, shape = "A, B, and C")) + 
    ylab("Expected return") + 
    xlab("Risk") + 
    theme(legend.title=element_blank())

    fef_a_lower <- both[[5]]
    fef_a_mid <- both[[6]]
    fef_a_upper <- both[[7]]
    
    fef_ab_lower <- both2[[5]]
    fef_ab_mid <- both2[[6]]
    fef_ab_upper <- both2[[7]]
    
    fef_abc_lower <- both3[[5]]
    fef_abc_mid <- both3[[6]]
    fef_abc_upper <- both3[[7]]
    
    fef_a_lower < as.data.frame(fef_a_lower, row.names = ticks1)
    print(fef_a_lower)
    fef_a_mid < as.data.frame(fef_a_mid, row.names = ticks1)
    fef_a_upper < as.data.frame(fef_a_upper, row.names = ticks1)
    
    fef_ab_lower < as.data.frame(fef_ab_lower, row.names = ticks2)
    fef_ab_mid < as.data.frame(fef_ab_mid, row.names = ticks2)
    fef_ab_upper < as.data.frame(fef_ab_upper, row.names = ticks2)
    
    fef_abc_lower < as.data.frame(fef_abc_lower, row.names = ticks3)
    fef_abc_mid < as.data.frame(fef_abc_mid, row.names = ticks3)
    fef_abc_upper < as.data.frame(fef_abc_upper, row.names = ticks3)
    
    colnames(fef_a_lower) <- "f_a_lower"
    colnames(fef_a_mid) <- "f_a_mid"
    colnames(fef_a_upper) <- "f_a_upper"
    
    colnames(fef_ab_lower) <- "f_ab_lower"
    colnames(fef_ab_mid) <- "f_ab_mid"
    colnames(fef_ab_upper) <- "f_ab_upper"
    
    colnames(fef_abc_lower) <- "f_abc_lower"
    colnames(fef_abc_mid) <- "f_abc_mid"
    colnames(fef_abc_upper) <- "f_abc_upper"
    
    rownames(fef_a_lower) <- ticks1
    rownames(fef_a_mid) <- ticks1
    rownames(fef_a_upper) <- ticks1
    
    rownames(fef_ab_lower) <- ticks2
    rownames(fef_ab_mid) <- ticks2
    rownames(fef_ab_upper) <- ticks2
    
    rownames(fef_abc_lower) <- ticks3
    rownames(fef_abc_mid) <- ticks3
    rownames(fef_abc_upper) <- ticks3
    
#   fmv_a <- as.data.frame(fmv_a, row.names = ticks1)
#   colnames(fmv_a) <- "fmv"
#   fmv_ab <- as.data.frame(fmv_ab, row.names = ticks2)
#   colnames(fmv_ab) <- "fmv"
#   fmv_abc <- as.data.frame(fmv_abc, row.names = ticks3)
#   colnames(fmv_abc) <- "fmv"

gg
  return(list(gg, fef_a_lower, fef_a_mid, fef_a_upper, fef_ab_lower, fef_ab_mid, fef_ab_upper, fef_abc_lower, fef_abc_mid, fef_abc_upper))
  #return(list(fmv_a,fmv_ab,fmv_abc,gg))
}

all t bill rates are last day of 1 year

2010 tbill rate, 0.0029

plotRisk_abc("2010", 0.0029)
##     As of 0.4-0, 'getSymbols' uses env=parent.frame() and
##  auto.assign=TRUE by default.
## 
##  This  behavior  will be  phased out in 0.5-0  when the call  will
##  default to use auto.assign=FALSE. getOption("getSymbols.env") and 
##  getOptions("getSymbols.auto.assign") are now checked for alternate defaults
## 
##  This message is shown once per session and may be disabled by setting 
##  options("getSymbols.warning4.0"=FALSE). See ?getSymbols for more details.
## Warning in download.file(paste(yahoo.URL, "s=", Symbols.name, "&a=",
## from.m, : downloaded length 16644 != reported length 200
## Warning in download.file(paste(yahoo.URL, "s=", Symbols.name, "&a=",
## from.m, : downloaded length 12112 != reported length 200
## Warning in download.file(paste(yahoo.URL, "s=", Symbols.name, "&a=",
## from.m, : downloaded length 13712 != reported length 200
## Warning in download.file(paste(yahoo.URL, "s=", Symbols.name, "&a=",
## from.m, : downloaded length 16644 != reported length 200
## Warning in download.file(paste(yahoo.URL, "s=", Symbols.name, "&a=",
## from.m, : downloaded length 12112 != reported length 200
## Warning in download.file(paste(yahoo.URL, "s=", Symbols.name, "&a=",
## from.m, : downloaded length 13712 != reported length 200
## Warning in download.file(paste(yahoo.URL, "s=", Symbols.name, "&a=",
## from.m, : downloaded length 14102 != reported length 200
## Warning in download.file(paste(yahoo.URL, "s=", Symbols.name, "&a=",
## from.m, : downloaded length 12141 != reported length 200
## pausing 1 second between requests for more than 5 symbols
## Warning in download.file(paste(yahoo.URL, "s=", Symbols.name, "&a=",
## from.m, : downloaded length 14145 != reported length 200
## pausing 1 second between requests for more than 5 symbols
## Warning in download.file(paste(yahoo.URL, "s=", Symbols.name, "&a=",
## from.m, : downloaded length 16644 != reported length 200
## Warning in download.file(paste(yahoo.URL, "s=", Symbols.name, "&a=",
## from.m, : downloaded length 12112 != reported length 200
## Warning in download.file(paste(yahoo.URL, "s=", Symbols.name, "&a=",
## from.m, : downloaded length 13712 != reported length 200
## Warning in download.file(paste(yahoo.URL, "s=", Symbols.name, "&a=",
## from.m, : downloaded length 14102 != reported length 200
## Warning in download.file(paste(yahoo.URL, "s=", Symbols.name, "&a=",
## from.m, : downloaded length 12141 != reported length 200
## pausing 1 second between requests for more than 5 symbols
## Warning in download.file(paste(yahoo.URL, "s=", Symbols.name, "&a=",
## from.m, : downloaded length 14145 != reported length 200
## pausing 1 second between requests for more than 5 symbols
## Warning in download.file(paste(yahoo.URL, "s=", Symbols.name, "&a=",
## from.m, : downloaded length 18511 != reported length 200
## pausing 1 second between requests for more than 5 symbols
## Warning in download.file(paste(yahoo.URL, "s=", Symbols.name, "&a=",
## from.m, : downloaded length 16844 != reported length 200
## pausing 1 second between requests for more than 5 symbols
## Warning in download.file(paste(yahoo.URL, "s=", Symbols.name, "&a=",
## from.m, : downloaded length 16600 != reported length 200
## pausing 1 second between requests for more than 5 symbols
##             [,1]
## [1,]  0.16825711
## [2,]  1.00225047
## [3,] -0.05171304
## [[1]]

## 
## [[2]]
##         f_a_lower
## VFINX  0.16825711
## VBTIX  1.00225047
## VGSIX -0.05171304
## 
## [[3]]
##           f_a_mid
## VFINX  0.34222316
## VBTIX  1.74385703
## VGSIX -0.08608019
## 
## [[4]]
##         f_a_upper
## VFINX  0.16825711
## VBTIX  1.00225047
## VGSIX -0.05171304
## 
## [[5]]
##        f_ab_lower
## VFINX  0.19936023
## VBTIX  1.38622670
## VGSIX -0.04726117
## DFSTX -0.02843798
## VFITX -0.37080843
## DFEMX -0.02280188
## 
## [[6]]
##          f_ab_mid
## VFINX  0.42018400
## VBTIX  2.41427392
## VGSIX -0.07635117
## DFSTX -0.07198122
## VFITX -0.65026988
## DFEMX -0.03585565
## 
## [[7]]
##        f_ab_upper
## VFINX  0.19936023
## VBTIX  1.38622670
## VGSIX -0.04726117
## DFSTX -0.02843798
## VFITX -0.37080843
## DFEMX -0.02280188
## 
## [[8]]
##        f_abc_lower
## VFINX  0.145975368
## VBTIX  1.389993139
## VGSIX -0.041368270
## DFSTX -0.015830362
## VFITX -0.374436453
## DFEMX -0.029153342
## GOOGL  0.008171478
## XOM    0.043938698
## UPS   -0.006980251
## 
## [[9]]
##         f_abc_mid
## VFINX  0.31873657
## VBTIX  2.42378760
## VGSIX -0.06762797
## DFSTX -0.04673120
## VFITX -0.65921751
## DFEMX -0.04540768
## GOOGL  0.01893669
## XOM    0.07482671
## UPS   -0.01730321
## 
## [[10]]
##        f_abc_upper
## VFINX  0.145975368
## VBTIX  1.389993139
## VGSIX -0.041368270
## DFSTX -0.015830362
## VFITX -0.374436453
## DFEMX -0.029153342
## GOOGL  0.008171478
## XOM    0.043938698
## UPS   -0.006980251

2011 tbill rate, 0.0029

plotRisk_abc("2011", 0.0029)
## Warning in download.file(paste(yahoo.URL, "s=", Symbols.name, "&a=",
## from.m, : downloaded length 17132 != reported length 200
## Warning in download.file(paste(yahoo.URL, "s=", Symbols.name, "&a=",
## from.m, : downloaded length 12116 != reported length 200
## Warning in download.file(paste(yahoo.URL, "s=", Symbols.name, "&a=",
## from.m, : downloaded length 14305 != reported length 200
## Warning in download.file(paste(yahoo.URL, "s=", Symbols.name, "&a=",
## from.m, : downloaded length 17132 != reported length 200
## Warning in download.file(paste(yahoo.URL, "s=", Symbols.name, "&a=",
## from.m, : downloaded length 12116 != reported length 200
## Warning in download.file(paste(yahoo.URL, "s=", Symbols.name, "&a=",
## from.m, : downloaded length 14305 != reported length 200
## Warning in download.file(paste(yahoo.URL, "s=", Symbols.name, "&a=",
## from.m, : downloaded length 14389 != reported length 200
## Warning in download.file(paste(yahoo.URL, "s=", Symbols.name, "&a=",
## from.m, : downloaded length 12256 != reported length 200
## pausing 1 second between requests for more than 5 symbols
## Warning in download.file(paste(yahoo.URL, "s=", Symbols.name, "&a=",
## from.m, : downloaded length 14154 != reported length 200
## pausing 1 second between requests for more than 5 symbols
## Warning in download.file(paste(yahoo.URL, "s=", Symbols.name, "&a=",
## from.m, : downloaded length 17132 != reported length 200
## Warning in download.file(paste(yahoo.URL, "s=", Symbols.name, "&a=",
## from.m, : downloaded length 12116 != reported length 200
## Warning in download.file(paste(yahoo.URL, "s=", Symbols.name, "&a=",
## from.m, : downloaded length 14305 != reported length 200
## Warning in download.file(paste(yahoo.URL, "s=", Symbols.name, "&a=",
## from.m, : downloaded length 14389 != reported length 200
## Warning in download.file(paste(yahoo.URL, "s=", Symbols.name, "&a=",
## from.m, : downloaded length 12256 != reported length 200
## pausing 1 second between requests for more than 5 symbols
## Warning in download.file(paste(yahoo.URL, "s=", Symbols.name, "&a=",
## from.m, : downloaded length 14154 != reported length 200
## pausing 1 second between requests for more than 5 symbols
## Warning in download.file(paste(yahoo.URL, "s=", Symbols.name, "&a=",
## from.m, : downloaded length 18517 != reported length 200
## pausing 1 second between requests for more than 5 symbols
## Warning in download.file(paste(yahoo.URL, "s=", Symbols.name, "&a=",
## from.m, : downloaded length 17063 != reported length 200
## pausing 1 second between requests for more than 5 symbols
## Warning in download.file(paste(yahoo.URL, "s=", Symbols.name, "&a=",
## from.m, : downloaded length 16837 != reported length 200
## pausing 1 second between requests for more than 5 symbols
##            [,1]
## [1,]  0.1936575
## [2,]  1.0072605
## [3,] -0.0903971
## [[1]]

## 
## [[2]]
##        f_a_lower
## VFINX  0.1936575
## VBTIX  1.0072605
## VGSIX -0.0903971
## 
## [[3]]
##          f_a_mid
## VFINX  0.3914191
## VBTIX  1.7509797
## VGSIX -0.1423988
## 
## [[4]]
##        f_a_upper
## VFINX  0.1936575
## VBTIX  1.0072605
## VGSIX -0.0903971
## 
## [[5]]
##         f_ab_lower
## VFINX  0.241700313
## VBTIX  0.973245653
## VGSIX -0.080888507
## DFSTX -0.042383292
## VFITX  0.020689487
## DFEMX -0.001802475
## 
## [[6]]
##          f_ab_mid
## VFINX  0.47113125
## VBTIX  1.68615401
## VGSIX -0.12796265
## DFSTX -0.08445069
## VFITX  0.04064173
## DFEMX  0.01448635
## 
## [[7]]
##         f_ab_upper
## VFINX  0.241700313
## VBTIX  0.973245653
## VGSIX -0.080888507
## DFSTX -0.042383292
## VFITX  0.020689487
## DFEMX -0.001802475
## 
## [[8]]
##         f_abc_lower
## VFINX  0.2223126615
## VBTIX  0.9739511736
## VGSIX -0.0780733386
## DFSTX -0.0390274495
## VFITX  0.0209022181
## DFEMX -0.0008936979
## GOOGL -0.0079166382
## XOM    0.0170871805
## UPS    0.0070550699
## 
## [[9]]
##         f_abc_mid
## VFINX  0.45087563
## VBTIX  1.68658344
## VGSIX -0.12570105
## DFSTX -0.08050187
## VFITX  0.04146510
## DFEMX  0.01623799
## GOOGL -0.01871153
## XOM    0.01875754
## UPS    0.01099476
## 
## [[10]]
##         f_abc_upper
## VFINX  0.2223126615
## VBTIX  0.9739511736
## VGSIX -0.0780733386
## DFSTX -0.0390274495
## VFITX  0.0209022181
## DFEMX -0.0008936979
## GOOGL -0.0079166382
## XOM    0.0170871805
## UPS    0.0070550699

2012 tbill rate, 0.0029

plotRisk_abc("2012", 0.0016)
## Warning in download.file(paste(yahoo.URL, "s=", Symbols.name, "&a=",
## from.m, : downloaded length 17293 != reported length 200
## Warning in download.file(paste(yahoo.URL, "s=", Symbols.name, "&a=",
## from.m, : downloaded length 12143 != reported length 200
## Warning in download.file(paste(yahoo.URL, "s=", Symbols.name, "&a=",
## from.m, : downloaded length 14114 != reported length 200
## Warning in download.file(paste(yahoo.URL, "s=", Symbols.name, "&a=",
## from.m, : downloaded length 17293 != reported length 200
## Warning in download.file(paste(yahoo.URL, "s=", Symbols.name, "&a=",
## from.m, : downloaded length 12143 != reported length 200
## Warning in download.file(paste(yahoo.URL, "s=", Symbols.name, "&a=",
## from.m, : downloaded length 14114 != reported length 200
## Warning in download.file(paste(yahoo.URL, "s=", Symbols.name, "&a=",
## from.m, : downloaded length 14288 != reported length 200
## Warning in download.file(paste(yahoo.URL, "s=", Symbols.name, "&a=",
## from.m, : downloaded length 12257 != reported length 200
## pausing 1 second between requests for more than 5 symbols
## Warning in download.file(paste(yahoo.URL, "s=", Symbols.name, "&a=",
## from.m, : downloaded length 14353 != reported length 200
## pausing 1 second between requests for more than 5 symbols
## Warning in download.file(paste(yahoo.URL, "s=", Symbols.name, "&a=",
## from.m, : downloaded length 17293 != reported length 200
## Warning in download.file(paste(yahoo.URL, "s=", Symbols.name, "&a=",
## from.m, : downloaded length 12143 != reported length 200
## Warning in download.file(paste(yahoo.URL, "s=", Symbols.name, "&a=",
## from.m, : downloaded length 14114 != reported length 200
## Warning in download.file(paste(yahoo.URL, "s=", Symbols.name, "&a=",
## from.m, : downloaded length 14288 != reported length 200
## Warning in download.file(paste(yahoo.URL, "s=", Symbols.name, "&a=",
## from.m, : downloaded length 12257 != reported length 200
## pausing 1 second between requests for more than 5 symbols
## Warning in download.file(paste(yahoo.URL, "s=", Symbols.name, "&a=",
## from.m, : downloaded length 14353 != reported length 200
## pausing 1 second between requests for more than 5 symbols
## Warning in download.file(paste(yahoo.URL, "s=", Symbols.name, "&a=",
## from.m, : downloaded length 18400 != reported length 200
## pausing 1 second between requests for more than 5 symbols
## Warning in download.file(paste(yahoo.URL, "s=", Symbols.name, "&a=",
## from.m, : downloaded length 16940 != reported length 200
## pausing 1 second between requests for more than 5 symbols
## Warning in download.file(paste(yahoo.URL, "s=", Symbols.name, "&a=",
## from.m, : downloaded length 16689 != reported length 200
## pausing 1 second between requests for more than 5 symbols
##              [,1]
## [1,] 0.1251295748
## [2,] 1.0055443764
## [3,] 0.0006292142
## [[1]]

## 
## [[2]]
##          f_a_lower
## VFINX 0.1251295748
## VBTIX 1.0055443764
## VGSIX 0.0006292142
## 
## [[3]]
##            f_a_mid
## VFINX  0.247687964
## VBTIX  1.754718310
## VGSIX -0.002406274
## 
## [[4]]
##          f_a_upper
## VFINX 0.1251295748
## VBTIX 1.0055443764
## VGSIX 0.0006292142
## 
## [[5]]
##         f_ab_lower
## VFINX  0.126275000
## VBTIX  1.240661460
## VGSIX  0.001116260
## DFSTX -0.008930818
## VFITX -0.234944838
## DFEMX  0.009439252
## 
## [[6]]
##           f_ab_mid
## VFINX  0.246342142
## VBTIX  2.139125143
## VGSIX -0.002516954
## DFSTX -0.012475223
## VFITX -0.383270718
## DFEMX  0.012795610
## 
## [[7]]
##         f_ab_upper
## VFINX  0.126275000
## VBTIX  1.240661460
## VGSIX  0.001116260
## DFSTX -0.008930818
## VFITX -0.234944838
## DFEMX  0.009439252
## 
## [[8]]
##        f_abc_lower
## VFINX  0.098096130
## VBTIX  1.229208013
## VGSIX  0.001377113
## DFSTX -0.007057100
## VFITX -0.225745035
## DFEMX  0.011450017
## GOOGL -0.001264479
## XOM    0.027301254
## UPS    0.005254215
## 
## [[9]]
##          f_abc_mid
## VFINX  0.172424586
## VBTIX  2.112853770
## VGSIX -0.002230906
## DFSTX -0.008487861
## VFITX -0.363499289
## DFEMX  0.017378769
## GOOGL -0.002692524
## XOM    0.059480372
## UPS    0.014773084
## 
## [[10]]
##        f_abc_upper
## VFINX  0.098096130
## VBTIX  1.229208013
## VGSIX  0.001377113
## DFSTX -0.007057100
## VFITX -0.225745035
## DFEMX  0.011450017
## GOOGL -0.001264479
## XOM    0.027301254
## UPS    0.005254215

2013 tbill rate, 0.0029

plotRisk_abc("2013", 0.0029)
## Warning in download.file(paste(yahoo.URL, "s=", Symbols.name, "&a=",
## from.m, : downloaded length 17512 != reported length 200
## Warning in download.file(paste(yahoo.URL, "s=", Symbols.name, "&a=",
## from.m, : downloaded length 12267 != reported length 200
## Warning in download.file(paste(yahoo.URL, "s=", Symbols.name, "&a=",
## from.m, : downloaded length 14326 != reported length 200
## Warning in download.file(paste(yahoo.URL, "s=", Symbols.name, "&a=",
## from.m, : downloaded length 17512 != reported length 200
## Warning in download.file(paste(yahoo.URL, "s=", Symbols.name, "&a=",
## from.m, : downloaded length 12267 != reported length 200
## Warning in download.file(paste(yahoo.URL, "s=", Symbols.name, "&a=",
## from.m, : downloaded length 14326 != reported length 200
## Warning in download.file(paste(yahoo.URL, "s=", Symbols.name, "&a=",
## from.m, : downloaded length 14216 != reported length 200
## Warning in download.file(paste(yahoo.URL, "s=", Symbols.name, "&a=",
## from.m, : downloaded length 12373 != reported length 200
## pausing 1 second between requests for more than 5 symbols
## Warning in download.file(paste(yahoo.URL, "s=", Symbols.name, "&a=",
## from.m, : downloaded length 14385 != reported length 200
## pausing 1 second between requests for more than 5 symbols
## Warning in download.file(paste(yahoo.URL, "s=", Symbols.name, "&a=",
## from.m, : downloaded length 17512 != reported length 200
## Warning in download.file(paste(yahoo.URL, "s=", Symbols.name, "&a=",
## from.m, : downloaded length 12267 != reported length 200
## Warning in download.file(paste(yahoo.URL, "s=", Symbols.name, "&a=",
## from.m, : downloaded length 14326 != reported length 200
## Warning in download.file(paste(yahoo.URL, "s=", Symbols.name, "&a=",
## from.m, : downloaded length 14216 != reported length 200
## Warning in download.file(paste(yahoo.URL, "s=", Symbols.name, "&a=",
## from.m, : downloaded length 12373 != reported length 200
## pausing 1 second between requests for more than 5 symbols
## Warning in download.file(paste(yahoo.URL, "s=", Symbols.name, "&a=",
## from.m, : downloaded length 14385 != reported length 200
## pausing 1 second between requests for more than 5 symbols
## Warning in download.file(paste(yahoo.URL, "s=", Symbols.name, "&a=",
## from.m, : downloaded length 18715 != reported length 200
## pausing 1 second between requests for more than 5 symbols
## Warning in download.file(paste(yahoo.URL, "s=", Symbols.name, "&a=",
## from.m, : downloaded length 17099 != reported length 200
## pausing 1 second between requests for more than 5 symbols
## Warning in download.file(paste(yahoo.URL, "s=", Symbols.name, "&a=",
## from.m, : downloaded length 16965 != reported length 200
## pausing 1 second between requests for more than 5 symbols
##            [,1]
## [1,]  0.2142328
## [2,]  1.0658600
## [3,] -0.1833878
## [[1]]

## 
## [[2]]
##        f_a_lower
## VFINX  0.2142328
## VBTIX  1.0658600
## VGSIX -0.1833878
## 
## [[3]]
##          f_a_mid
## VFINX  0.3939054
## VBTIX  1.8716349
## VGSIX -0.2655404
## 
## [[4]]
##        f_a_upper
## VFINX  0.2142328
## VBTIX  1.0658600
## VGSIX -0.1833878
## 
## [[5]]
##        f_ab_lower
## VFINX  0.21014016
## VBTIX  1.20064607
## VGSIX -0.17672627
## DFSTX  0.01407489
## VFITX -0.12794237
## DFEMX -0.02737487
## 
## [[6]]
##          f_ab_mid
## VFINX  0.36813367
## VBTIX  2.12003688
## VGSIX -0.25850148
## DFSTX  0.02655171
## VFITX -0.23975395
## DFEMX -0.01646683
## 
## [[7]]
##        f_ab_upper
## VFINX  0.21014016
## VBTIX  1.20064607
## VGSIX -0.17672627
## DFSTX  0.01407489
## VFITX -0.12794237
## DFEMX -0.02737487
## 
## [[8]]
##        f_abc_lower
## VFINX  0.171987840
## VBTIX  1.200763459
## VGSIX -0.177000157
## DFSTX  0.016459031
## VFITX -0.137259655
## DFEMX -0.026734390
## GOOGL -0.003338473
## XOM    0.028375882
## UPS    0.028794855
## 
## [[9]]
##         f_abc_mid
## VFINX  0.30044177
## VBTIX  2.12099777
## VGSIX -0.26013773
## DFSTX  0.03470753
## VFITX -0.25442737
## DFEMX -0.01649101
## GOOGL -0.01091264
## XOM    0.05292360
## UPS    0.03289808
## 
## [[10]]
##        f_abc_upper
## VFINX  0.171987840
## VBTIX  1.200763459
## VGSIX -0.177000157
## DFSTX  0.016459031
## VFITX -0.137259655
## DFEMX -0.026734390
## GOOGL -0.003338473
## XOM    0.028375882
## UPS    0.028794855

2014 tbill rate, 0.0029

plotRisk_abc("2014", 0.0029)
## Warning in download.file(paste(yahoo.URL, "s=", Symbols.name, "&a=",
## from.m, : downloaded length 17512 != reported length 200
## Warning in download.file(paste(yahoo.URL, "s=", Symbols.name, "&a=",
## from.m, : downloaded length 12368 != reported length 200
## Warning in download.file(paste(yahoo.URL, "s=", Symbols.name, "&a=",
## from.m, : downloaded length 14236 != reported length 200
## Warning in download.file(paste(yahoo.URL, "s=", Symbols.name, "&a=",
## from.m, : downloaded length 17512 != reported length 200
## Warning in download.file(paste(yahoo.URL, "s=", Symbols.name, "&a=",
## from.m, : downloaded length 12368 != reported length 200
## Warning in download.file(paste(yahoo.URL, "s=", Symbols.name, "&a=",
## from.m, : downloaded length 14236 != reported length 200
## Warning in download.file(paste(yahoo.URL, "s=", Symbols.name, "&a=",
## from.m, : downloaded length 14245 != reported length 200
## Warning in download.file(paste(yahoo.URL, "s=", Symbols.name, "&a=",
## from.m, : downloaded length 12361 != reported length 200
## pausing 1 second between requests for more than 5 symbols
## Warning in download.file(paste(yahoo.URL, "s=", Symbols.name, "&a=",
## from.m, : downloaded length 14445 != reported length 200
## pausing 1 second between requests for more than 5 symbols
## Warning in download.file(paste(yahoo.URL, "s=", Symbols.name, "&a=",
## from.m, : downloaded length 17512 != reported length 200
## Warning in download.file(paste(yahoo.URL, "s=", Symbols.name, "&a=",
## from.m, : downloaded length 12368 != reported length 200
## Warning in download.file(paste(yahoo.URL, "s=", Symbols.name, "&a=",
## from.m, : downloaded length 14236 != reported length 200
## Warning in download.file(paste(yahoo.URL, "s=", Symbols.name, "&a=",
## from.m, : downloaded length 14245 != reported length 200
## Warning in download.file(paste(yahoo.URL, "s=", Symbols.name, "&a=",
## from.m, : downloaded length 12361 != reported length 200
## pausing 1 second between requests for more than 5 symbols
## Warning in download.file(paste(yahoo.URL, "s=", Symbols.name, "&a=",
## from.m, : downloaded length 14445 != reported length 200
## pausing 1 second between requests for more than 5 symbols
## Warning in download.file(paste(yahoo.URL, "s=", Symbols.name, "&a=",
## from.m, : downloaded length 18297 != reported length 200
## pausing 1 second between requests for more than 5 symbols
## Warning in download.file(paste(yahoo.URL, "s=", Symbols.name, "&a=",
## from.m, : downloaded length 17289 != reported length 200
## pausing 1 second between requests for more than 5 symbols
## Warning in download.file(paste(yahoo.URL, "s=", Symbols.name, "&a=",
## from.m, : downloaded length 17345 != reported length 200
## pausing 1 second between requests for more than 5 symbols
##             [,1]
## [1,]  0.15006224
## [2,]  1.02067004
## [3,] -0.04888183
## [[1]]

## 
## [[2]]
##         f_a_lower
## VFINX  0.15006224
## VBTIX  1.02067004
## VGSIX -0.04888183
## 
## [[3]]
##           f_a_mid
## VFINX  0.30267551
## VBTIX  1.78318930
## VGSIX -0.08586481
## 
## [[4]]
##         f_a_upper
## VFINX  0.15006224
## VBTIX  1.02067004
## VGSIX -0.04888183
## 
## [[5]]
##        f_ab_lower
## VFINX  0.12623011
## VBTIX  1.11861405
## VGSIX -0.04846512
## DFSTX  0.01101089
## VFITX -0.09769277
## DFEMX  0.01596690
## 
## [[6]]
##          f_ab_mid
## VFINX  0.23733116
## VBTIX  1.91070417
## VGSIX -0.08799019
## DFSTX  0.03245897
## VFITX -0.12736467
## DFEMX  0.03486057
## 
## [[7]]
##        f_ab_upper
## VFINX  0.12623011
## VBTIX  1.11861405
## VGSIX -0.04846512
## DFSTX  0.01101089
## VFITX -0.09769277
## DFEMX  0.01596690
## 
## [[8]]
##         f_abc_lower
## VFINX  0.0991744375
## VBTIX  1.1316349859
## VGSIX -0.0469831717
## DFSTX  0.0131815707
## VFITX -0.1135679523
## DFEMX  0.0135673006
## GOOGL  0.0005312395
## XOM    0.0095230531
## UPS    0.0250388729
## 
## [[9]]
##          f_abc_mid
## VFINX  0.171944728
## VBTIX  1.939225886
## VGSIX -0.085172837
## DFSTX  0.036849406
## VFITX -0.160955511
## DFEMX  0.029363397
## GOOGL  0.002573994
## XOM    0.024047103
## UPS    0.042123833
## 
## [[10]]
##         f_abc_upper
## VFINX  0.0991744375
## VBTIX  1.1316349859
## VGSIX -0.0469831717
## DFSTX  0.0131815707
## VFITX -0.1135679523
## DFEMX  0.0135673006
## GOOGL  0.0005312395
## XOM    0.0095230531
## UPS    0.0250388729

2015 tbill rate, 0.0029

plotRisk_abc("2015", 0.0029)
## Warning in download.file(paste(yahoo.URL, "s=", Symbols.name, "&a=",
## from.m, : downloaded length 17446 != reported length 200
## Warning in download.file(paste(yahoo.URL, "s=", Symbols.name, "&a=",
## from.m, : downloaded length 12351 != reported length 200
## Warning in download.file(paste(yahoo.URL, "s=", Symbols.name, "&a=",
## from.m, : downloaded length 14159 != reported length 200
## Warning in download.file(paste(yahoo.URL, "s=", Symbols.name, "&a=",
## from.m, : downloaded length 17446 != reported length 200
## Warning in download.file(paste(yahoo.URL, "s=", Symbols.name, "&a=",
## from.m, : downloaded length 12351 != reported length 200
## Warning in download.file(paste(yahoo.URL, "s=", Symbols.name, "&a=",
## from.m, : downloaded length 14159 != reported length 200
## Warning in download.file(paste(yahoo.URL, "s=", Symbols.name, "&a=",
## from.m, : downloaded length 14651 != reported length 200
## Warning in download.file(paste(yahoo.URL, "s=", Symbols.name, "&a=",
## from.m, : downloaded length 12360 != reported length 200
## pausing 1 second between requests for more than 5 symbols
## Warning in download.file(paste(yahoo.URL, "s=", Symbols.name, "&a=",
## from.m, : downloaded length 14243 != reported length 200
## pausing 1 second between requests for more than 5 symbols
## Warning in download.file(paste(yahoo.URL, "s=", Symbols.name, "&a=",
## from.m, : downloaded length 17446 != reported length 200
## Warning in download.file(paste(yahoo.URL, "s=", Symbols.name, "&a=",
## from.m, : downloaded length 12351 != reported length 200
## Warning in download.file(paste(yahoo.URL, "s=", Symbols.name, "&a=",
## from.m, : downloaded length 14159 != reported length 200
## Warning in download.file(paste(yahoo.URL, "s=", Symbols.name, "&a=",
## from.m, : downloaded length 14651 != reported length 200
## Warning in download.file(paste(yahoo.URL, "s=", Symbols.name, "&a=",
## from.m, : downloaded length 12360 != reported length 200
## pausing 1 second between requests for more than 5 symbols
## Warning in download.file(paste(yahoo.URL, "s=", Symbols.name, "&a=",
## from.m, : downloaded length 14243 != reported length 200
## pausing 1 second between requests for more than 5 symbols
## Warning in download.file(paste(yahoo.URL, "s=", Symbols.name, "&a=",
## from.m, : downloaded length 17989 != reported length 200
## pausing 1 second between requests for more than 5 symbols
## Warning in download.file(paste(yahoo.URL, "s=", Symbols.name, "&a=",
## from.m, : downloaded length 17058 != reported length 200
## pausing 1 second between requests for more than 5 symbols
## Warning in download.file(paste(yahoo.URL, "s=", Symbols.name, "&a=",
## from.m, : downloaded length 17452 != reported length 200
## pausing 1 second between requests for more than 5 symbols
##            [,1]
## [1,]  0.1898340
## [2,]  1.0511537
## [3,] -0.1350449
## [[1]]

## 
## [[2]]
##        f_a_lower
## VFINX  0.1898340
## VBTIX  1.0511537
## VGSIX -0.1350449
## 
## [[3]]
##          f_a_mid
## VFINX  0.3780445
## VBTIX  1.8288902
## VGSIX -0.2069347
## 
## [[4]]
##        f_a_upper
## VFINX  0.1898340
## VBTIX  1.0511537
## VGSIX -0.1350449
## 
## [[5]]
##        f_ab_lower
## VFINX  0.11617202
## VBTIX  1.14452683
## VGSIX -0.12668353
## DFSTX  0.06289877
## VFITX -0.10384550
## DFEMX  0.01746913
## 
## [[6]]
##          f_ab_mid
## VFINX  0.21029636
## VBTIX  2.04714811
## VGSIX -0.19260000
## DFSTX  0.13298862
## VFITX -0.23998422
## DFEMX  0.04215113
## 
## [[7]]
##        f_ab_upper
## VFINX  0.11617202
## VBTIX  1.14452683
## VGSIX -0.12668353
## DFSTX  0.06289877
## VFITX -0.10384550
## DFEMX  0.01746913
## 
## [[8]]
##       f_abc_lower
## VFINX  0.12326353
## VBTIX  1.11153540
## VGSIX -0.13095766
## DFSTX  0.05739342
## VFITX -0.07465465
## DFEMX  0.02079696
## GOOGL -0.01224015
## XOM   -0.01859777
## UPS    0.04011635
## 
## [[9]]
##         f_abc_mid
## VFINX  0.22587774
## VBTIX  1.99400923
## VGSIX -0.19966690
## DFSTX  0.11944225
## VFITX -0.19323536
## DFEMX  0.04531656
## GOOGL -0.03080244
## XOM   -0.02826249
## UPS    0.06732140
## 
## [[10]]
##       f_abc_upper
## VFINX  0.12326353
## VBTIX  1.11153540
## VGSIX -0.13095766
## DFSTX  0.05739342
## VFITX -0.07465465
## DFEMX  0.02079696
## GOOGL -0.01224015
## XOM   -0.01859777
## UPS    0.04011635