Computes an efficient portfolio from the given return series x
in the mean-variance sense.
# S3 method for default
portfolio.optim(x, pm = mean(x), riskless = FALSE,
shorts = FALSE, rf = 0.0, reslow = NULL, reshigh = NULL,
covmat = cov(x), …)
a numeric matrix or multivariate time series consisting of a series of returns.
the desired mean portfolio return.
a logical indicating whether there is a riskless lending and borrowing rate.
a logical indicating whether shortsales on the risky securities are allowed.
the riskfree interest rate.
a vector specifying the (optional) lower bound on allowed portfolio weights.
a vector specifying the (optional) upper bound on allowed portfolio weights.
the covariance matrix of asset returns.
further arguments to be passed from or to methods.
A list containing the following components:
the portfolio weights.
the returns of the overall portfolio.
the expected portfolio return.
the standard deviation of the portfolio returns.
The computed portfolio has the desired expected return pm
and
no other portfolio exists, which has the same mean return, but a
smaller variance. Inequality restrictions of the form \(w_l \le w
\le w_h\) can be imposed using the reslow
and
reshigh
vectors. An alternative covariance matrix estimate can
be supplied via the covmat
argument. To solve the quadratic
program, solve.QP
is used.
portfolio.optim
is a generic function with methods for
multivariate "ts"
and default
for matrix.
Missing values are not allowed.
E. J. Elton and M. J. Gruber (1991): Modern Portfolio Theory and Investment Analysis, 4th Edition, Wiley, NY, pp. 65-93.
C. Huang and R. H. Litzenberger (1988): Foundations for Financial Economics, Elsevier, NY, pp. 59-82.
# NOT RUN { x <- rnorm(1000) dim(x) <- c(500,2) res <- portfolio.optim(x) res$pw require("zoo") # For diff() method. X <- diff(log(as.zoo(EuStockMarkets))) res <- portfolio.optim(X) ## Long only res$pw res <- portfolio.optim(X, shorts=TRUE) ## Long/Short res$pw # }
Run the code above in your browser using DataCamp Workspace