Learn fundamental concepts in data analysis and statistical inference, focusing on one and two independent samples.

Loading...

From the course by Johns Hopkins University

Mathematical Biostatistics Boot Camp 2

41 ratings

Learn fundamental concepts in data analysis and statistical inference, focusing on one and two independent samples.

From the lesson

Hypothesis Testing

In this module, you'll get an introduction to hypothesis testing, a core concept in statistics. We'll cover hypothesis testing for basic one and two group settings as well as power. After you've watched the videos and tried the homework, take a stab at the quiz.

- Brian Caffo, PhDProfessor, Biostatistics

Bloomberg School of Public Health

So let's go through an example.

Â a respiratory disturbance index of more than 30 events

Â per hour is considered evidence of severe sleep disordered breathing.

Â Here the respiratory disturbance is usually abbreviated RDI.

Â 30 events per hour is quite a bit, and what this means is, a person's upper

Â airway, their collapses or partially collapses while their sleeping, 30 times

Â in an hour, and on average at 30 times in an hour over the night of

Â sleeping, which is quite a bit because they're

Â being deprived of oxygen every time this happens.

Â And they wake up a little bit and then they fall back asleep.

Â This is a, a disease called sleep disorder breathing.

Â Suppose that, in a, in, let's, let's assume 30 events prior

Â were some sort of cut off, for severe sleep disorder breathing.

Â Now, actually, in case you're interested in this, the cut

Â off for diagnosis of sleep disorder breathing, is far lower.

Â I picked 30 for whatever the reason here, but the.

Â so, so keep that in mind.

Â So imagine if you had, let's say overweight

Â subjects, and you're interested in whether these overweight

Â subjects were drawn from a population that has

Â an RDI, a population RDI greater than 30.

Â So your null hypothesis

Â that the RDI, average RDI for this population is 30,

Â versus the alternative that the RDI is greater than 30.

Â Now notice this, this mu that we're talking about

Â here refers to the population mean, not the sample mean.

Â here we're assuming that the sample mean was 32 events per hour.

Â So we want to test whether, with respect to the model of IID

Â sampling from this population, and we're going to make Gaussian assumptions.

Â And with respect to Gaussian assumptions

Â about the, the respiratory disturbance index,

Â is there enough evidence in the fact that the mean was 32

Â events per hour, and the standard deviation was 10 events per hour,

Â to conclude that the population mean is, in fact, bigger than 30.

Â That's what we'd like to test.

Â The alternative hypothesis that we specified on the previous

Â page was that mu was particularly greater than 30.

Â But, you know, they could, we, you

Â know, those different versions of the hypothesis test

Â for our purposes, where we could test less than, greater than, or not equal to.

Â And there's maybe some philosophical discussion about whether or

Â not testing whether mu is exactly 30 versus not

Â equal to 30 is a, is a sensible thing to do.

Â and we'll talk about that a little bit later.

Â but for the time being, we'll think that

Â the alternative is going to come in three varieties.

Â Grater than, less than, or not equal to.

Â And then, you know, there's, there's basically, we create this two

Â by two table of the kinds of decisions that we could make.

Â So, we could, if the truth was

Â a, in fact, the null hypothesis, we could decide the null

Â hypothesis and that would, in that case we'd correctly accept the null.

Â If the truth was the null hypothesis, and we decide the alternative hypothesis,

Â then we will have made what, what, what is called a type I error.

Â if the falsely rejecting the null hypothesis, if

Â the truth is the alternative hypothesis, and we

Â decide the where we failure reject the null hypothesis, then we've made

Â so called Type II error. And then if the truth is the alternative,

Â then we reject the null hypothesis, then will have correctly rejected the null, so

Â that in, encapsulates the decision space for hypothesis

Â testing. So let's revisit

Â this court of law example again.

Â So, in general, in most courts, the

Â null hypothesis is that the defendant is innocent.

Â And then, we're going to require evidence to request evidence

Â to reject the null hypothesis or convict a person.

Â If we require very little evidence, then what, what happens?

Â Well, we increase the percentage of innocent people convicted which in this

Â case would be type one error.

Â however we would also increase the percentage of guilty people

Â convict, convicted so this would be correctly rejecting the null.

Â On the other hand, if the court requires a lot

Â of evidence to convict someone then we increase the percentage of

Â innocent people let free in, in this case that's correctly

Â accepting the null But then we would also increase the percentage

Â of guilty people set free.

Â These, this is, this case would be type II error.

Â So this also goes to show, you know, basically in all decision spaces, not

Â just in statistical decision spaces but certainly

Â the same things happens in policies for, law.

Â Is that the type I and type II errors are

Â associated as you increase one you decrease another and vice versa.

Â And what

Â we'll see is, we'll kind of set up our statistical decision making

Â in a particular way to minimize the chance of type I errors.

Â And as, as doing so then we've kind of hamstrung our self a lot

Â about what the, the, the what kind of type II errors we can make.

Â and so, that's that'll, that'll cloud I think a lot of our kind of framework and

Â rubric that we talk about for hypothesis testing is that

Â we're going to very specifically control Type I errors and

Â then we'll talk maybe later on about how we can

Â control type, type II errors and try to minimize them.

Â Now, now obviously to, you know, to, to, to control type

Â II errors while also keeping type I errors Well, you have to do something.

Â You have to get better evidence.

Â Not just more or less, but better

Â evidence, and that's, we'll talk about that.

Â So, let's talk a little bit about what's the kind of standard way to

Â implement hypothesis testing, and we'll go back

Â to our example with a respirator disturbance index.

Â And the kind of obvious strategy we want to test whether

Â or not the mean, the population mean is bigger than 30.

Â The obvious thing, strategy would be to to say well, is the sample mean

Â larger than some constant where we pick the constant in some traditional way.

Â Well, the, the traditional way to do this now is to pick the constant so that

Â the probability of the type 1 error is

Â low, you know and, and there's a standard benchmark

Â that, that occurs very commonly which is 5%.

Â But the idea is that the type 1 error rate is controlled.

Â So that the probability of making a type one error is low.

Â And, and there's a couple of reasons why people do this.

Â One is maybe there's some logic to it, right, that we you know, we want to, you

Â know the, the, the, the null hypothesis is our status quo hypothesis

Â so we want to make sure. That we don't reject that hypothesis idly.

Â And so, if it's true.

Â And so, maybe there's some scientific sense

Â of, of conservatism scientific conservatism, built into it.

Â it's also, I think, rather pratical in terms of the mathematics.

Â In that, the fact that, under the null hypothesis, the mean is sharply

Â specified at mu equal 30.

Â that makes the math a little easier as well.

Â And it turns out you can also say whether that, mu is

Â not just strictly equal to 30, but less than or equal to 30.

Â You wind up with a, with the same test.

Â But the fact that the null is this sharp

Â null hypothesis also helps with the mathematics a little bit,

Â which maybe isn't the best reason to do it, but

Â still, nonetheless, it's a good reason, or it's part of

Â the reason why I think people do it. But maybe the main reason is this

Â idea that we want to control for Type I error is and have that probability be low.

Â So the type I error rate we usually assign the letter alpha, the Greek letter alpha.

Â And that's probability of the type I error.

Â So, the probability of rejecting the null hypothesis, when in fact it's true.

Â We want the type I error rate to be 5%.

Â So, what we're going to do is we're going to choose this constant C

Â and situate that it factors in the, the uncertainty associated with the

Â sample mean in the, in, in, in such a way that our

Â Type I error rate, probability of a Type I error rate is 5%.

Â So let's go ahead and do that.

Â Okay so we want this value c here to

Â be chosen so that the probability of getting a sample

Â mean larger than it given that the mean is,

Â the population mean is actually 30 to be 5 percent.

Â That would be the probability of a type one error if we're going to observe The

Â rule that we're going to reject for an X bar larger than this constant,

Â okay? Well so either by the Central Limit

Â Theorem or supposing our data is, is, is

Â Gaussian, we can normalize X bar so that

Â it's zero mean. Unit variance under the null, okay.

Â So in this case we can subtract off 30 from both sides of this equation,

Â because that's the actual population mean.

Â And then we can divide by the standard error of the mean which in this case

Â is 10 over square root 100, 10 because

Â that's Let's assume known standard deviation, of the population.

Â And then square root 100.

Â Because 100 observations. The mean is comprised of 100 observations.

Â So this quantity right here.

Â X bar minus 30 over 10 divided by square root 100.

Â That is a, that's a, a standard normal now.

Â Or, you know, it limits to a standard normal if the data are

Â [INAUDIBLE]

Â And so, we can just take this whole quantity here, and replace it with a z.

Â Okay?

Â And on the right hand side, we have c minus 30.

Â And we want to calculate this, we're, remember, the

Â reason that this quantity is a Z random variable,

Â is we're calculating this probability under the condition that

Â the null hypothesis is true, so mu equal 30.

Â You'll see here this point that I was making earlier, that when the.

Â Null is true we have a sharply specified parameter, it

Â helps, right, because we can actually plug in exactly 30 here.

Â Okay, so we want 5% to be equal to the

Â probability a Z random variable is bigger than C minus 30.

Â So we could just set C minus 30, well,

Â I put divided by 1 here just to remind ourselves

Â of the standard error in the denominator.

Â We want it to, to be set to a value

Â that has the probability of Z being larger than at 5%.

Â Well, we know what that value is.

Â It's the 95th percentile of the standard normal, which

Â is 1.645. We can solve for C, and C is 31.645.

Â Since our mean is 32 in this case, we would reject the null hypothesis.

Â [INAUDIBLE]

Â . Okay.

Â Very briefly, I'd like to just show how to get this normal quantile in r.

Â Here, I have a cutout of our studio.

Â And I'm just typing in the appropriate command.

Â Okay.

Â So very briefly, let's just illustrate with picture,

Â what that calculation is, is giving for us.

Â So here, I have my r studio window.

Â Just to remind ourselves, the 95th percentile of the normal is about 1.645,

Â we do that with the cue norm function. So let's visualize it.

Â Let's create some grid points to, to plot.

Â and so this is just sequence from minus 3 to plus

Â 3, 0.2 and that, that covers most of the normal distribution.

Â The y value here is evaluated at the normal

Â density of the x values, so let's plot that.

Â So we see a plot of the bell shaped curve from minus 3 to plus 3 about

Â let me define the sequence that we want to shade in that represents

Â 5% of this. I'll shade it in with a polygon.

Â There is is now shaded in salmon color.

Â and then just remind us that's 5% of the curve and then the

Â number that represents that 5% is 1.645.

Â Coursera provides universal access to the worldâ€™s best education,
partnering with top universities and organizations to offer courses online.