3
$\begingroup$

I found some functions for Markowitz mean variance portfolio optimization in R such as portfolio.optim in tseries package.

However, I was not able to figure out how to use this function if I want to use my own calculated expected mean/return and variance.

Any ideas on how to achieve that with this or any other function?

And does portfolio.optim simply calculate the expected return as the mean of return series and expected volatility/risk as the standard-deviation of the return series? I cannot find it's detailed implementation in the documentation.

$\endgroup$
3
  • $\begingroup$ Isn't the documentation of the package clarifying what is being done inside? $\endgroup$
    – SRKX
    Commented Oct 28, 2015 at 9:06
  • $\begingroup$ @SRKX Are you talking about this documentation? link. I didn't find much details here. $\endgroup$ Commented Oct 28, 2015 at 19:19
  • $\begingroup$ Ok, indeed the package documentation does not explain how expected returns are computed, which means they estimate it from the historical time series you provide as input somehow. You should have mentioned this in your question it gives your more credibility I think. I can see you have found a way around the problem at the end... $\endgroup$
    – SRKX
    Commented Oct 29, 2015 at 1:11

2 Answers 2

4
$\begingroup$

You can use the package quadprog and define everything yourself.

Code can look like this:

library(quadprog)
Sigma = cov(data)
mu = mean(data)
Amat_in # define constraints here
bvec_in # define rhs of constraints here
solve.QP( Dmat = 2*Sigma, dvec = mu, meq=0,Amat=Amat_in,bvec=bvec_in)

EDIT: Yes, and reading the documentation we see that

portfolio.optim(x, pm = mean(x), riskless = FALSE,
shorts = FALSE, rf = 0.0, reslow = NULL, reshigh = NULL,
covmat = cov(x), ...)

the argument covmat can be set. As it seems the single assets' expected return can not be set as pm is the desired portfolio return. The documentation says that solve.QP is used.

$\endgroup$
0
0
$\begingroup$

Just came up with the thought that if I supply my expected return vector instead of entire return series matrix to portfolio.optim, and also provide my own covariance matrix using argument covmat=.., then this might work.

$\endgroup$
4
  • 1
    $\begingroup$ why not add to this to your question? $\endgroup$
    – Gordon
    Commented Oct 28, 2015 at 20:07
  • $\begingroup$ That's ok if he realized this afterwards it seems an honest attempt to answer your own question after a bit of advice. Please make sure the what you "expect" is the case and that's fine as far as I'm concerned. $\endgroup$
    – SRKX
    Commented Oct 29, 2015 at 1:13
  • $\begingroup$ I edited my answer. Apparently you can enter the covariance but not the expected values. $\endgroup$
    – Richi Wa
    Commented Oct 29, 2015 at 15:03
  • $\begingroup$ Will this technique of entering expected return values - providing expected return vector instead of return series matrix to portfolio.optim - work? I didn't find in the documentation that how do they find expected return from return series matrix. $\endgroup$ Commented Oct 30, 2015 at 4:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.