Hi, Is there a limit on the number of observations for using cor.test. For example,> library(ctest) > cor.test(rnorm(3000), rnorm(3000), method="spearman")Error in if (q > (n^3 - n)/6) pspearman(q - 1, n, lower.tail = FALSE) else pspearman(q, : missing value where logical needed In addition: Warning message: NAs introduced by coercion I mainly want to calculate the spearman correlation rho for a data with missing values. But the rcorr function in Hmisc library (from Hmisc_1.4.2.zip) gave me an error message> library(Hmisc) > rcorr(tmp[5600:5900,1:2], type="spearman")Error in rcorr(tmp[5600:5900, 1:2], type = "spearman") : NA/NaN/Inf in foreign function call (arg 1) Any help is appreciated, Ming-Chung Li
Yes. About 1290 for the Spearman test. You need (n^3 - n) representable as an integer. On Tue, 1 Apr 2003, Ming-Chung Li wrote:> Is there a limit on the number of observations for using cor.test. For > example, > > > library(ctest)That's not needed, and has not been for about 3 years.> > cor.test(rnorm(3000), rnorm(3000), method="spearman") > Error in if (q > (n^3 - n)/6) pspearman(q - 1, n, lower.tail = FALSE) else > pspearman(q, : > missing value where logical needed > In addition: Warning message: > NAs introduced by coercion-- Brian D. Ripley, ripley at stats.ox.ac.uk Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UK Fax: +44 1865 272595
This is a note to my second question. I just discovered my data containing an 'Inf' value and this causes the error I saw when I used rcorr() function from the Hmisc package. If I delete this observation, everything is fine. Best, Ming-Chung