I'm struggling with computing two-tailed p-values from a Z value:
pvalue = pnorm(zscore, meanIAT2, sdIAT2, lower.tail = FALSE) calculates a one-tailed p-value.
Now, usually you would use 2*pnorm for a two-tailed test. However, if I do that, I get p > 1. What do I do wrong?
The Z scores have mean 0 and SD 1, so that step went correctly.

Follow

@Maxprimbs intuitively, you are on the wrong end of the distribution - if the z-val is negative, you'd do $lower.tail = TRUE$ and that should work (?)

@levolz I have a z score of 0.30, a population mean of 0.307, a SD of 0.03, and my p value for lower.tail = False is 1.03.
For my z of 6 it is 0 with false and 2 with true.

This is all very weird.

@Maxprimbs @levolz If you can get something like a 2-sided p-value here like pnorm(.30,.307,.03, lower.tail=T)+pnorm((.307+(.307-.30)), .307, .03) which gives you the symmetrical probability of any value being at least as far removed from the mean as the observed value. Note though, that, because it symmetrical, this is equivalent to just using pnorm(.30, .307, .03, lower.tail=T)*2.

@Maxprimbs @levolz the reason why it is 0 or 1 with z = 6 is just rounding (it is actually like really really small or really really big) so you can denote it as <.001 or > .999 depending on the hypothesis.

@julianquandt @levolz Thanks, that makes sense. Do you have any idea why the other one (2*pnorm(.306644094402146, .307794, .03393001, lower.tail = FALSE)) would return a p of 1.05?

The Z is larger 0, hence it should be lower.tail = False, or not?

@Maxprimbs @levolz I think what matters is whether it is positive or negative with respect to the population mean. So here, if you would want to know about values as "extreme" (i.e. removed from the mean) you would care about values < .306644094402146 and larger .307794+(.307794-.306644094402146) assuming that in your scenario the zscore is supposed to be tested against the population distribution.

@julianquandt @levolz I found the error. I standardized twice, once when calculating the z score and again when specifying my actual population mean and sd in pnorm, instead of the mean and sd of the z scores.

@Maxprimbs @julianquandt
Ah yes, that ofc makes sense then - kind of didn't doubt that before :D
Glad it's fixed now!

@julianquandt @Maxprimbs
Thanks for the added context, Julian!

@ max: pnorm(.30, .307, .03, lower.tail=F) is equivalent to pnorm(-.07, 0., .03, F), so you integrate over more than half of the probability distribution - that's why lower.tail = T fixes it here

Sign in to participate in the conversation
Qoto Mastodon

QOTO: Question Others to Teach Ourselves
An inclusive, Academic Freedom, instance
All cultures welcome.
Hate speech and harassment strictly forbidden.