Constrained Least Square in R
Here's the solution to constrained least square, where the coefficient sum up to one.
Given the linear predictor lp:
b0+b1X1+b2X2
as b2=1-b1 the lp becomes:
b0+b1X1+(1-b1)X2 => b0+b1(X1-X2)+offset(X2)
Hence for a generic GLM you can type
glm(y~1+I(x1-x2)+offset(x2))
Given the linear predictor lp:
b0+b1X1+b2X2
as b2=1-b1 the lp becomes:
b0+b1X1+(1-b1)X2 => b0+b1(X1-X2)+offset(X2)
Hence for a generic GLM you can type
glm(y~1+I(x1-x2)+offset(x2))

0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home