If I have the following data
n<-1000
x1<-rnorm(n,1,1)
x2<-rnorm(n,2,2)
x3<-rnorm(n,3,3)
e<-rnorm(n)
y<-3+0.5*x1+0.2*x2+0.3*x3+e
I want to fit a linear model between $y$ and $x$ like: $$y=\alpha+\beta_1x_1+\beta_2x_2+\beta_3x_3+\epsilon$$ The unconstraint linear regression in R is
fit=lm(y~x1+x2+x3)
Now if I have some extra constraints for the coefficients:
(i) $\beta_i\ge0$, for $i=1,2,3$;
(ii) $\displaystyle\sum_{i=1}^3\beta_i=1$.
I still want to run a linear regression but with the two constraints above. How can I implement this constrained linear regression in R?