Restricted weighted OLS

51 Views Asked by At

I would like to run a restricted weighted OLS regression in R. Let me first state the problem mathematically:

$\arg\min_{\beta} \sum_{i=1}^{n} w_{i} \lvert y_{i} - \sum_{k=1}^{m} x_{i,k} \beta_{k}\rvert^{2}$ or in vector notation

$\arg\min_{\beta} \lvert\lvert W^{1/2}(y-X\beta)\rvert\rvert^{2}$

such that

$\sum_{i=1}^{n} w_{i} = 1$,

$\sum_{i=1}^{n} w_{i} x_{i,k} = 0 \quad \text{for} \; k = 1,\dots,m$,

$\sum_{i=1}^{n} w_{i} x_{i,k}^{2} = 1 \quad \text{for} \; k = 1,\dots,m$

To provide an example, following R-code with $i = 10$ and $m = 3$ can be used:

y <- rnorm(10)
w <- c(0.05, 0.15, 0.02, 0.08, 0.2, 0.04, 0.06, 0.1, 0.18, 0.12)
x1 <- rnorm(10)
x2 <- rnorm(10)
x3 <- rnorm(10)
data <- cbind(y, x1, x2, x3, w)
lm(y ~ x1 + x2 + x3, data = data, weigths = w)

That is to say, that I would like to add the constraints that the weights must sum up to one, the weighted mean has to be zero and the weighted standard deviation has to be one to the regression. The first condition can actually be discarded since the weights do always add up to one in my case. Does anybody know either the mathematical solution (that can later be programmed into R) or a function that is able to perform that directly in R?