I have this problem in R.
$$\max w^Tu- y w^T A w$$ where A is covariance variance matrix, y risk aversion parameter. Is it rigth if I use the function solve.QP multiplying the covariance matrix for lambda and setting dvec (vector appearing in the quadratic function to be minimized) equal to the vector of mean returns of the asset? In order to find the maximum I have to change the sign
weigth4<- matrix(0, nrow=15, ncol=15)
mu <- matrix(NA, nrow=15, ncol=15)
for ( i in 1:15){
mu[i,]<- mean(c[[i]][2])
}
Amat<- cbind(1, diag(15), -diag(15))
bvec<- c(1, rep(0.01, 15), rep(-0.5,15))
for ( i in 1:15){
result4<- solve.QP(Dmat=2*list[[i]], dvec=(-1)*mu[1,], Amat=Amat, bvec=bvec, meq=1)
weigth4[i,]<- result4$solution
}
In the case of expected utility maximization, I also want to check for the impact of different values of y= 0, 1, 5, 10. In any event, please rule out any short positions. How can I find these portfolios?