[R] Lots of huge matrices, for-loops, speed

Moshe Olshansky m_olshansky at yahoo.com
Mon Jul 7 03:21:09 CEST 2008


This is correct for larger (more columns) matrices - computing the t(A)*A matrix and inverting it may cause numerical problems, but this should not be the case with two columns (one of which is all 1's).

In any case, the matrix depends on vector x only and since it is small (80 entries), the resulting matrix can be decomposed/processed in any desirable way independently of the huge Y matrices (but once again, this is not needed for the particular case).


--- On Mon, 7/7/08, Rolf Turner <r.turner at auckland.ac.nz> wrote:

> From: Rolf Turner <r.turner at auckland.ac.nz>
> Subject: Re: [R] Lots of huge matrices, for-loops, speed
> To: m_olshansky at yahoo.com
> Cc: r-help at r-project.org, "Zarza" <s.schmidtlein at uni-bonn.de>
> Received: Monday, 7 July, 2008, 9:40 AM
> On 7/07/2008, at 11:05 AM, Moshe Olshansky wrote:
> 
> > Another possibility is to use explicit formula, i.e.
> if you are  
> > doing linear regression like y = a*x + b then the
> explicit formulae  
> > are:
> >
> > a = (meanXY - meanX*meanY)/(meanX2 - meanX^2)
> > b = (meanY*meanX2 - meanX*meanXY)/(meanX2 - meanX^2)
> >
> > where meanX is mean(x), meanXY is mean(x*y), meanX2 is
> mean(x^2), etc.
> 
> 
> My understanding is that such formulae, while
> ``algebraically  
> correct'' are
> highly unstable numerically and hence should be avoided.
> 
> Others who are wiser and more knowledgeable than I may wish
> to  
> comment or
> correct me.
> 
> 	cheers,
> 
> 		Rolf Turner
> 
> ######################################################################
> Attention: 
> This e-mail message is privileged and confidential. If you
> are not the 
> intended recipient please delete the message and notify the
> sender. 
> Any views or opinions presented are solely those of the
> author.
> 
> This e-mail has been scanned and cleared by MailMarshal 
> www.marshalsoftware.com
> ######################################################################



More information about the R-help mailing list