Positive Spearman's r value with negative abline -
i'm looking on data collected week-end , 1 of spearman correlation test gave me positive value, when add abline on plot, descending. i'm curious how can possible.
here's data study:
year matches total 1 1958 2 7 2 1959 2 14 3 1960 5 9 4 1961 2 20 5 1962 4 27 6 1963 5 20 7 1964 5 25 8 1965 5 20 9 1966 3 18 10 1967 5 28 11 1968 6 26 12 1969 4 24 13 1970 6 22 14 1971 7 32 and here's procedure used:
results<- (study$matches/study$total)*100 year<-study$year plot(year, results, main = "main") fit1 <- lm (results ~ year, data = study) abline(fit1, lty = "dashed") cor.test(year, results, method = "s")
the fit produces linear model. pearson linear correlation , negative. spearman non-linear , based on ranking.
> cor.test(year,results,method="spearman") spearman's rank correlation rho data: year , results s = 438.9647, p-value = 0.9048 alternative hypothesis: true rho not equal 0 sample estimates: rho 0.03524238 warning message: in cor.test.default(year, results, method = "spearman") : cannot compute exact p-value ties > cor(year,results,method="spearman") [1] 0.03524238 > cor(year,results,method="pearson") [1] -0.17501 it correctly plotting negative linear correlation. happens spearman positive. unintuitive things can happen when correlations low. high p-value clue too.
Comments
Post a Comment