trackingPortfolio {NMOF} | R Documentation |
Compute a Tracking Portfolio
Description
Computes a portfolio similar to a benchmark, e.g. for tracking the benchmark's performance or identifying factors.
Usage
trackingPortfolio(var, wmin = 0, wmax = 1,
method = "qp", objective = "variance", R,
ls.algo = list())
Arguments
var |
the covariance matrix: a numeric (real), symmetric matrix. The first asset is the benchmark. |
R |
a matrix of returns: each colums holds the returns of one asset; each rows holds the returns for one observation. The first asset is the benchmark. |
wmin |
numeric: a lower bound on weights. May also be a vector that holds specific bounds for each asset. |
wmax |
numeric: an upper bound on weights. May also be a vector that holds specific bounds for each asset. |
method |
character. Currently, |
objective |
character. Currently, |
ls.algo |
a list of named elements, for settings for
method ‘ |
Details
With method "qp"
, the function uses
solve.QP
from package
quadprog. Because of the algorithm that
solve.QP
uses, var
has to
be positive definite (i.e. must be of full rank).
With method "ls"
, the function uses
LSopt
. Settings can be passed via
ls.algo
, which corresponds to
LSopt
's argument algo
. Default
settings are 2000 iterations and printBar
,
printDetail
set to FALSE
.
R
is needed only when objective
is
"sum.of.squares"
or method
is
‘ls
’. (See Examples.)
Value
a numeric vector (the portfolio weights)
Author(s)
Enrico Schumann
References
Gilli, M., Maringer, D. and Schumann, E. (2019) Numerical Methods and Optimization in Finance. 2nd edition. Elsevier. doi:10.1016/C2017-0-01621-X
Schumann, E. (2023) Financial Optimisation with R (NMOF Manual). http://enricoschumann.net/NMOF.htm#NMOFmanual
Schumann, E. (2020) Return-based tracking portfolios. http://enricoschumann.net/notes/return-based-tracking-portfolios.html
Sharpe, W. F. (1992) Asset Allocation: Management Style and Performance Measurement. Journal of Portfolio Management. 18 (2), 7–19. https://web.stanford.edu/~wfsharpe/art/sa/sa.htm
See Also
Examples
if (requireNamespace("quadprog")) {
ns <- 120
R <- randomReturns(na = 1 + 20,
ns = ns,
sd = 0.03,
mean = 0.005,
rho = 0.7)
var <- cov(R)
sol.qp <- trackingPortfolio(var, wmax = 0.4)
sol.ls <- trackingPortfolio(var = var, R = R, wmax = 0.4, method = "ls")
data.frame(QP = round(100*sol.qp, 1),
LS = round(100*sol.ls, 1))
sol.qp <- trackingPortfolio(var, R = R, wmax = 0.4,
objective = "sum.of.squares")
sol.ls <- trackingPortfolio(var = var, R = R, wmax = 0.4, method = "ls",
objective = "sum.of.squares")
data.frame(QP = round(100*sol.qp, 1),
LS = round(100*sol.ls, 1))
## same as 'sol.qp' above
sol.qp.R <- trackingPortfolio(R = R,
wmax = 0.4,
objective = "sum.of.squares")
sol.qp.var <- trackingPortfolio(var = crossprod(R),
wmax = 0.4,
objective = "variance")
## ==> should be the same
all.equal(sol.qp.R, sol.qp.var)
}