# [R] "Fast" correlation algorithm

Joshua Stults joshua.stults at gmail.com
Fri May 15 03:06:35 CEST 2009

```If you need auto(cross)correlations in O(n*log(n)) rather than O(n^2)
you can use an FFT.  Here's a good short write-up on using the FFT for
this (numerical recipes chapter):

Won't get you p values, but is faster than a normal matrix-vector
multiply.  If I understand your post correctly though, you are doing
bunches of vectors of dimension ~100, probably the standard method is
plenty fast, you may not see speed up by using an FFT for vectors this
small (larger overhead for the transform -> operations -> inverse
transform).

On Thu, May 14, 2009 at 5:02 PM, Greg Snow <Greg.Snow at imail.org> wrote:
> Well if your matrix and vector are centered and properly scaled (and there are no missing values), then the correlations are just a crossproduct and matrix arithmetic is already fairly fast (assuming you have enough memory).
>
> --
> Gregory (Greg) L. Snow Ph.D.
> Statistical Data Center
> Intermountain Healthcare
> greg.snow at imail.org
> 801.408.8111
>
>
>> -----Original Message-----
>> From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-
>> project.org] On Behalf Of jastar
>> Sent: Thursday, May 14, 2009 2:06 PM
>> To: r-help at r-project.org
>> Subject: [R] "Fast" correlation algorithm
>>
>>
>> Hi,
>> Is in R any "fast" algorithm for correlation?
>> What I mean is:
>> I have very large dataset (microarray) with 55000 rows and 100 columns.
>> I
>> want to count correlation (p-value and cor.coef) between each row of
>> dataset
>> and some vector (of course length of this vector is equal to number of
>> columns of dataset).
>> In short words:
>> For t-test we have:
>> "normal" algorithm - t.test
>> "fast" algorithm - rowttests
>> For correlation:
>> "normal" algorithm - cor.test
>> "fast" algorithm - ???
>>
>> Thank's for help
>> --
>> View this message in context: http://www.nabble.com/%22Fast%22-
>> correlation-algorithm-tp23548016p23548016.html
>> Sent from the R help mailing list archive at Nabble.com.
>>
>> ______________________________________________
>> R-help at r-project.org mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-help
>> guide.html
>> and provide commented, minimal, self-contained, reproducible code.
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> and provide commented, minimal, self-contained, reproducible code.
>

--
Joshua Stults
Website: http://j-stults.blogspot.com

```