Issue with t.test

classic Classic list List threaded Threaded
8 messages Options
Reply | Threaded
Open this post in threaded view
|

Issue with t.test

SMRUTI BULSARI
I am writing this e-mail as I have come across one issue while performing t-test using R. If the function t.test(�) is used, a p-value of 1 is obtained for a calculated t-value greater than 1.96. If the t-value is greater than 1.96, the null hypothesis is rejected. However, if the p-value is greater than 0.05, one may say that there is not enough evidence to reject the null hypothesis. Thus, a t-value of greater than 1.96 and a p-value of 1 leaves the user of R software confused on whether to reject or not to reject the null. Moreover, how can p-value 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:+91-261-2256071 (Ext. 204)

Alternate E-mail: [hidden email]

LinkedIn Profile: https://www.linkedin.com/in/smruti-bulsari-0a30b312/

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/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
Reply | Threaded
Open this post in threaded view
|

Re: Issue with t.test

glsnow
Can you show us an example with the data that you are using and the
output from t.test.

A t-value 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 p-value 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 p-value close to
0.975 for high degrees of freedom.

The only time I have seen t.test give a p-value 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 e-mail as I have come across one issue while performing t-test using R. If the function t.test(…) is used, a p-value of 1 is obtained for a calculated t-value greater than 1.96. If the t-value is greater than 1.96, the null hypothesis is rejected. However, if the p-value is greater than 0.05, one may say that there is not enough evidence to reject the null hypothesis. Thus, a t-value of greater than 1.96 and a p-value of 1 leaves the user of R software confused on whether to reject or not to reject the null. Moreover, how can p-value 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:+91-261-2256071 (Ext. 204)
>
> Alternate E-mail: [hidden email]
>
> LinkedIn Profile: https://www.linkedin.com/in/smruti-bulsari-0a30b312/
>
> 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/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, 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/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
Reply | Threaded
Open this post in threaded view
|

Re: [FORGED] Re: Issue with t.test

Rolf Turner
On 13/03/19 9:06 AM, Greg Snow wrote:

<SNIP>

> The only time I have seen t.test give a p-value 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: +64-9-373-7599 ext. 88276

______________________________________________
[hidden email] mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
Reply | Threaded
Open this post in threaded view
|

Re: Issue with t.test

SMRUTI BULSARI
In reply to this post by glsnow
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 one-sample t-test 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 t-value greater than 1.96 for a two-tailed test and an absolute value of 1.64 for upper and lower tailed tests. I am performing one-sample t-test 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 two-tailed t-test using the following command:

t.test(X,mu=50,alternative='two.sided',conf.level=0.95)

I am getting a p-value < 2.2e-16.

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 p-value <2.2e-16

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 p-value = 1 and therefore, this query. As you mention in your e-mail, I even thought that 2.2e-16 is to be deducted from 1 to get the p-value 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/smruti-bulsari-0a30b312/

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 t-value 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 p-value 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 p-value close to
0.975 for high degrees of freedom.

The only time I have seen t.test give a p-value 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 e-mail as I have come across one issue while performing t-test using R. If the function t.test(…) is used, a p-value of 1 is obtained for a calculated t-value greater than 1.96. If the t-value is greater than 1.96, the null hypothesis is rejected. However, if the p-value is greater than 0.05, one may say that there is not enough evidence to reject the null hypothesis. Thus, a t-value of greater than 1.96 and a p-value of 1 leaves the user of R software confused on whether to reject or not to reject the null. Moreover, how can p-value 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:+91-261-2256071 (Ext. 204)
>
> Alternate E-mail: [hidden email]
>
> LinkedIn Profile: https://www.linkedin.com/in/smruti-bulsari-0a30b312/
>
> 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/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, 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/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
Reply | Threaded
Open this post in threaded view
|

Re: Issue with t.test

Jim Lemon-4
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 t-test

data:  X
t = 101.29, df = 98, p-value = 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 p-value of 1 as an
estimate, much like the p-value<2.2e-16 for the other tests.

> 1-2e-16
[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/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
Reply | Threaded
Open this post in threaded view
|

Re: Issue with t.test

SMRUTI BULSARI
Dear Jim Lemon:
First of all, very sorry for such a long delay in replying to your e-mail.
I am quite surprised that you did not receive the .csv and .R files attachment with my previous e-mail. I am re-sending 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 t-test using t.test. I have got a clear idea of how the t.test algorithm works and generates values through the communication with the R-team 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; r-help 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 t-test

data:  X
t = 101.29, df = 98, p-value = 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 p-value of 1 as an
estimate, much like the p-value<2.2e-16 for the other tests.

> 1-2e-16
[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/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
Reply | Threaded
Open this post in threaded view
|

Re: [FORGED] Re: Issue with t.test

Martin Maechler
In reply to this post by Rolf Turner
>>>>> 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 p-value 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.049139e-11
  >

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+7e-15))
  [1] -1.110223e-16
  > 1 - t.test(x,mu=mx*(1 + 2^(-53+7e-15)))$p.value
  [1] 1.110223e-15
  >

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/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
Reply | Threaded
Open this post in threaded view
|

Re: [FORGED] Re: Issue with t.test

SMRUTI BULSARI
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 p-value 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.049139e-11 > 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+7e-15)) [1] -1.110223e-16 > 1 - t.test(x,mu=mx*(1 + 2^(-53+7e-15)))$p.value [1] 1.110223e-15 > 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/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.