# [R-SIG-Finance] solnp Problem Inverting Hessian

Michael Ashton m.ashton at enduringinvestments.com
Tue Dec 15 01:13:01 CET 2015

```I must admit to being flummoxed here, mainly because my linear algebra was 25 years ago and I can't remember what a Hessian is.

I have a matrix of 60 securities' weekly returns, along with 60 projected returns. The returns are in a vector called Ret.vect and the covariance matrix of weekly returns in cov.mat . I have the minConstraints and maxConstraints that the parameters are permitted to take. I cycle through targeted risks and get the same error for each risk targeted...below I have removed the loop to focus on the risk=0.002.

wgt.vect=c(rep(1/60, 60))
constr.fun <- function(wgt.vect) {;
c1 = sqrt(crossprod(t(wgt.vect %*% cov.mat),wgt.vect));
c2 = sum(wgt.vect);
return(c(c1,c2));
}
ineqconstr.fun <- function(wgt.vect) {
wgt.vect[1:60];
}
opt.fun <- function(wgt.vect) {-crossprod(wgt.vect,t(Ret.vect))}

OptimSolution <- solnp(wgt.vect,opt.fun,constr.fun,eqB=c(0.002,1),ineqconstr.fun,ineqLB=minConstraints,ineqUB=maxConstraints)

I get the following error:
solnp--> Solution not reliable....Problem Inverting Hessian.

Well, that doesn't tell me very much! The parameters (weights) that are output for each run, as I cycle through the weights, are very scrambled...lots of little allocations, rather than clumping as you would expect to happen especially at the risky and riskless ends of the spectrum.

Can anyone with more math than me give me a helping hand on the Hessian?

Thanks,

Mike

Michael Ashton, CFA
Managing Principal

Enduring Investments LLC
W: 973.457.4602
C: 551.655.8006

________________________________
This email and any attachments are confidential and inte...{{dropped:9}}

```