Description Usage Arguments Details Value Author(s) Examples
View source: R/efficient.portfolio.R
Compute minimum variance portfolio subject to target return either allowing all assets to be sold short or not allowing any asset to be sold short. The returned object is of class portfolio.
1 | efficient.portfolio(er, cov.mat, target.return, shorts = TRUE)
|
er |
N x 1 vector of expected returns |
cov.mat |
N x N return covariance matrix |
target.return |
scalar, target expected return |
shorts |
logical, if TRUE then short sales (negative portfolio weights) are allowed. If FALSE then no asset is allowed to be sold short. |
A mean-variance efficient portfolio x allowing short sales (negative weights) that achieves the target expected return μ_0 solves the optimization problem: min t(x)Σ x s.t. t(x)1=1 and t(x)μ=μ_0, for which there is an analytic solution using matrix algebra. If short sales are not allowed then the portfolio is computed numerically using the function solve.QP() from the quadprog package.
call |
captures function call |
er |
portfolio expected return |
sd |
portfolio standard deviation |
weights |
N x 1 vector of portfolio weights |
Eric Zivot
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | # construct the data
asset.names = c("MSFT", "NORD", "SBUX")
er = c(0.0427, 0.0015, 0.0285)
names(er) = asset.names
covmat = matrix(c(0.0100, 0.0018, 0.0011,
0.0018, 0.0109, 0.0026,
0.0011, 0.0026, 0.0199),
nrow=3, ncol=3)
r.free = 0.005
dimnames(covmat) = list(asset.names, asset.names)
# compute efficient portfolio subject to target return
target.return = er["MSFT"]
e.port.msft = efficient.portfolio(er, covmat, target.return)
e.port.msft
summary(e.port.msft, risk.free=r.free)
plot(e.port.msft, col="blue")
# compute efficient portfolio subject to target return with no short sales
target.return = er["MSFT"]
e.port.msft.ns = efficient.portfolio(er, covmat, target.return, shorts=FALSE)
e.port.msft.ns
summary(e.port.msft.ns, risk.free=r.free)
plot(e.port.msft.ns, col="blue")
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.