similar to: Wrong result with cor(x, y, method="spearman", use="complete.obs") with NA's???

Displaying 20 results from an estimated 3000 matches similar to: "Wrong result with cor(x, y, method="spearman", use="complete.obs") with NA's???"

2010 Jun 09
1
bug? in stats::cor for use=complete.obs with NAs
Arrrrr, I think I've found a bug in the behavior of the stats::cor function when NAs are present, but in case I'm missing something, could you look over this example and let me know what you think: > a = c(1,3,NA,1,2) > b = c(1,2,1,1,4) > cor(a,b,method="spearman", use="complete.obs") [1] 0.8164966 > cor(a,b,method="spearman",
2008 Jan 02
2
strange behavior of cor() with pairwise.complete.obs
Hi all, I'm not quite sure if this is a feature or a bug or if I just fail to understand the documentation: If I use cor() with pairwise.complete.obs and method=pearson, the result is a scalar: ->cor(c(1,2,3),c(3,4,6),use="pairwise.complete.obs",method="pearson") [1] 0.9819805 The documentation says that " '"pairwise.complete.obs"' only
2011 May 16
2
about spearman and kendal correlation coefficient calculation in "cor"
Hi, I have the following two measurements stored in mat: > print(mat) [,1] [,2] [1,] -14.80976 -265.786 [2,] -14.92417 -54.724 [3,] -13.92087 -58.912 [4,] -9.11503 -115.580 [5,] -17.05970 -278.749 [6,] -25.23313 -219.513 [7,] -19.62465 -497.873 [8,] -13.92087 -659.486 [9,] -14.24629 -131.680 [10,] -20.81758 -604.961 [11,] -15.32194 -18.735 To calculate the ranking
2008 Sep 10
3
making spearman correlation cor() call fail with log(0) as input
Hi, How can I make the cor(x, y, method="spearman") call to produce an error when the input to it (x, y) produces an error? Here is a simple example: > a <- c(0, 1, 2) > b <- c(100, 2, 4) ## error: > log(a) [1] -Inf 0.0000000 0.6931472 ## error, as expected: > cor(log(a), log(b), method="pearson") [1] NaN ## not an error any more (not expected): >
2011 Jan 21
0
Possible bug in Spearman correlation with use="pairwise.complete.obs"
Hi, I have just encountered a strange behaviour from 'cor' with regards to the treatment of NAs when calculating Spearman correlations. I guess it is a subtle bug. If I understand the help page correctly, the two modes 'complete.obs' and 'pairwise.complete.obs' specify how to deal with correlation coefficients when calculating a correlation _matrix_. When calculating
2004 Mar 03
1
cor(..., method="spearman") or cor(..., method="kendall") (PR#6641)
Dear R maintainers, R is great. Now that I have that out of the way, I believe I have encountered a bug, or at least an inconsistency, in how Spearman and Kendall rank correlations are handled. Specifically, cor() and cor.test() do not produce the same answer when the data contain NAs. cor() treats the NAs as data, while cor.test() eliminates them. The option use="complete.obs" has
2009 Nov 30
1
cor.test(method = spearman, exact = TRUE) not exact (PR#14095)
Full_Name: David Simcha Version: 2.10 OS: Windows XP Home Submission from: (NULL) (173.3.208.5) > a <- c(1:10) > b <- c(1:10) > cor.test(a, b, method = "spearman", alternative = "greater", exact = TRUE) Spearman's rank correlation rho data: a and b S = 0, p-value < 2.2e-16 alternative hypothesis: true rho is greater than 0 sample estimates:
2005 Oct 07
1
cor() function, method="spearman"
Hello, Does anyone know if the cor function, when method = "spearman", returns a correlation coefficient corrected for any ties in the ranks of the data? I have data with quite a few ties and am thinking that I should use a calculation of the coefficient corrected for ties, but before I try and code this calculation myself, I thought I should check whether or not cor() automatically
2006 Sep 13
1
S in cor.test(..., method="spearman")
Dear HelpeRs, I have some data: "ice" <- structure(c(0.386, 0.374, 0.393, 0.425, 0.406, 0.344, 0.327, 0.288, 0.269, 0.256, 0.286, 0.298, 0.329, 0.318, 0.381, 0.381, 0.47, 0.443, 0.386, 0.342, 0.319, 0.307, 0.284, 0.326, 0.309, 0.359, 0.376, 0.416, 0.437, 0.548, 41, 56, 63, 68, 69, 65, 61, 47, 32, 24, 28, 26, 32, 40, 55, 63, 72, 72, 67, 60, 44, 40, 32, 27, 28, 33,
2003 Nov 07
2
Bug in cor.test - Spearman
Greetings. There seems to be a problem with the P-value computation in the cor.test with method="spearman". In R1.8.0 (MS Windows) I seem to be getting intermittently nonsense P-values, but the rho's are OK. I can get this reproducibly with the toy example attached where the first use is OK and subsequent calls with the same data give nonsense. (I have also seen the problem
2007 Sep 20
1
Bug with Cor(..., method='spearman") and by() (PR#9921)
I posted this on R help, and a few others responded indicating they too were able to replicate the error as a function of missing data. I believe this should not be the case and hence and reporting it here. ### Code provided on R-Help by Ivar Herfindal # Simulate data testdata <- cbind.data.frame(gr=3Drep(letters[1:4], each=3D5), = aa=3Drnorm(20), bb=3Drnorm(20)) # Introduce some missingness
2006 Dec 05
1
Spearman correlation ties and discrepancies
Hi. I am currently trying to run some Spearman correlations, and have encountered two issues. 1) When using cor.test() with a variable that includes ties, I get the "Cannot compute exact p-values with ties" error. I have read that this function now uses an asymptotic formula that allows for ties, so do not understand why I am getting this error. (I am running version 2.4.0.) I
2004 Mar 15
1
spearman rank correlation problem
Hello R gurus, I want to calculate the Spearman rho between two ranked lists. I am getting results with cor.test that differ in comparison to my own spearman function: > my.spearman function(l1, l2) { if(length(l1) != length(l2)) stop("lists must have same length") r1 <- rank(l1) r2 <- rank(l2) dsq <- sapply(r1-r2,function(x) x^2) 1 - ((6 * sum(dsq))
2012 Aug 29
3
Help on calculating spearman rank correlation for a data frame with conditions
Dear all, Suppose my data frame is as follows: id price distance 1 2 4 1 3 5 ... 2 4 8 2 5 9 ... n 3 7 n 8 9 I would like to calculate the rank-order correlation between price and distance for each id. cor(price,distance,method = "spearman") calculate a correlation for all. Then I tried to use apply(data,list='id',cor(price , distance , method =
2009 Jan 17
1
bug in cor.test(method = "spearman")
Dear R developers: There is a possible bug in calculating the p-value for Spearman's rank correlation. Line 155 in file R-patched/src/library/stats/R/cor.test.R is as.double(round(q) + lower.tail), I think, it should be as.double(round(q) + 2*lower.tail), The reason is that round(q) is expected to be an even number (the S statistic), so the next feasible value is round(q)+2.
2007 May 29
2
R's Spearman
Hi all, I am trying to figure out the formula used by R's Spearman rho (using cor(method="spearman")) because I can't seem to get the same value as by calculating "by hand". Perhaps I'm using "cor" wrong, but I don't know where. Basically, I am running these commands: > y=read.table(file="tmp",header=TRUE,sep="\t") >
2008 Feb 28
4
p-value in Spearman rank order
Dear R-helpers, I would like to do a Spearman rank order test, and used the cor() function with the method "spearman". It gives me a number (correlation coefficient?) , but how can I get the p-value? Thank you for the help in advance! Regards, Anne-Katrin -- [[alternative HTML version deleted]]
2016 Apr 29
2
lm() with spearman corr option ?
Hi, A following function was kindly provided by GGally?s maintainer, Barret Schloerke. function(data, mapping, ...) { p <- ggplot(data = data, mapping = mapping) + geom_point(color = I("blue")) + geom_smooth(method = "lm", color = I("black"), ...) + theme_blank() + theme(panel.border=element_rect(fill=NA, linetype =
2007 Aug 23
1
in cor.test, difference between exact=FALSE and exact=NULL
Pardon my ignorance, but is there a difference in cor.test between exact=FALSE and exact=NULL when method=spearman? Take for example: x<-c(1,2,2,3,4,5) y<-c(1,2,2,10,11,12) cor.test(x,y, method="spearman", exact=NULL) This gives an error message, Warning message: Cannot compute exact p-values with ties in: cor.test.default(x, y, method = "spearman", exact = NULL)
2007 Mar 15
1
Incorrect matrix of spearman correlations .... in 64-bit Linux ... (PR#9568)
Full_Name: Vladimir Obolonkin Version: tested in 2.0 to 2.4.1 OS: linux, win, mac Submission from: (NULL) (202.14.96.194) {{ Subject shortened manually -- to pass anti-spam filters Original-subject: Incorrect matrix of spearman correlations working \ large (24000 by 425 and 78 by 425 data frames) in 64-bit Linux machines;\ the same code gives correct results in 32-bits Win and