# Can I use NormalPValue the same way for lower-tail and upper-tail hypothesis tests?

I want to ask if I can use the NormalPValue[val] the same way for lower-tail and upper-tail hypothesis tests or if there is something I need to watch out for? Personally, my gut feeling is that I need to substract the P-Value from 1 for the other kind of test.

Here's an example to show what I'm talking about:

A software reduced the amount of spam of 100 messages to 11%. This is better than the goal of 20%. Based on a significance level of 0.05, is this significant or not? I.e. buy the software or not?

1. We state the following hypotheses:

H0: p >= p0 = 0.20

H1: p < p0 = 0.20

Further use [Alpha] = 0.05.

1. Since we test a proportion we have to use the z-statistic:

p0 = 0.20;

n = 100;

zcalc = (phead - p0) / (Sqrt[p0 * (1 - p0) / n])

-2.25

2. Calculate the P-Value Needs["HypothesisTesting"];

NormalPValue[zcalc]

OneSidedPValue -> 0.0122245

3. Compare P-Value to [Alpha]

Since The P-Value of 0.0122245 is smaller than our [Alpha] = 0.05, we reject H0 and accept the alternative hypothesis H1. The manager should buy the software.

My question now is, if we were to use the following H0/H1 instead (for a different kind of task, of course):

H0: p <= p0 = 0.20

H1: p > p0 = 0.20

Am I correct that in this case, I would receive the P-Value as follows:

1 - 0.0122245 = 0.9877755

And would therefore not be able to reject H0?

• This site is about the programming environment "Mathematica" not about mathematics and statistics in general. You might want to take a gander at crossvalidated.SE for questions about statistics. – Sascha Jan 18 '17 at 12:54
• @Sascha My question stems from Mathematica, since unlike when using TTest (reference.wolfram.com/language/ref/TTest.html) there is no option to define whether it's a lower-tail or upper-tail test in the OneSidedPValue[val] function. I.e. I don't understand what OneSidedPValue returns and how to properly use it. – Jonas Kaufmann Jan 18 '17 at 12:58
• You might want to edit your question to reflect what you stated in your comment. – Sascha Jan 18 '17 at 13:00
• There are some issues with the example you've used. The distribution that is assumed is a binomial distribution and the "exact" answer for the first set of hypotheses is CDF[BinomialDistribution[100, 0.2], 11]. For the second set of hypotheses the answer is 1 - CDF[BinomialDistribution[100, 0.1], 10] which is not "1 minus the first probability". A "P-value" is the probability of obtaining at least as extreme a value as observed. (I've ignored the complication that you have a compound hypothesis for the null hypothesis.) – JimB Mar 20 '17 at 0:07
• If your underlying distribution was continuous, then, yes, the P-values would be 1 minus the other. Also, in that case you could use LocationTest` which does have an option for a one-sided alternative hypothesis. – JimB Mar 20 '17 at 0:09