[Rd] numerical issue with t.test

Michael Dewey ||@t@ @end|ng |rom dewey@myzen@co@uk
Mon Sep 16 16:54:11 CEST 2024


Dear Toby

I see no problem there. If you compute the mean and variance of err1 - 
err2 which is what the paired test is working on then that might help to 
see what is going on.

Michael

On 16/09/2024 15:47, Toby Hocking wrote:
> Hi! I expected that t.test should report a very large p-value (close
> to 1), even when using paired=TRUE, for the data below (which are very
> similar). However, I observe p-value = 0.02503 which indicates a
> significant difference, even though there is none. Can this be fixed
> please? This is with R-4.4.1. For reference below I use paired=FALSE
> with the same data, and I get p-value = 1 as expected.
> 
>> err1 = c(-1.6076199373862132, -1.658521185520103, -1.6549424312339873, -1.5887767975086149, -1.634129577540383, -1.7442711937982249)
>> err2 = c(-1.6076199373862132, -1.6585211855201032, -1.6549424312339875, -1.5887767975086149, -1.6341295775403832, -1.7442711937982252)
>> t.test(err1,err2,paired=TRUE)
> 
>      Paired t-test
> 
> data:  err1 and err2
> t = 3.1623, df = 5, p-value = 0.02503
> alternative hypothesis: true mean difference is not equal to 0
> 95 percent confidence interval:
>   2.769794e-17 2.683615e-16
> sample estimates:
> mean difference
>     1.480297e-16
> 
>> t.test(err1,err2,paired=FALSE)
> 
>      Welch Two Sample t-test
> 
> data:  err1 and err2
> t = 0, df = 10, p-value = 1
> alternative hypothesis: true difference in means is not equal to 0
> 95 percent confidence interval:
>   -0.06988771  0.06988771
> sample estimates:
> mean of x mean of y
> -1.648044 -1.648044
> 
> ______________________________________________
> R-devel using r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel
> 

-- 
Michael



More information about the R-devel mailing list