0

I'm having difficulties using R's quadprog library to implement weighted least squares with 2 restrictions. The first restriction is that all the coefficients need to be greater than or equal to 0. The second restriction is that the coefficients need to sum to 1.

More formally, I am trying to minimize with respect to W the following equation: (Y - XW)^T * V * (Y - XW), where V is a diagonal matrix.

Y is (p x 1), X is (p x s), W is (s x 1), and V is diagonal (pxp). Below is a reproducible example: I am trying to find the proper parameters to use with quadprog::solve.QP

library(quadprog)
set.seed(1)
y = rnorm(100)
X = matrix(nrow = 100, ncol = 3)
for (i in 1:ncol(X)) {
X[,i]<- rnorm(100, mean = i)
}
v_vec = rnorm(ncol(X))
V = diag(v_vec)
Zslice
  • 412
  • 1
  • 5
  • 14
  • please provide the reproducible code and data from your attempt http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example – Hack-R Jun 11 '16 at 01:58
  • @Hack-R I have added a reproducible example – Zslice Jun 12 '16 at 01:58

0 Answers0