Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Jonckheere Terpstra Test asymptotic p value seems to be inconsistent with cor.test(x, g, method="k") #114

Open
lijuanyan122 opened this issue Apr 26, 2023 · 2 comments

Comments

@lijuanyan122
Copy link

When we have data with ties, the DescTools::JonckheereTerpstraTest() does not provide the same asymptotic p value as described in the documentation using cor.test(x, g, method="k"). Please see the code below.

https://gist.github.com/lijuanyan122/f0e3a8a520f47b238b44f30fa79d4b2c

@AndriSignorell
Copy link
Owner

I can't see from your example

# For data with ties
x <- rep(1:4, 4)
g <- c(rep(57, 15), 59)
# The below p values based on normal approximation produced are different
DescTools::JonckheereTerpstraTest(x, g, exact=FALSE)
cor.test(x, g, method="kendall")

why the two functions should yield the same p-value. Are you aware that x is a numeric variable and g a grouping factor for JonckheereTerpstraTest and cor.test expects two variables x, y?
Can you explain what you would expect? Thanks

@lijuanyan122
Copy link
Author

First of all, thanks for responding to my question and sorry it took long to reply. I edited the code, so to better describe my question: https://gist.github.com/lijuanyan122/f0e3a8a520f47b238b44f30fa79d4b2c

In the documentation of DescTools::JonckheereTerpstraTest(), it is written that "the asymptotic version is equivalent to cor.test(x, g, method="k")." Therefore, I would expect that the p values produced by cor.test() and DescTools::JonckheereTerpstraTest() for the asymptotic version are the same. As expected, the JT test from another R package PMCMRplus::jonckheereTest() actually gives exactly the same result as cor.test(), no matter if the "g" is a grouping factor or integer --> I also checked the results with one standard software used for the statistical analysis of ecotoxicological data (ToxRat: https://www.toxrat.com/Home_en.html) and it gives the same p value as PMCMRplus::jonckheereTest().

So the discrepancies of results lie in the fact that "g" is treated as a factor all the time for DescTools::JonckheereTerpstraTest(), whereas it is treated as integer in PMCMRplus::jonckheereTest(), cor.test() and ToxRat??

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants