Re: [R] How to project a vector on a subspace?

2010-09-09 Thread James

Hi Peng, Gabor  Peter,

Thank you very much for replying me so soon. I will try it right now!


-- 
View this message in context: 
http://r.789695.n4.nabble.com/How-to-project-a-vector-on-a-subspace-tp2530886p2532388.html
Sent from the R help mailing list archive at Nabble.com.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] How to project a vector on a subspace?

2010-09-08 Thread James

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?

Thanks,

James.
-- 
View this message in context: 
http://r.789695.n4.nabble.com/How-to-project-a-vector-on-a-subspace-tp2530886p2530886.html
Sent from the R help mailing list archive at Nabble.com.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] How to project a vector on a subspace?

2010-09-08 Thread Peng, C

Can you be a little bit more specific? For example, the base vectors of the
subspace and the vector you want to project. Specific artificial
vectors/matrices are helpful.
-- 
View this message in context: 
http://r.789695.n4.nabble.com/How-to-project-a-vector-on-a-subspace-tp2530886p2531245.html
Sent from the R help mailing list archive at Nabble.com.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] How to project a vector on a subspace?

2010-09-08 Thread Gabor Grothendieck
On Wed, Sep 8, 2010 at 2:52 AM, James vuda...@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

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] How to project a vector on a subspace?

2010-09-08 Thread peter dalgaard

On Sep 8, 2010, at 15:22 , Gabor Grothendieck wrote:

 On Wed, Sep 8, 2010 at 2:52 AM, James vuda...@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))

Perhaps qr.fitted(qr(X),y) is slightly faster than fitted(lm.fit(X,y)). Looks 
like it might be bypassing some red tape, and otherwise do the same. 

-- 
Peter Dalgaard
Center for Statistics, Copenhagen Business School
Solbjerg Plads 3, 2000 Frederiksberg, Denmark
Phone: (+45)38153501
Email: pd@cbs.dk  Priv: pda...@gmail.com

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.