[R] How to project a vector on a subspace?
Gabor Grothendieck
ggrothendieck at gmail.com
Wed Sep 8 15:22:46 CEST 2010
On Wed, Sep 8, 2010 at 2:52 AM, James <vuda.it at gmail.com> wrote:
>
> Hi experts,
>
> I have a subspace represented as matrix of basic vectors and I want to
> project a vector on that subspace. Does R have any function that help me to
> do so?
>
The projection of vector y onto the space spanned by the columns of X
is fitted(lm.fit(X, y)) .
Although not numerically optimal it can also be written:
X %*% solve(crossprod(X, X), crossprod(X, y))
--
Statistics & Software Consulting
GKX Group, GKX Associates Inc.
tel: 1-877-GKX-GROUP
email: ggrothendieck at gmail.com
More information about the R-help
mailing list