[R] cor.test p-value ties

(Ted Harding) Ted.Harding at nessie.mcc.ac.uk
Fri Jul 9 23:25:20 CEST 2004

On 09-Jul-04 Jason.L.Higbee at stls.frb.org wrote:
> I got a warning message when running the cor.test function
> using both Spearman and Kendall rank correlations saying that
> the p-value may be incorrect due to ties in the data. My data
> has 35 obs and one series has 6 pairs of ties. Does anyone
> know if this would likely have a great effect on the p-values
> calculated..
> The values look good; tau = -0.68 with p-value = 8e-9 and
> rho = =0.84 with p-value = 8e-8.

With P-values like that, probably not!

However, one can always check it by doing random tie-breaking,

  x.1 <- x + 0.001*runif(n)
  y.1 <- y + 0.001*runif(n)

and then repeating the correlation test, where n is the length
of x and y. You can run a simulation loop to get the distribution
of the P-value under random tie-breaking if you like.

The "0.001" could be replaced by something smaller, depending on
the scale of the x and y values (e.g. if all less than 0.01 in
magnitude) -- the important thing is to break the ties without
allowing the perturbed values to step past adjacent values and
upsetting the ordering.

Best wishes,

E-Mail: (Ted Harding) <Ted.Harding at nessie.mcc.ac.uk>
Fax-to-email: +44 (0)870 167 1972
Date: 09-Jul-04                                       Time: 22:25:20
------------------------------ XFMail ------------------------------

More information about the R-help mailing list