**800**wrote:

Hi everyone!

Can anyone tell me how to calculate p-values from z-scores in R? Is this the correct way:

pvalue = pnorm(-abs(z))

Thanks!!!

**52k**• written 7.8 years ago by Diana •

**800**

Question: Calculating P-Values From Z-Scores

11

Diana • **800** wrote:

Hi everyone!

Can anyone tell me how to calculate p-values from z-scores in R? Is this the correct way:

pvalue = pnorm(-abs(z))

Thanks!!!

ADD COMMENT
• link
•
modified 14 months ago
by
Kevin Blighe ♦ **52k**
•
written
7.8 years ago by
Diana • **800**

7

Manu Prestat ♦ **3.9k** wrote:

your expression is good. Just don't forget, if relevant, to take into account the two-sided characteristic of the test, it would be then:

```
pvalue2sided=2*pnorm(-abs(z))
```

And, if you think you need to use the "apply" function, you might need to think about multitesting correction... but, I agree, this is another topic ;-)

1

Thanks! my test is one-sided as I am looking at enrichment only

1

Gjain ♦ **5.4k** wrote:

Hi Diana,

I was explaining the same thing to my friend this morning.

here is a very nice and useful link: Calculating p Values

- Calculating a Single p Value From a Normal Distribution
- Calculating a Single p Value From a t Distribution
- Calculating Many p Values From a t Distribution

I hope this helps.

1

Emre • **90** wrote:

Based on the previous answers and comments, here is a function that considers both the one-sided case (two alternatives, observed scores are greater / z is positive: "+", observed scores are lower / z is negative: "-") and two sided case ("NULL").

convert.z.score<-function(z, one.sided=NULL) { if(is.null(one.sided)) { pval = pnorm(-abs(z)); pval = 2 * pval } else if(one.sided=="-") { pval = pnorm(z); } else { pval = pnorm(-z); } return(pval); }

1

Kevin Blighe ♦ **52k** wrote:

Yet another [late] answer, in the context of GWAS: A: SNP dataset and Z Score

Kevin

Please log in to add an answer.

Use of this site constitutes acceptance of our User
Agreement
and Privacy
Policy.

Powered by Biostar
version 2.3.0

Traffic: 934 users visited in the last hour