[R] regression problem
Gabor Grothendieck
ggrothendieck at myway.com
Fri Mar 26 17:54:32 CET 2004
<pnick <at> virgilio.it> writes:
>
> i need to know how to estimate a linear regression whose coefficients sum
> to zero
>
Transform the model:
y = Xb + error
to
y = XPb + error
where P is the projection onto the orthogonal complement of the vector 1.
Solve this regression for b and then Pb will be your desired coefficients.
In R this would be:
n <- ncol(X)
P <- diag(n)-matrix(1,n,n)/n
z <- lm(y ~.-1, data=(X%*%P))
b <- coef(z)
b[is.na(b)] <- 0
P %*% b
More information about the R-help
mailing list