1
$\begingroup$

while I was trying to apply one-tailed t-test to two vector of data on R, I just wanted to apply same thing on librecalc also and then I noticed that p-values are different. Here is a summary what I have done so far:

in R I applied: t.test(data[,1],data[,2],paired = TRUE,alternative = 'greater') and then result is:

Paired t-test

data:  ttest[, 2] and ttest[, 3]
t = -134.33, df = 49, p-value = 1
alternative hypothesis: true difference in means is greater than 0
95 percent confidence interval:
-8.318141       Inf
sample estimates:
mean of the differences 
            -8.2156 

It returns 1 as p-value. However, same thing on Librecalc, it gives following:

Paired t-test       
Alpha   0,05    
Hypothesized Mean Difference    0   
    Variable 1  Variable 2
Mean    33,003568   41,219168
Variance    0,155220041404082   0,038756230791837
Observations    50  50
Pearson Correlation 0,04472285907661    
Observed Mean Difference    -8,2156 
Variance of the Differences 0,187038752653061   
df  49  
t Stat  -134,325507363656   
P (T<=t) one-tail   7,16710643183049E-65 //(Here is the p-value)    
t Critical one-tail 1,67655089261685    
P (T<=t) two-tail   1,4334212863661E-64 
t Critical two-tail 2,00957523712924    

Except the p-values, all the other results are same as you see. Can someone tell me what is going on here, or what should I do for a one-tailed t-test to compare two algorithms. (I have 50 different runs' results of both algorithm). Here is the data:

31,3888 41,028
33,3064 41,2048
32,6824 41,5216
33,4552 40,9848
32,6832 41,3152
33,2704 41,212
32,8344 41,2104
32,6376 41,2904
33,3552 41,22
32,6    41,2152
32,6752 41,4784
32,9464 41,1352
33,2064 41,4216
33,1752 41,0568
33,0952 41,2808
32,5272 41,7328
33,1624 40,8696
33,0192 41,0544
33,1744 41,1048
33,4464 41,0488
33,7448 41,3832
33,0568 41,4656
32,836  41,1192
33,1    41,0832
33,2144 41,4944
33,0544 41,2736
33,3232 41,4232
32,8616 41,2304
33,228  41,2184
33,2472 41,02
32,8952 40,9808
33,5056 41,3808
33,5248 41,348
33,4416 41,1072
33,0416 41,016
33,0504 41,168
32,4064 41,184
32,6256 41,572
32,488  40,7848
33,4304 41,2536
33,2128 41,2248
32,9576 41,5392
33,0136 41,4608
32,9296 41,0872
32,632  41,0128
33,2616 40,968
32,7664 41,0192
32,8952 41,3344
33,3512 41,2984
32,4408 41,1216
$\endgroup$
0
$\begingroup$

If alternative = 'greater' means that alternative hypothesis is "x has greater mean than y". In your code:

t.test(data[,1],data[,2],paired = TRUE,alternative = 'greater')

it translates to data[,1] has grater mean that data[,2]. Which is obviously not true. Just change the order of inputs and you'll get a correct p-value

t.test(data[,2],data[,1],paired = TRUE,alternative = 'greater')

I suppose that in LibreCalc arguments are flipped w.r.t. R

| improve this answer | |
$\endgroup$
  • $\begingroup$ I see. But this was only the one example. There are 576 different ttest on my work and some gives positive mean differences and some gives negative mean differences. If I do what you said, then same thing is going to be happen to the current positive mean differences I think. There must be a way to get over it. Any idea? Thanks. $\endgroup$ – WhoCares Apr 16 '19 at 14:20
  • $\begingroup$ @WhoCares I am not getting your point. Your problem is that you used t.test arguments the wrong way. If you have 576 test, then you should have 576 errors, and each can be fixed the same way. What doesn't convince you? $\endgroup$ – lsmor Apr 16 '19 at 14:30
  • $\begingroup$ I thought I was clear. The above example, difference of the means is -8.2156. So that means your answer is correct in this particular example. However, in the rest of the results, there are also positive differences (x has greater mean than y) which means if I change greater to less, this time their p-value will be 1. $\endgroup$ – WhoCares Apr 16 '19 at 14:37
  • $\begingroup$ @WhoCares Ok, I got you now. So you want to use the same code for all 576 examples you have isn't it?. In such a case you have two options: use the "two.sided" alternative so the test becomes "do x and y have the same mean?" or use two different codes, one for 'greater' and one for 'less'. In the latter solution you can read the example, take the mean of each column, compare them and use an if then else to select which t.test you want to run $\endgroup$ – lsmor Apr 16 '19 at 14:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.