# import data
# read.csv()
# read_csv(): package readr
library(readr)
library(xts)
## Loading required package: zoo
##
## Attaching package: 'zoo'
## The following objects are masked from 'package:base':
##
## as.Date, as.Date.numeric
library(SIT)
## Loading required package: SIT.date
## Loading required package: quantmod
## Loading required package: TTR
## Registered S3 method overwritten by 'quantmod':
## method from
## as.zoo.data.frame zoo
##
## Attaching package: 'SIT'
## The following object is masked from 'package:TTR':
##
## DVI
## The following object is masked from 'package:base':
##
## close
etf4.df <- read.csv('myetf4.csv')
str(etf4.df)
## 'data.frame': 751 obs. of 5 variables:
## $ Index : chr "2015-12-14" "2015-12-15" "2015-12-16" "2015-12-17" ...
## $ X0050 : num 53.3 53.3 54.1 54.8 54.5 ...
## $ X0056 : num 18.2 18.4 18.6 18.8 18.9 ...
## $ X006205: num 31.1 31.6 31.6 32.2 32.2 ...
## $ X00646 : num 19.6 19.6 19.9 20.1 19.9 ...
etf4 <- read_csv('myetf4.csv')
##
## ── Column specification ───────────────────────────────────────────────────────────────────
## cols(
## Index = col_date(format = ""),
## `0050` = col_double(),
## `0056` = col_double(),
## `006205` = col_double(),
## `00646` = col_double()
## )
str(etf4)
## tibble [751 × 5] (S3: spec_tbl_df/tbl_df/tbl/data.frame)
## $ Index : Date[1:751], format: "2015-12-14" "2015-12-15" ...
## $ 0050 : num [1:751] 53.3 53.3 54.1 54.8 54.5 ...
## $ 0056 : num [1:751] 18.2 18.4 18.6 18.8 18.9 ...
## $ 006205: num [1:751] 31.1 31.6 31.6 32.2 32.2 ...
## $ 00646 : num [1:751] 19.6 19.6 19.9 20.1 19.9 ...
## - attr(*, "spec")=
## .. cols(
## .. Index = col_date(format = ""),
## .. `0050` = col_double(),
## .. `0056` = col_double(),
## .. `006205` = col_double(),
## .. `00646` = col_double()
## .. )
head(etf4)
## # A tibble: 6 x 5
## Index `0050` `0056` `006205` `00646`
## <date> <dbl> <dbl> <dbl> <dbl>
## 1 2015-12-14 53.3 18.2 31.1 19.6
## 2 2015-12-15 53.3 18.4 31.6 19.6
## 3 2015-12-16 54.1 18.6 31.6 19.9
## 4 2015-12-17 54.8 18.8 32.2 20.0
## 5 2015-12-18 54.5 19.0 32.2 19.8
## 6 2015-12-21 54.4 19.0 33 19.6
library(magrittr)
##
## Attaching package: 'magrittr'
## The following object is masked from 'package:SIT':
##
## add
# using pipe %>%
library(PerformanceAnalytics)
##
## Attaching package: 'PerformanceAnalytics'
## The following object is masked from 'package:graphics':
##
## legend
# Convert Data into XTS
etf4.xts <- xts(etf4[, -1], order.by = etf4$Index)
head(etf4.xts)
## 0050 0056 006205 00646
## 2015-12-14 53.29 18.25 31.06 19.61
## 2015-12-15 53.33 18.38 31.59 19.63
## 2015-12-16 54.14 18.56 31.60 19.89
## 2015-12-17 54.77 18.81 32.23 20.05
## 2015-12-18 54.50 18.95 32.18 19.85
## 2015-12-21 54.41 19.02 33.00 19.64
etf4.ret <- etf4.xts %>% Return.calculate() %>% na.omit()
head(etf4.ret)
## 0050 0056 006205 00646
## 2015-12-15 0.0007506099 0.007123288 0.0170637476 0.001019888
## 2015-12-16 0.0151884493 0.009793254 0.0003165559 0.013245033
## 2015-12-17 0.0116364980 0.013469828 0.0199367089 0.008044243
## 2015-12-18 -0.0049297060 0.007442850 -0.0015513497 -0.009975062
## 2015-12-21 -0.0016513761 0.003693931 0.0254816656 -0.010579345
## 2015-12-22 0.0023892667 -0.003680336 0.0030303030 0.004073320
# Compute the Average Return and Covariance Matrix
etf4.mean.ret <- apply(etf4.ret,2,"mean")
head(etf4.mean.ret)
## 0050 0056 006205 00646
## 0.0004632227 0.0003846366 -0.0002118311 0.0002554122
# Arithmetic Mean
Mean.arithmetic(etf4.ret)
## 0050 0056 006205 00646
## Arithmetic Mean 0.0004632227 0.0003846366 -0.0002118311 0.0002554122
cov(etf4.ret)
## 0050 0056 006205 00646
## 0050 7.837060e-05 4.559164e-05 4.467258e-05 3.663388e-05
## 0056 4.559164e-05 4.526413e-05 2.673674e-05 2.353543e-05
## 006205 4.467258e-05 2.673674e-05 1.304184e-04 2.910367e-05
## 00646 3.663388e-05 2.353543e-05 2.910367e-05 5.902892e-05
# Compute Optimal weights for 4 ETFs based on daily returns of the period
ETF.names <- c("0050", "0056", "006205", "00646")
mu.vec = c(0.0004632227, 0.0003846366, -0.0002118311, 0.0002554122)
names(mu.vec) = ETF.names
sigma.mat = matrix(c(7.837060e-05, 4.559164e-05, 4.467258e-05, 3.663388e-05,
4.559164e-05, 4.526413e-05, 2.673674e-05, 2.353543e-05,
4.467258e-05, 2.673674e-05, 1.304184e-04, 2.910367e-05,
3.663388e-05, 2.353543e-05, 2.910367e-05, 5.902892e-05),
nrow=4, ncol=4)
dimnames(sigma.mat) = list(ETF.names, ETF.names)
mu.vec
## 0050 0056 006205 00646
## 0.0004632227 0.0003846366 -0.0002118311 0.0002554122
sigma.mat
## 0050 0056 006205 00646
## 0050 7.837060e-05 4.559164e-05 4.467258e-05 3.663388e-05
## 0056 4.559164e-05 4.526413e-05 2.673674e-05 2.353543e-05
## 006205 4.467258e-05 2.673674e-05 1.304184e-04 2.910367e-05
## 00646 3.663388e-05 2.353543e-05 2.910367e-05 5.902892e-05
x.vec = rep(1,4)/4
names(x.vec) = ETF.names
mu.p.x = crossprod (x.vec,mu.vec)
sig2.p.x = t(x.vec) %*% sigma.mat %*%x.vec
sig.p.x = sqrt ( sig2.p.x)
mu.p.x
## [,1]
## [1,] 0.0002228601
sig.p.x
## [,1]
## [1,] 0.00673438
# Compute minimum variance portfolio (Daily)
top.mat = cbind(2*sigma.mat, rep(1, 4))
bot.vec = c(rep(1, 4), 0)
Am.mat = rbind(top.mat, bot.vec)
b.vec = c(rep(0, 4), 1)
z.m.mat = solve(Am.mat)%*%b.vec
m.vec = z.m.mat [1:4,1]
m.vec
## 0050 0056 006205 00646
## -0.2193578 0.7283718 0.1076234 0.3833627
# Portfolio Return and Standard Deviation
mu.gmin = as.numeric(crossprod(m.vec, mu.vec))
mu.gmin
## [1] 0.0002536644
sig2.gmin = as.numeric(t(m.vec)%*%sigma.mat%*%m.vec)
sig.gmin = sqrt(sig2.gmin)
sig.gmin
## [1] 0.005904942
# Convert into Monthly Frequency
etf4.mon.ret <- etf4.xts %>% to.monthly(indexAt = 'lastof', OHLC = FALSE) %>%
Return.calculate() %>% na.omit
head(etf4.mon.ret)
## 0050 0056 006205 00646
## 2016-01-31 -0.01981651 -0.013785790 -0.173070915 -0.038883350
## 2016-02-29 0.02864096 0.043548387 -0.027578391 -0.003630705
## 2016-03-31 0.05550500 -0.002575992 0.082750583 0.026028110
## 2016-04-30 -0.04724138 -0.037190083 -0.024757804 0.009639777
## 2016-05-31 0.02515382 0.016630901 0.004415011 0.022110553
## 2016-06-30 0.03636364 0.029551451 -0.025641026 -0.026057030
# compute average returns and covariance matrix
Mean.arithmetic(etf4.mon.ret)
## 0050 0056 006205 00646
## Arithmetic Mean 0.008819836 0.007086721 -0.005355481 0.00451063
cov(etf4.mon.ret)
## 0050 0056 006205 00646
## 0050 0.0011751458 0.0008661004 0.0008472189 0.0003928466
## 0056 0.0008661004 0.0009080806 0.0005553289 0.0003572509
## 006205 0.0008472189 0.0005553289 0.0024412877 0.0006736296
## 00646 0.0003928466 0.0003572509 0.0006736296 0.0008605161
# compute optimal weights for 4 ETFs based on monthly returns of the period
ETF.names <- c("0050", "0056", "006205", "00646")
mu.vec = c(0.008819836, 0.007086721, -0.005355481, 0.00451063)
names(mu.vec) = ETF.names
sigma.mat = matrix(c(0.0011751458, 0.0008661004, 0.0008472189, 0.0003928466,
0.0008661004, 0.0009080806, 0.0005553289, 0.0003572509,
0.0008472189, 0.0005553289, 0.0024412877, 0.0006736296,
0.0003928466, 0.0003572509, 0.0006736296, 0.0008605161) ,
nrow=4, ncol=4)
dimnames(sigma.mat) = list(ETF.names, ETF.names)
mu.vec
## 0050 0056 006205 00646
## 0.008819836 0.007086721 -0.005355481 0.004510630
sigma.mat
## 0050 0056 006205 00646
## 0050 0.0011751458 0.0008661004 0.0008472189 0.0003928466
## 0056 0.0008661004 0.0009080806 0.0005553289 0.0003572509
## 006205 0.0008472189 0.0005553289 0.0024412877 0.0006736296
## 00646 0.0003928466 0.0003572509 0.0006736296 0.0008605161
x.vec = rep(1,4)/4
names(x.vec) = ETF.names
mu.p.x = crossprod (x.vec,mu.vec)
sig2.p.x = t(x.vec) %*% sigma.mat %*%x.vec
sig.p.x = sqrt ( sig2.p.x)
mu.p.x
## [,1]
## [1,] 0.003765426
sig.p.x
## [,1]
## [1,] 0.02825086
# Compute minimum variance portfolio (monthly)
top.mat = cbind(2*sigma.mat, rep(1, 4))
bot.vec = c(rep(1, 4), 0)
Am.mat = rbind(top.mat, bot.vec)
b.vec = c(rep(0, 4), 1)
z.m.mat = solve(Am.mat)%*%b.vec
m.vec = z.m.mat [1:4,1]
m.vec
## 0050 0056 006205 00646
## 0.003183681 0.474049222 0.001203766 0.521563330
#portfolio return and standard deviation
mu.gmin = as.numeric(crossprod(m.vec, mu.vec))
mu.gmin
## [1] 0.005733667
sig2.gmin = as.numeric(t(m.vec)%*%sigma.mat%*%m.vec)
sig.gmin = sqrt(sig2.gmin)
sig.gmin
## [1] 0.02490441
#Compute Tangency Portfolio
rf = 0.00
sigma.inv.mat = solve(sigma.mat)
one.vec = rep(1, 4)
mu.minus.rf = mu.vec - rf*one.vec
top.mat = sigma.inv.mat%*%mu.minus.rf
bot.val = as.numeric(t(one.vec)%*%top.mat)
t.vec = top.mat[, 1]/bot.val
t.vec
## 0050 0056 006205 00646
## 1.3050536 -0.1576806 -0.8475320 0.7001591
#Expected Return and Standard Deviation
mu.t = as.numeric(crossprod(t.vec , mu.vec))
mu.t
## [1] 0.01809002
#Plot of Efficient Frontier
return <- etf4.mon.ret[,2:4]
frontier <- function(return){
Sigma <- cov(return)
mu.vec <- colMeans(return)
#return <- log(tail(assets, -1) / head(assets, -1))
n <- ncol(return)
top.mat <- cbind(2*Sigma, mu.vec, rep(1, 4))
mid.vec <- c(mu.vec, 0, 0)
bot.vec <- c(rep(1, 4), 0, 0)
A.mat <- rbind(top.mat, mid.vec, bot.vec)
rbase <- seq(min(mu.vec), max(mu.vec), length = 100)
s <- sapply(rbase, function(x) {
b.vec <- c(rep(0, n), x, 1)
z.mat <- solve(A.mat)%*%b.vec
w.r0 <- z.mat[1:3,]
sqrt(w.r0%*%Sigma%*%w.r0)
})
plot(s, rbase, xlab = 'Std', ylab = 'Return')
}
frontier(return)
## Warning in cbind(2 * Sigma, mu.vec, rep(1, 4)): number of rows of result is not
## a multiple of vector length (arg 3)
## Warning in rbind(top.mat, mid.vec, bot.vec): number of columns of result is not
## a multiple of vector length (arg 3)

library(SIT)
#creating constraints
n <- dim(etf4.xts)[2]
constraints = new.constraints(n, lb = -Inf, ub = +Inf)
# SUM x.i = 1
constraints = add.constraints(rep(1, n), 1, type = '=', constraints)
ia <- create.historical.ia(etf4.xts, 4)
names(ia)
## [1] "hist.returns" "nperiod" "index"
## [4] "n" "symbols" "risk"
## [7] "correlation" "cov" "expected.return"
## [10] "annual.factor" "arithmetic.return" "geometric.return"
#s0 <- apply(coredata(etf4.xts),2,sd)
#ia$cov <- cor(coredata(etf4.xts), use='complete.obs',method='pearson') * (s0 %*% t(s0))
weight <- min.risk.portfolio(ia, constraints)
## Loading required package: kernlab
##
## Attaching package: 'kernlab'
## The following object is masked from 'package:SIT':
##
## cross
weight
## [1] -0.28080456 1.07989097 0.13606491 0.06484868
#===================================================
# Try to plot efficient frontier using SIT
# create sample historical input assumptions
ia <- create.historical.ia(etf4.xts, 4)
# 0 <= x.i <= 1
# If short sale allowed: constraints = new.constraints(n, lb = -Inf, ub = +Inf)
constraints = new.constraints(n, lb = 0, ub = 1)
constraints = add.constraints(diag(n), type='>=', b=0, constraints)
constraints = add.constraints(diag(n), type='<=', b=1, constraints)
# SUM x.i = 1
constraints = add.constraints(rep(1, n), 1, type = '=', constraints)
#
weight <- min.risk.portfolio(ia, constraints)
# create efficient frontier
ifelse(!require(corpcor), install.packages("corpcor"), library(corpcor))
## Loading required package: corpcor
##
## Attaching package: 'corpcor'
## The following object is masked from 'package:SIT':
##
## cov.shrink
## [1] "corpcor"
ifelse(!require(lpSolve), install.packages("lpSolve"), library(lpSolve))
## Loading required package: lpSolve
## [1] "lpSolve"
ef = portopt(ia, constraints, 50, 'Efficient Frontier')
## Warning in if (class(val) == "try-error") return(FALSE) else return(TRUE): the
## condition has length > 1 and only the first element will be used
ef
## $weight
## 0050 0056 006205 00646
## [1,] 0.00000000 1.314039e-01 0.42886475 4.397313e-01
## [2,] 0.01918755 3.006301e-02 0.48624313 4.645063e-01
## [3,] 0.03910026 6.938894e-18 0.50414890 4.567508e-01
## [4,] 0.05908026 0.000000e+00 0.51805117 4.228686e-01
## [5,] 0.07906025 -2.775558e-17 0.53195343 3.889863e-01
## [6,] 0.09904025 0.000000e+00 0.54585569 3.551041e-01
## [7,] 0.11902024 0.000000e+00 0.55975795 3.212218e-01
## [8,] 0.13900024 0.000000e+00 0.57366021 2.873396e-01
## [9,] 0.15898023 0.000000e+00 0.58756247 2.534573e-01
## [10,] 0.17896023 0.000000e+00 0.60146473 2.195750e-01
## [11,] 0.19894022 0.000000e+00 0.61536699 1.856928e-01
## [12,] 0.21892022 -1.110223e-16 0.62926925 1.518105e-01
## [13,] 0.23890021 0.000000e+00 0.64317151 1.179283e-01
## [14,] 0.25888021 0.000000e+00 0.65707377 8.404603e-02
## [15,] 0.27886020 0.000000e+00 0.67097603 5.016377e-02
## [16,] 0.29884020 0.000000e+00 0.68487829 1.628152e-02
## [17,] 0.31915865 0.000000e+00 0.68084135 0.000000e+00
## [18,] 0.33979021 0.000000e+00 0.66020979 0.000000e+00
## [19,] 0.36042177 0.000000e+00 0.63957823 0.000000e+00
## [20,] 0.38105332 2.220446e-16 0.61894668 0.000000e+00
## [21,] 0.40168488 0.000000e+00 0.59831512 0.000000e+00
## [22,] 0.42231643 0.000000e+00 0.57768357 0.000000e+00
## [23,] 0.44294799 0.000000e+00 0.55705201 0.000000e+00
## [24,] 0.46357955 0.000000e+00 0.53642045 0.000000e+00
## [25,] 0.48421110 2.220446e-16 0.51578890 0.000000e+00
## [26,] 0.50484266 -1.294954e-15 0.49515734 -2.220446e-16
## [27,] 0.52547421 -1.318099e-15 0.47452579 2.220446e-16
## [28,] 0.54610577 -1.341244e-15 0.45389423 0.000000e+00
## [29,] 0.56673733 -1.364389e-15 0.43326267 0.000000e+00
## [30,] 0.58736888 -1.387534e-15 0.41263112 0.000000e+00
## [31,] 0.60800044 -9.665902e-16 0.39199956 0.000000e+00
## [32,] 0.62863199 1.972152e-31 0.37136801 3.142644e-31
## [33,] 0.64926355 0.000000e+00 0.35073645 3.193373e-31
## [34,] 0.66989511 0.000000e+00 0.33010489 3.244102e-31
## [35,] 0.69052666 0.000000e+00 0.30947334 3.294831e-31
## [36,] 0.71115822 -1.082315e-15 0.28884178 0.000000e+00
## [37,] 0.73178977 -1.105460e-15 0.26821023 0.000000e+00
## [38,] 0.75242133 0.000000e+00 0.24757867 3.447018e-31
## [39,] 0.77305288 0.000000e+00 0.22694712 3.497747e-31
## [40,] 0.79368444 0.000000e+00 0.20631556 4.521827e-31
## [41,] 0.81431600 0.000000e+00 0.18568400 4.572556e-31
## [42,] 0.83494755 0.000000e+00 0.16505245 3.649935e-31
## [43,] 0.85557911 0.000000e+00 0.14442089 3.700664e-31
## [44,] 0.87621066 1.972152e-31 0.12378934 3.751393e-31
## [45,] 0.89684222 -1.290621e-15 0.10315778 0.000000e+00
## [46,] 0.91747378 1.972152e-31 0.08252622 3.852851e-31
## [47,] 0.93810533 0.000000e+00 0.06189467 3.903580e-31
## [48,] 0.95873689 0.000000e+00 0.04126311 3.954309e-31
## [49,] 0.97936844 0.000000e+00 0.02063156 4.005038e-31
## [50,] 1.00000000 0.000000e+00 0.00000000 0.000000e+00
##
## $return
## [,1]
## [1,] 507267.6
## [2,] 1027894.3
## [3,] 1548521.0
## [4,] 2069147.8
## [5,] 2589774.5
## [6,] 3110401.2
## [7,] 3631028.0
## [8,] 4151654.7
## [9,] 4672281.5
## [10,] 5192908.2
## [11,] 5713534.9
## [12,] 6234161.7
## [13,] 6754788.4
## [14,] 7275415.1
## [15,] 7796041.9
## [16,] 8316668.6
## [17,] 8837295.4
## [18,] 9357922.1
## [19,] 9878548.8
## [20,] 10399175.6
## [21,] 10919802.3
## [22,] 11440429.0
## [23,] 11961055.8
## [24,] 12481682.5
## [25,] 13002309.3
## [26,] 13522936.0
## [27,] 14043562.7
## [28,] 14564189.5
## [29,] 15084816.2
## [30,] 15605442.9
## [31,] 16126069.7
## [32,] 16646696.4
## [33,] 17167323.2
## [34,] 17687949.9
## [35,] 18208576.6
## [36,] 18729203.4
## [37,] 19249830.1
## [38,] 19770456.8
## [39,] 20291083.6
## [40,] 20811710.3
## [41,] 21332337.1
## [42,] 21852963.8
## [43,] 22373590.5
## [44,] 22894217.3
## [45,] 23414844.0
## [46,] 23935470.7
## [47,] 24456097.5
## [48,] 24976724.2
## [49,] 25497350.9
## [50,] 26017977.7
##
## $risk
## [1] 3.727698 3.975622 4.228855 4.485789 4.746138 5.009368 5.275049
## [8] 5.542829 5.812417 6.083573 6.356097 6.629819 6.904597 7.180310
## [15] 7.456854 7.734140 8.012689 8.295578 8.582855 8.874095 9.168919
## [22] 9.466993 9.768019 10.071733 10.377898 10.686305 10.996763 11.309105
## [29] 11.623179 11.938847 12.255987 12.574487 12.894247 13.215175 13.537187
## [36] 13.860209 14.184172 14.509012 14.834671 15.161098 15.488243 15.816062
## [43] 16.144514 16.473560 16.803167 17.133301 17.463933 17.795035 18.126582
## [50] 18.458549
##
## $name
## [1] "Efficient Frontier"
# Create Plot
#******************************************************************
# plot efficient frontier
plot.ef(ia, list(ef), transition.map=F)
# find maximum sharpe portfolio
max(portfolio.return(ef$weight,ia) / portfolio.risk(ef$weight,ia))
## [1] 1409535
# plot minimum variance portfolio
weight = min.var.portfolio(ia,constraints)
points(50 * portfolio.risk(weight,ia), 50 * portfolio.return(weight,ia), pch=15, col='red')
portfolio.return(weight,ia) / portfolio.risk(weight,ia)
## [,1]
## [1,] 136080.6
# plot maximum Sharpe or tangency portfolio
weight = max.sharpe.portfolio()(ia,constraints)
points(50 * portfolio.risk(weight,ia), 50 * portfolio.return(weight,ia), pch=15, col='orange')
portfolio.return(weight,ia) / portfolio.risk(weight,ia)
## [,1]
## [1,] 1409535
plota.legend('Minimum Variance,Maximum Sharpe','red,orange', x='topright')

# create efficient frontier
ef = portopt(ia, constraints, 50, 'Efficient Frontier')
## Warning in if (class(val) == "try-error") return(FALSE) else return(TRUE): the
## condition has length > 1 and only the first element will be used
ef
## $weight
## 0050 0056 006205 00646
## [1,] 0.00000000 1.314039e-01 0.42886475 4.397313e-01
## [2,] 0.01918755 3.006301e-02 0.48624313 4.645063e-01
## [3,] 0.03910026 6.938894e-18 0.50414890 4.567508e-01
## [4,] 0.05908026 0.000000e+00 0.51805117 4.228686e-01
## [5,] 0.07906025 -2.775558e-17 0.53195343 3.889863e-01
## [6,] 0.09904025 0.000000e+00 0.54585569 3.551041e-01
## [7,] 0.11902024 0.000000e+00 0.55975795 3.212218e-01
## [8,] 0.13900024 0.000000e+00 0.57366021 2.873396e-01
## [9,] 0.15898023 0.000000e+00 0.58756247 2.534573e-01
## [10,] 0.17896023 0.000000e+00 0.60146473 2.195750e-01
## [11,] 0.19894022 0.000000e+00 0.61536699 1.856928e-01
## [12,] 0.21892022 -1.110223e-16 0.62926925 1.518105e-01
## [13,] 0.23890021 0.000000e+00 0.64317151 1.179283e-01
## [14,] 0.25888021 0.000000e+00 0.65707377 8.404603e-02
## [15,] 0.27886020 0.000000e+00 0.67097603 5.016377e-02
## [16,] 0.29884020 0.000000e+00 0.68487829 1.628152e-02
## [17,] 0.31915865 0.000000e+00 0.68084135 0.000000e+00
## [18,] 0.33979021 0.000000e+00 0.66020979 0.000000e+00
## [19,] 0.36042177 0.000000e+00 0.63957823 0.000000e+00
## [20,] 0.38105332 2.220446e-16 0.61894668 0.000000e+00
## [21,] 0.40168488 0.000000e+00 0.59831512 0.000000e+00
## [22,] 0.42231643 0.000000e+00 0.57768357 0.000000e+00
## [23,] 0.44294799 0.000000e+00 0.55705201 0.000000e+00
## [24,] 0.46357955 0.000000e+00 0.53642045 0.000000e+00
## [25,] 0.48421110 2.220446e-16 0.51578890 0.000000e+00
## [26,] 0.50484266 -1.294954e-15 0.49515734 -2.220446e-16
## [27,] 0.52547421 -1.318099e-15 0.47452579 2.220446e-16
## [28,] 0.54610577 -1.341244e-15 0.45389423 0.000000e+00
## [29,] 0.56673733 -1.364389e-15 0.43326267 0.000000e+00
## [30,] 0.58736888 -1.387534e-15 0.41263112 0.000000e+00
## [31,] 0.60800044 -9.665902e-16 0.39199956 0.000000e+00
## [32,] 0.62863199 1.972152e-31 0.37136801 3.142644e-31
## [33,] 0.64926355 0.000000e+00 0.35073645 3.193373e-31
## [34,] 0.66989511 0.000000e+00 0.33010489 3.244102e-31
## [35,] 0.69052666 0.000000e+00 0.30947334 3.294831e-31
## [36,] 0.71115822 -1.082315e-15 0.28884178 0.000000e+00
## [37,] 0.73178977 -1.105460e-15 0.26821023 0.000000e+00
## [38,] 0.75242133 0.000000e+00 0.24757867 3.447018e-31
## [39,] 0.77305288 0.000000e+00 0.22694712 3.497747e-31
## [40,] 0.79368444 0.000000e+00 0.20631556 4.521827e-31
## [41,] 0.81431600 0.000000e+00 0.18568400 4.572556e-31
## [42,] 0.83494755 0.000000e+00 0.16505245 3.649935e-31
## [43,] 0.85557911 0.000000e+00 0.14442089 3.700664e-31
## [44,] 0.87621066 1.972152e-31 0.12378934 3.751393e-31
## [45,] 0.89684222 -1.290621e-15 0.10315778 0.000000e+00
## [46,] 0.91747378 1.972152e-31 0.08252622 3.852851e-31
## [47,] 0.93810533 0.000000e+00 0.06189467 3.903580e-31
## [48,] 0.95873689 0.000000e+00 0.04126311 3.954309e-31
## [49,] 0.97936844 0.000000e+00 0.02063156 4.005038e-31
## [50,] 1.00000000 0.000000e+00 0.00000000 0.000000e+00
##
## $return
## [,1]
## [1,] 507267.6
## [2,] 1027894.3
## [3,] 1548521.0
## [4,] 2069147.8
## [5,] 2589774.5
## [6,] 3110401.2
## [7,] 3631028.0
## [8,] 4151654.7
## [9,] 4672281.5
## [10,] 5192908.2
## [11,] 5713534.9
## [12,] 6234161.7
## [13,] 6754788.4
## [14,] 7275415.1
## [15,] 7796041.9
## [16,] 8316668.6
## [17,] 8837295.4
## [18,] 9357922.1
## [19,] 9878548.8
## [20,] 10399175.6
## [21,] 10919802.3
## [22,] 11440429.0
## [23,] 11961055.8
## [24,] 12481682.5
## [25,] 13002309.3
## [26,] 13522936.0
## [27,] 14043562.7
## [28,] 14564189.5
## [29,] 15084816.2
## [30,] 15605442.9
## [31,] 16126069.7
## [32,] 16646696.4
## [33,] 17167323.2
## [34,] 17687949.9
## [35,] 18208576.6
## [36,] 18729203.4
## [37,] 19249830.1
## [38,] 19770456.8
## [39,] 20291083.6
## [40,] 20811710.3
## [41,] 21332337.1
## [42,] 21852963.8
## [43,] 22373590.5
## [44,] 22894217.3
## [45,] 23414844.0
## [46,] 23935470.7
## [47,] 24456097.5
## [48,] 24976724.2
## [49,] 25497350.9
## [50,] 26017977.7
##
## $risk
## [1] 3.727698 3.975622 4.228855 4.485789 4.746138 5.009368 5.275049
## [8] 5.542829 5.812417 6.083573 6.356097 6.629819 6.904597 7.180310
## [15] 7.456854 7.734140 8.012689 8.295578 8.582855 8.874095 9.168919
## [22] 9.466993 9.768019 10.071733 10.377898 10.686305 10.996763 11.309105
## [29] 11.623179 11.938847 12.255987 12.574487 12.894247 13.215175 13.537187
## [36] 13.860209 14.184172 14.509012 14.834671 15.161098 15.488243 15.816062
## [43] 16.144514 16.473560 16.803167 17.133301 17.463933 17.795035 18.126582
## [50] 18.458549
##
## $name
## [1] "Efficient Frontier"
plot.ef(ia, list(ef), portfolio.risk, T)
