Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

output p value from a t-test in R

Tags:

r

p-value

So lets work through the example from ?t.test()

We do a two-sample t-test on the data by:

t.test(1:10, y = c(7:20))

Now I am only interested in saving the p-value When I input the followng code, the $p.value is also saved.

t.test(1:10, y = c(7:20))[3]

I want only the p-value saved (with the $p.value) as an numeric/integer/double. Sorry for asking such a simple question

like image 382
lukeg Avatar asked Jul 03 '15 11:07

lukeg


People also ask

What is p-value in R output?

The p-value is an estimate of the probability of seeing a t-value as extreme, or more extreme the one you got, if you assume that the null hypothesis is true (the null hypothesis is usually "no effect", unless something else is specified).

Does T test give p-value?

Every t-value has a p-value to go with it. A p-value from a t test is the probability that the results from your sample data occurred by chance. P-values are from 0% to 100% and are usually written as a decimal (for example, a p value of 5% is 0.05).

How do you find the p-value in a normal distribution in R?

In R, we may use the pnorm() function to find the p-value associated with a z-score, which has the following syntax. mean: The normal distribution's mean. The default value is 0. sd: The normal distribution's standard deviation.


1 Answers

You can save the p-value from the t-test to another variable with something like:

pVal <- t.test(1:10, y = c(7:20))$p.value

pVal will then be numeric:

> str(pVal)
num 1.86e-05
like image 138
Stewart Macdonald Avatar answered Sep 21 '22 19:09

Stewart Macdonald