

I am writing this email as I have come across one issue while performing ttest using R. If the function t.test(�) is used, a pvalue of 1 is obtained for a calculated tvalue greater than 1.96. If the tvalue is greater than 1.96, the null hypothesis is rejected. However, if the pvalue is greater than 0.05, one may say that there is not enough evidence to reject the null hypothesis. Thus, a tvalue of greater than 1.96 and a pvalue of 1 leaves the user of R software confused on whether to reject or not to reject the null. Moreover, how can pvalue of stochastic process be exactly equal to 1? Can you please guide me on whom should I report this issue to? Or can you please forward this issue to the appropriate person / team?
Thanking you,
Sincerely,
Smruti Bulsari
Assistant Professor
Department of Human Resource Development
Veer Narmad South Gujarat University
Surat  395 007
(Gujarat) INDIA
Ph:+912612256071 (Ext. 204)
Alternate Email: [hidden email]
LinkedIn Profile: https://www.linkedin.com/in/smrutibulsari0a30b312/Blog Posts: https://wordpress.com/posts/smrutibulsari.wordpress.com [[alternative HTML version deleted]]
______________________________________________
[hidden email] mailing list  To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/rhelpPLEASE do read the posting guide http://www.Rproject.org/postingguide.htmland provide commented, minimal, selfcontained, reproducible code.


Can you show us an example with the data that you are using and the
output from t.test.
A tvalue of 1.96 is not an automatic rejection. It depends on alpha
and the degrees of freedom. Even if we set alpha at 0.05, 1.96 should
not give a pvalue less than 0.05 with finite degrees of freedom.
This also depends on the arguments to t.test. If the alternative is
set to "Less" then a t value of 1.96 would give a pvalue close to
0.975 for high degrees of freedom.
The only time I have seen t.test give a pvalue of 1 is when the data
mean exactly equals the null hypothesis mean and the alternative is
the default of two.sided.
For us to diagnose what is going on we need to see your command (how
you are calling t.test) and what data you are using.
On Tue, Mar 12, 2019 at 1:49 PM SMRUTI BULSARI < [hidden email]> wrote:
>
> I am writing this email as I have come across one issue while performing ttest using R. If the function t.test(…) is used, a pvalue of 1 is obtained for a calculated tvalue greater than 1.96. If the tvalue is greater than 1.96, the null hypothesis is rejected. However, if the pvalue is greater than 0.05, one may say that there is not enough evidence to reject the null hypothesis. Thus, a tvalue of greater than 1.96 and a pvalue of 1 leaves the user of R software confused on whether to reject or not to reject the null. Moreover, how can pvalue of stochastic process be exactly equal to 1? Can you please guide me on whom should I report this issue to? Or can you please forward this issue to the appropriate person / team?
>
> Thanking you,
>
> Sincerely,
>
> Smruti Bulsari
>
> Assistant Professor
> Department of Human Resource Development
> Veer Narmad South Gujarat University
> Surat  395 007
> (Gujarat) INDIA
>
> Ph:+912612256071 (Ext. 204)
>
> Alternate Email: [hidden email]
>
> LinkedIn Profile: https://www.linkedin.com/in/smrutibulsari0a30b312/>
> Blog Posts: https://wordpress.com/posts/smrutibulsari.wordpress.com>
>
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> [hidden email] mailing list  To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/rhelp> PLEASE do read the posting guide http://www.Rproject.org/postingguide.html> and provide commented, minimal, selfcontained, reproducible code.

Gregory (Greg) L. Snow Ph.D.
[hidden email]
______________________________________________
[hidden email] mailing list  To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/rhelpPLEASE do read the posting guide http://www.Rproject.org/postingguide.htmland provide commented, minimal, selfcontained, reproducible code.


On 13/03/19 9:06 AM, Greg Snow wrote:
<SNIP>
> The only time I have seen t.test give a pvalue of 1 is when the
> data mean exactly equals the null hypothesis mean and the alternative
> is the default of two.sided.
<SNIP>
Doesn't have to be *exact* equality. Just close!
E.g.:
set.seed(42)
x < runif(10)
mew < 0.63626
mew==mean(x) # FALSE
t.test(x,mu=mew)
cheers,
Rolf

Honorary Research Fellow
Department of Statistics
University of Auckland
Phone: +6493737599 ext. 88276
______________________________________________
[hidden email] mailing list  To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/rhelpPLEASE do read the posting guide http://www.Rproject.org/postingguide.htmland provide commented, minimal, selfcontained, reproducible code.


Dear Greg Snow / Rolf Turner:
I must thank you very much for your very prompt and a detailed response to my query on t.test command.
I am attaching herewith, a file in csv format, containing the column vector with on which I am performing the onesample ttest using t.test. I understand that 1.96 is not an automatic rejection of null. However, at alpha = 0.05 and degrees of freedom = 99 (100 observations minus 1), one may consider rejecting the null at tvalue greater than 1.96 for a twotailed test and an absolute value of 1.64 for upper and lower tailed tests. I am performing onesample ttest with a hypothesized mean of 50 and the actual mean works out to 59.96753. I would also like to bring to your notice that while, I perform a twotailed ttest using the following command:
t.test(X,mu=50,alternative='two.sided',conf.level=0.95)
I am getting a pvalue < 2.2e16.
If I use the same command with alternative = ‘greater’, as follows:
t.test(X,mu=50,alternative='greater',conf.level=0.95)
I still get a pvalue <2.2e16
However, if I use the command with alternative = ‘less’, as follows:
t.test(X,mu=50,alternative='less',conf.level=0.95)
I am getting a pvalue = 1 and therefore, this query. As you mention in your email, I even thought that 2.2e16 is to be deducted from 1 to get the pvalue for the ‘less’ and perhaps that seems to be a explanation to it.
I am still attaching the R script file and the data file for your perusal.
Thanking you once again.
Kindest regards,
Smruti Bulsari
LinkedIn Profile: https://www.linkedin.com/in/smrutibulsari0a30b312/Blog Posts: https://wordpress.com/posts/smrutibulsari.wordpress.com________________________________
From: Greg Snow < [hidden email]>
Sent: 13 March 2019 01:36
To: SMRUTI BULSARI
Cc: [hidden email]
Subject: Re: [R] Issue with t.test
Can you show us an example with the data that you are using and the
output from t.test.
A tvalue of 1.96 is not an automatic rejection. It depends on alpha
and the degrees of freedom. Even if we set alpha at 0.05, 1.96 should
not give a pvalue less than 0.05 with finite degrees of freedom.
This also depends on the arguments to t.test. If the alternative is
set to "Less" then a t value of 1.96 would give a pvalue close to
0.975 for high degrees of freedom.
The only time I have seen t.test give a pvalue of 1 is when the data
mean exactly equals the null hypothesis mean and the alternative is
the default of two.sided.
For us to diagnose what is going on we need to see your command (how
you are calling t.test) and what data you are using.
On Tue, Mar 12, 2019 at 1:49 PM SMRUTI BULSARI < [hidden email]> wrote:
>
> I am writing this email as I have come across one issue while performing ttest using R. If the function t.test(…) is used, a pvalue of 1 is obtained for a calculated tvalue greater than 1.96. If the tvalue is greater than 1.96, the null hypothesis is rejected. However, if the pvalue is greater than 0.05, one may say that there is not enough evidence to reject the null hypothesis. Thus, a tvalue of greater than 1.96 and a pvalue of 1 leaves the user of R software confused on whether to reject or not to reject the null. Moreover, how can pvalue of stochastic process be exactly equal to 1? Can you please guide me on whom should I report this issue to? Or can you please forward this issue to the appropriate person / team?
>
> Thanking you,
>
> Sincerely,
>
> Smruti Bulsari
>
> Assistant Professor
> Department of Human Resource Development
> Veer Narmad South Gujarat University
> Surat  395 007
> (Gujarat) INDIA
>
> Ph:+912612256071 (Ext. 204)
>
> Alternate Email: [hidden email]
>
> LinkedIn Profile: https://www.linkedin.com/in/smrutibulsari0a30b312/>
> Blog Posts: https://wordpress.com/posts/smrutibulsari.wordpress.com>
>
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> [hidden email] mailing list  To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/rhelp> PLEASE do read the posting guide http://www.Rproject.org/postingguide.html> and provide commented, minimal, selfcontained, reproducible code.

Gregory (Greg) L. Snow Ph.D.
[hidden email]
______________________________________________
[hidden email] mailing list  To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/rhelpPLEASE do read the posting guide http://www.Rproject.org/postingguide.htmland provide commented, minimal, selfcontained, reproducible code.


Hi Smruti,
In the example in question, you are probably doing something like this:
# I didn't see any attachment for the data
X<rnorm(99,mean=59.96753)
t.test(X,mu=50,alternative="less")
One Sample ttest
data: X
t = 101.29, df = 98, pvalue = 1
alternative hypothesis: true mean is less than 50
95 percent confidence interval:
Inf 60.07022
sample estimates:
mean of x
59.90779
What this probably means is since the lower confidence interval for
the test is undefined, the program returns a pvalue of 1 as an
estimate, much like the pvalue<2.2e16 for the other tests.
> 12e16
[1] 1
Neither of these values are exact, but indicate that the null
hypothesis should be accepted or rejected respectively.
Jim
______________________________________________
[hidden email] mailing list  To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/rhelpPLEASE do read the posting guide http://www.Rproject.org/postingguide.htmland provide commented, minimal, selfcontained, reproducible code.


Dear Jim Lemon:
First of all, very sorry for such a long delay in replying to your email.
I am quite surprised that you did not receive the .csv and .R files attachment with my previous email. I am resending those files. However, by any chance, you do not receive them even this time, I must say that you have simulated the values that are almost similar in the example on which I undertook the one sample ttest using t.test. I have got a clear idea of how the t.test algorithm works and generates values through the communication with the Rteam so far. Thank you very much for your detailed and prompt reply.
Kindest regards,
Smruti Bulsari
________________________________
From: Jim Lemon < [hidden email]>
Sent: 14 March 2019 02:25
To: SMRUTI BULSARI; rhelp mailing list
Subject: Re: [R] Issue with t.test
Hi Smruti,
In the example in question, you are probably doing something like this:
# I didn't see any attachment for the data
X<rnorm(99,mean=59.96753)
t.test(X,mu=50,alternative="less")
One Sample ttest
data: X
t = 101.29, df = 98, pvalue = 1
alternative hypothesis: true mean is less than 50
95 percent confidence interval:
Inf 60.07022
sample estimates:
mean of x
59.90779
What this probably means is since the lower confidence interval for
the test is undefined, the program returns a pvalue of 1 as an
estimate, much like the pvalue<2.2e16 for the other tests.
> 12e16
[1] 1
Neither of these values are exact, but indicate that the null
hypothesis should be accepted or rejected respectively.
Jim
______________________________________________
[hidden email] mailing list  To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/rhelpPLEASE do read the posting guide http://www.Rproject.org/postingguide.htmland provide commented, minimal, selfcontained, reproducible code.


>>>>> Rolf Turner
>>>>> on Wed, 13 Mar 2019 09:38:24 +1300 writes:
> On 13/03/19 9:06 AM, Greg Snow wrote:
> <SNIP>
>> The only time I have seen t.test give a pvalue of 1 is when the
>> data mean exactly equals the null hypothesis mean and the alternative
>> is the default of two.sided.
> <SNIP>
> Doesn't have to be *exact* equality. Just close!
> E.g.:
> set.seed(42)
> x < runif(10)
> mew < 0.63626
> mew==mean(x) # FALSE
> t.test(x,mu=mew)
Well, it *prints* as 1. But we've talked about *exact* above:
> t.test(x,mu=mew)$p.value
[1] 0.9999792
> getOption("digits")
[1] 7
> mean(x)
[1] 0.6362622
> print(mean(x), digits=14)
[1] 0.63626220719889
> t.test(x,mu=0.6362622072)$p.value
[1] 1
> 1  t.test(x,mu=0.6362622072)$p.value
[1] 1.049139e11
>
So even we get much closer to the mean, there's still a
difference to one, even though even less visibly.
And then if you go really really close to the mean, small
accuracy loss in the pt() function will kick in, and you'll occasionally
will be correct, Rolf ... but only if you move **much** much
closer .... and in this case, it even seems not to happen at all:
> mx < mean(x)
> mx  mx*(1 + 2^(53+7e15))
[1] 1.110223e16
> 1  t.test(x,mu=mx*(1 + 2^(53+7e15)))$p.value
[1] 1.110223e15
>
Cheers, Martin
> cheers,
> Rolf
> 
> Honorary Research Fellow
> Department of Statistics
> University of Auckland
______________________________________________
[hidden email] mailing list  To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/rhelpPLEASE do read the posting guide http://www.Rproject.org/postingguide.htmland provide commented, minimal, selfcontained, reproducible code.


Thank you very much, Rolf Turner, Greg Snow, Martin Maechler and the entire team for the discussion and responses to my query. It has helped getting and enhancing my clarity on the issue.
Kindest regards,
Smruti
Get Outlook for Android< https://aka.ms/ghei36>
From: Martin Maechler
Sent: Thursday 21 March, 20:25
Subject: Re: [R] [FORGED] Re: Issue with t.test
To: Rolf Turner
Cc: Greg Snow, [hidden email], SMRUTI BULSARI
>>>>> Rolf Turner >>>>> on Wed, 13 Mar 2019 09:38:24 +1300 writes: > On 13/03/19 9:06 AM, Greg Snow wrote: > >> The only time I have seen t.test give a pvalue of 1 is when the >> data mean exactly equals the null hypothesis mean and the alternative >> is the default of two.sided. > > Doesn't have to be *exact* equality. Just close! > E.g.: > set.seed(42) > x mew mew==mean(x) # FALSE > t.test(x,mu=mew) Well, it *prints* as 1. But we've talked about *exact* above: > t.test(x,mu=mew)$p.value [1] 0.9999792 > getOption("digits") [1] 7 > mean(x) [1] 0.6362622 > print(mean(x), digits=14) [1] 0.63626220719889 > t.test(x,mu=0.6362622072)$p.value [1] 1 > 1  t.test(x,mu=0.6362622072)$p.value [1] 1.049139e11 > So even we get much closer to the mean, there's still a difference to one, even though even less visibly. And then if you go really really close to the mean, small accuracy loss in the pt() function will kick in, and you'll occasionally will be correct, Rolf ... but only if you move **m
uch** much closer .... and in this case, it even seems not to happen at all: > mx mx  mx*(1 + 2^(53+7e15)) [1] 1.110223e16 > 1  t.test(x,mu=mx*(1 + 2^(53+7e15)))$p.value [1] 1.110223e15 > Cheers, Martin > cheers, > Rolf >  > Honorary Research Fellow > Department of Statistics > University of Auckland
[[alternative HTML version deleted]]
______________________________________________
[hidden email] mailing list  To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/rhelpPLEASE do read the posting guide http://www.Rproject.org/postingguide.htmland provide commented, minimal, selfcontained, reproducible code.

