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.
@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.
@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.
@Maxprimbs @julianquandt
Ah yes, that ofc makes sense then - kind of didn't doubt that before :D
Glad it's fixed now!