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

________________________________________
Scott Hixon, CFA
Portfolio Manager
Global Asset Allocation

404.439.3123 direct
404.892.0896 main
404.439.4918 facsimile
scott.hixon@invesco.com<mailto:scott.hixon@invesco.com>

Invesco Global Strategies
Two Peachtree Pointe
1555 Peachtree Street, NE
Atlanta, Georgia 30309



****************************************************************
Confidentiality Note: The information contained in this ...{{dropped:12}}

