In this tutorial, I'm going to show you how to convert a z-test statistic into a p-value using a graphing calculator, a z-table, and Excel. And I'm going to do so by using a few hypothesis test examples.
So in this first example, we have a pharmaceutical company that manufactures ibuprofen pills, and they need to perform some quality assurance to make sure that they have the correct dosage, which is supposed to be 500 milligrams. This is a two sided test because if their pills are deviating in either direction, either there's more than 500 milligrams or less than 500 milligrams, significantly, that's going to be a problem. So of their random sample, they get an average dose of 499.3 milligrams with a standard deviation of 6 milligrams.
Now because this is quantitative data, this is a population mean-- the 500 milligrams. We're going to use this formula to calculate our z-test statistic. When I do so, I get a z-score of negative 1.304. But because this is a two sided test, it's not enough to just look at the left tail. I also have to look at the equivalent of the right tail. So a positive 1.304.
So first I'm going to show you how to use the z-table to get your p-value. So in this case, in your z-table, the left column will take you up to the 10th place whereas the top row will take you up to the hundredths place. So we got a z-score of negative 1.304. And again, the table can only take you up to the hundredth place. So we're going to look for negative 1.30.
So in my column, here's my negative 1.3. And my hundredth place is 0. And that gets me a p-value of 9.68%.
Now that is just for the negative 1.304, 4. so we also have to take the positive 1.304 into account in my upper right tail. So I have to times that by 2 to get my true p-value. So my p-value is 0.0968 times 2, which is 0.1936 or 19.36%. And I'm also going to show you how to do this on your calculator, which can actually get you an even more exact p-value because we don't have to cut off our z-score at the hundredths place.
So using your calculator, you're going to hit second distribution. And we're going to use normalcdf, which stands for "normal cumulative density function." Now, when inserting your values into your calculator, we always go lower boundary, comma, upper boundary. So I'll write that down. So using our calculator function normalcdf, we use lower boundary, comma, upper boundary.
And in this case, the lower boundary we shade all the way to the left of the curve. That's negative infinity. Well, we can't put negative infinity into our calculator. So what we use in our calculator is a negative 99, and that signifies to the calculator I'm going all the way to the left on my curve.
And then we hit our comma button, and we go up to the upper boundary. So the shading stops at a negative 1.304 for my z-score. Hit Enter, and look. We get about the same value we got on our table, which is 0.0911 or 9.61%. So in this case, we did negative 99, comma, negative 1.304 to get a p-value of 0.961. And again, we have to take both tails into account since it's a two sided test. So I'm going to times that value by 2 to get a p-value of 19.22%.
In Excel, to convert the z-test statistic into a p-value, you're going to click on your formulas tab. And we're going to insert a formula that we're going to find under the statistical column. And it is NORM dot distribution right here at the top. And the first value we're going to input is the mean of our sample, which was 499.3, comma, the population mean that we're testing against, which is 500, comma, the standard deviation, which was 6, divided by-- and I have to insert a square root, which is under the math and trig column right here. SQRT 125.
Be careful with your parentheses. Let's see. So far, I have one, two, three open and two closed. Oops, that's not what I wanted to do. Comma, and then cumulative, we're going to put "true." Hit Enter. Something's wrong with my parentheses. I need to close one more parenthesis.
And you can see we get the same value we did from the table and our calculator. But because this is a two-sided test, we have to times this by 2. So go ahead and put equal. Click on that cell, and then to do multiplication, it's the asterisk times 2. And we get our 19.21% for our p-value.
For this example, we are looking at the proportion of students who suffer from test anxiety. And we're testing the claim that fewer than half of students suffer from test anxiety. So in this case, we have a left tailed test. Now because we are looking at qualitative data, it's either yes or no. I either suffer from test anxiety or I do not. This is a population proportion, and we're going to use this formula to calculate our z-test statistic.
When I do so, I get a z-score of negative 3.162. So testing against that half of students suffer from test anxiety, I just have this little shaded region all the way to the left of my curve. First, I'm going to show you the table. And then I'll show you the calculator.
So again, using my table, I can only go up to the hundredth place. So I am looking for a negative 3.16. So negative 3.1 is right here, and then my 0.06. I get AP value of 0.08%. And I'm going to show you how we can get the same answer on our calculator.
So again, just like the previous example, we're going to use normalcdf,. So you go second distribution, normalcdf. And remember it's always lower boundary, comma, upper boundary of the shaded region. But again, we can't put negative infinity into our calculator, so we signify with a negative 99, comma. The upper boundary of my shaded region is a negative 3.162. Hit Enter, and we get a p-value of 0.00078 or 0.078%.
Back in Excel, we're going to go to our formulas tab again. And we're going to put in, again, NORM dot distribution. And we're going to insert our sample proportion, which was 0.45, against the population proportions, 0.5, comma. And then we need to put in the standard deviation. And here again be careful with your parentheses. It's the square root, which we can find under the math and trig column, SQRT. The square root, parentheses, of 0.5 times 0.5. And you do multiplication with the asterisk. Close my parentheses. Divide it by 1,000. Close my parentheses again, comma, true.
Oops, hold on. I think I-- for my parentheses, there we go. Comma, true, and there we get our p-value, which we got from our calculator as well as our estimated p-value which is close in the z-table.
In this last example, we're going to test the claim that women in a certain town are taller than the average US height, which is 63.8 inches. So from our random sample of women, we get an average height of 64.7 inches with a standard deviation of 2.5 inches. Now inches is a quantitative variable. Therefore, this 63.8 is a population mean. So we're going to use this formula to calculate our z-test statistic. When we do so, we get a z-score of 2.546 which I've labeled here on our normal distribution. So let's go ahead and look at the table to get a p-value that's associated with this z-score.
Now remember your table can only take you to the hundredths place. So I looked for a z-score of 2.55 because I had to round up from the six to make sure I get a more accurate p-value. So based on my table, that is associated with the z-score of 99.46%. Now when you're performing an upper tailed test or a right tailed test, that p-value from the table always reads left to right for your distribution. So that's associated with the 99.46% of the distribution that's unshaded.
So to get the proportion-- or I'm sorry, not proportion, the percent, that's shaded under this curve, we're just going to do 100% minus the 99.46% which gets us 0.54% which is your p-value. Or you can keep it a decimal 1 minus 0.9946 to get a p-value of 0.0054. Both mean the same thing. One is a decimal. One is a percentage.
So let me show you how to do that now on your calculator. Oops, I'm going to leave that there, actually. So again, we're going to do normalcdf. So second distribution, normalcdf. And remember, we put lower boundary to upper boundary of our shaded region. So in this case, the lower boundary of my shaded region is the z-score. So first thing I'm going to put in is 2.546, comma, all the way up to positive infinity. So in order to signify our positive infinity to our calculator, we're going to put a positive 99. And that gets us the same z-score-- I'm sorry, the same p-value from our table. So when I do normalcdf. 2.546, comma, 99, I get a p-value of 0.0054, which is 0.54% for our p-value.
All right, so in Excel, if you don't want to go through the columns and the tabs that I've been showing you so far, what you can do is you can go to equals, and you can start to type in "NORM." And you can see that it's a function we've used before. So we can go ahead and click on it. That's just one alternative way to get to that formula.
So again, we're going to insert our population mean. And then our-- I'm sorry, first our sample mean, and then our population mean. So 63.8. And then we have to put in the standard deviation, which was 2.5 divided by the square root of 50. Followed by true.
And notice we do not get the same p-value we did in our calculator and from the table. Well, in this case because it's a right tailed test, Excel always goes from the first part of the distribution and reads left to right. And we know that the distribution is 100%. So to get that upper portion of our distribution, we have to do equals 1 minus this value. And there we get the p-value that we've seen, which is about 0.545%.