[R-SIG-Finance] (no subject)
Brian G. Peterson
brian at braverock.com
Thu Jun 30 13:58:01 CEST 2011
On Thu, 2011-06-30 at 11:44 +0000, Hixon, Scott R. wrote:
> Hello R community.
>
> I am trying to construct a portfolio subject to a few risk contribution constraints and have created the following function...
>
> fnc <- function (wtsmat)
> {
> q <- c(tail(SAA.BondWts, 1), wtsmat)
> a <- c(sqrt(t(q) %*% cov.mat %*% q))
> b <- cov.mat %*% q
> c <- q * b/a
> d <- sd(c[colnames(Equity.Rtn), ])
> e <- sd(c[colnames(Cmdty.Rtn), ])
> f <- sd(c(sum(c[colnames(Bond.Rtn), ]), sum(c[colnames(Equity.Rtn), ]), sum(c[colnames(Cmdty.Rtn), ])))
> g <- c(d, e, f)
> return(g)
> }
>
> Where:
> wtsmat <- c(0.1610060, 0.1254689, 0.1994601, 0.1804945, 0.1851957, 0.1483748, 0.2178142, 0.3390351, 0.2049340, 0.2382168)
> SAA.BondWts <- c(0.2160611, 0.1804805, 0.1950128, 0.1095015, 0.1982830, 0.0000000, 0.1006611)
> and "cov.mat" represents the covariance matrix of all of the assets (17 x 17). If it is necessary to include the matrix for a proper answer to my question I will be happy to attach it.
>
> The function above calculates the risk contribution of each asset in the portfolio. Ideally I would like to optimize the values of wtsmat given that d, e, and f in the function should all equal zero.
> I am however, having some trouble setting this up in R. Has anyone solved a problem like this in the past?
>
> Thanks for any help and advice.
> Scott
The function StdDev in package PerformanceAnalytics can calculate
contribution to portfolio standard deviation.
The R-Forge package PortfolioAnalytics can construct risk-budget
constrained portfolios, and allows you to vary the constraints and
objectives without limiting yourself to what's possible with a closed
form solver.
I know that a single set of box constraints on contribution to portfolio
standard deviation may be solved with a closed form solver, but I don't
remember the paper reference offhand to go look it up. As you add more
constraints or other objectives to the portfolio, it is likely that you
will violate the conditions that allow for a closed form solution, and
require a global solution such as that provided by PortfolioAnalytics.
Regards,
- Brian
--
Brian G. Peterson
http://braverock.com/brian/
Ph: 773-459-4973
IM: bgpbraverock
More information about the R-SIG-Finance
mailing list