1. Home
  2. Explore
  3. Statistics
  4. Confidence Intervals and Hypothesis Testing

Study methods

Flashcards
Quiz
Fill in the blanks
Written test
Lesson
Notes
Podcast
Content

Confidence Intervals and Hypothesis Testing

Transcript

Hi, and welcome to the second  session of the basic stats course.   This session will cover confidence  intervals, hypothesis testing, and p-values.   My name is Martha Elwenspoek and I'm a  quantitative researcher at NIHR Arc West. These are the learning objectives of this  second session. So hopefully by the end of   this lecture you will have a better understanding  of the following. That's what it means to infer   from samples to populations. You will  understand what sampling variation means.

The difference between precision and accuracy. Why we need standard error what it means, and how  we can use it to calculate confidence intervals. And finally when you will use hypothesis  testing and how to interpret p-values. I will try to explain all these concepts that  I showed you in the previous slide by using this example, which is not a real study, it's  just it's a fake example. So let's say we   want to do a weight loss program and we want to  know how effective this weight loss program is. So we recruit 100 women age between 20 and 35  years old, and we measured their weight beforehand   and after. Then we can calculate the the mean  weight loss after the intervention. So before on   average they weighed 70 kilograms and afterwards  66.3 kilograms so there was a difference in weight

of 3.7 kilograms. So we can already see that on  average these women lost weight, and if we look   at the graph that I'm showing here, so you can  show the data like this as well, you can see that   the weight on average before is higher than  after. But this is not enough information to   judge whether this is a real effect and whether  this is a significant reduction in weight.

To judge that we need either the  p-value or confidence intervals. So here I'm showing the confidence interval and  the p-value so the 95% confidence interval goes   from 3.4 to 4 kilograms, and how you read this  is that you are 95% confident that the true   weight loss, the true value of weight loss,  is somewhere between 3.4 and 4 kilograms.

So that means that even in the worst case scenario  you expect that the weight loss program causes on average a 3.4 kilogram weight loss, which is  a good effect. In fact this is what you would   want to see. If we look at the p-value it's very  low so this means that it's highly significant. So this is an example of a real study, of a  paper that was published in the Lancet in 2013,   and this shows the results of a randomized control  trial where they looked at the effectiveness of   using electronic cigarettes for smoking cessation.  They compared three groups so they had one group   where they used e-cigarettes that contain  nicotine, one group e-cigarettes without nicotine,   that was the placebo group, and then they also  compared the effect with using nicotine patches.

Here I'll just show you the results, so you  can see how results like these are presented   in papers. So they say that most participants  relapse within 30 days after stopping smoking,   but they found a difference in a different group,  so the people using the nicotine e-cigarettes, their time to relapse was 35 days and  then they showed this confidence interval. Then because they compare it to a different  group, and this is the one that uses,   the patches they again show the results,  so this is their estimate for this group,   and followed by the confidence  interval and the p-value. So this p-value shows what the difference is  between the first group and the second group   and then they also compare this to the  placebo e-cigarette group and again   they show you the estimate and the confidence  interval and a p-value. So we will come back

to this paper at the end of this session and then  hopefully these concepts make more sense to you. Okay so what does it mean to infer from samples to  populations? So every time you do a study you're   interested in a certain population, you want to  know something about a population. But because   it's hardly ever possible to measure everyone  in a population, you need to take a subsample. So what you do is, if this is the population  you're interested in you will recruit a sample   from this population that is supposed to be  representative of that population, and you will

do your measurements in this group. So this can  be a mean, median, proportions, or percentages,   whatever you want to measure. But of course what  you're really interested in is what does this tell   me about the population? You're not interested in  the sample per se, but you want to say something   about the population, and that's what  we mean with statistical inference. So to do this you will use standard  error confidence intervals, and p-values   because they tell you how likely is it that  what I see is a true effect? How likely is   it to see something by chance? And how how  likely is it that this is a true effect?

So here are just some examples of when  you would use statistical inference.   So the simplest example is just to  estimate population demographics such as,   what is the percentage of smokers in the UK?  So you come up with an estimate which is in   a percentage in this case and you can  draw a confidence interval around that. Also for comparing groups, so in the weight  loss study example that I've used before,   we had a before and after measurement and you will  measure the difference between before and after   and look at a confidence around the difference.  Or you can compare two different treatment groups.   So this is for instance the e-cigarette  study that I mentioned, so when you compare   e-cigarettes to placebo e-cigarettes or another  example would be statins versus the placebo.

In this case they measure a mean difference  and show a confidence interval there. Finally you can also have studies that compare one  treatment to another treatment. So this was also   an example in this study of e-cigarettes where  they compared e-cigarettes with nicotine patches.   Or another example would be paracetamol compared  with ibuprofen, where they could measure pain   scores and even around these scores that do not  have any units you can draw a confidence interval.

So what does this mean for the weight loss example  that I've mentioned? So in the weight loss example   the population that we are interested in  are women in the UK between 20 and 35.   So that's why we've recruited a sample of women  between 20 and 35 that live in the UK. Our   outcome in the study would be the mean weight  loss in kilograms after the intervention, and what we want to know is, we want to estimate  the true weight loss of the population. So   this is statistical inference and we want to  know, whatever we've measured in our sample,   could this have been a chance  finding? And how likely is it to   to see this effect if actually the  weight loss program is ineffective?

So whenever we do a study we take a  subset, and because we take a subset, we won't measure the exact truth because  we haven't measured everyone. We can   also imagine that it will never be the  exact same value as if we measured everyone. So even if we repeat the study in exactly  the same way, and we recruit people in   exactly the same way, we will still  get different people in our sample.   So we can imagine that the answer  will also be slightly different.   You would expect them to be similar, but  every time they will be slightly different.

So how do you know how confident you can be in  your estimate? Which of these studies is close   to the truth? So that's when we want to calculate  things like confidence intervals and p-values. So this fact - that every time you  take a sample you get a different   estimate - is called sampling  variation or sampling error. So if you have performed a study and you've  calculated a sample mean, you want to know how   good this sample mean is as an estimate of the  population mean, because you ultimately want to   know the population mean. So a good estimate  means that it's both precise and accurate.

These are very much related concepts but they're  slightly different and I think these four bulls   eyes show nicely what the difference is. So  you can have an estimate which is precise but   inaccurate, in that case the arrows are all  very close together or your measurements are   also very close together but they're not close to  the truth. So the bullseye represents the truth. You can also have a situation where  your measurements are not very precise   but they are accurate. So here the errors are all on average close to the truth (so the  bulls eye) but they are not close together.

Then of course you have situations that where  your estimate is not precise and not accurate, so   they're just all over the place. Then ideally you  have an estimate that's both precise and accurate. So precision means errors are close together  and accuracy means it's close to the truth. So this is just another way to look at what the  difference is between precision and accuracy.   So if the red line shows the the distribution of  the of the population. This is the truth, this is   something you, don't know, so this is in in case  you were able to measure everyone in a population,   then you know what the true  underlying distribution is.   The blue bars are all the studies  that have tried to measure this and some studies are very close to the  truth and other studies are are further off.

So on average these studies, if you would  take the average of all these studies,   you would think that the true value is around  here, although the true value is actually here,   so the difference between these things that's  what we call accuracy. But precision is how wide this distribution looks like, so if the studies  would be very similar then you would be much more confident about this estimate of the mean.  But this is quite a wide range in studies,   so some studies thought and the effect was all the  way here, another thought it was all the way here.

We can only calculate precision,  we cannot calculate accuracy. We calculate precision by calculating the  standard error and the higher your standard   error the lower your precision. So you want to  have a low standard error to have a high precision   and there's two things you can do to  influence precision or your standard error,   and that's either, by changing the sample size,  so the more people you have in your study the   more precise your estimate will be. On the  other hand the lower the standard deviation of your your variable that you're  measuring and higher the precision.

So this is what the formula  looks like for standard error. Again standard error is a measure of  precision. As I mentioned the previous slide,   either you change the standard deviation,  which is not that straightforward,   or you change the sample size to change or  have an effect on precision of your estimate. So the higher the standard deviation  the higher the standard error,   and the higher the sample size  the lower the standard error.

Again let's go back to our weight  loss example, so what does this mean   for the results that we had from our weight loss  study? We had a hundred people in our study and   we had their before measurements,  after measurements and the difference. And I'll just give you the standard deviation. So if standard deviation is a 1.5 how  do you calculate the standard error?

So we need to divide the standard deviation   by the square root of the number  of participants in the study. So it was a 100, and that means that the standard error  for this study would be 0.15. I've showed you how to calculate the  standard error, but what's the point   of doing this? You can hardly  ever see it reported in papers. But what you do see is confidence intervals   and you need the standard error to  calculate the confidence intervals.   So now you know what goes into the standard  error - it's dependent on the standard deviation   and the size of your sample. So how do we  get from there to the confidence intervals?

Well to explain this we have to  do a thought experiment first. So let's assume that we have  all the resources in the world   and we can take we can repeat  our study a thousand times. In this case we take a sample of 20 women to  do our weight loss program, and we calculate   the effect, and we do it again, and again,  and again and we do it a thousand times.

So here we can then show  our results, so instead of   having a measurement per participant  we have a measurement per study. So   these are all the mean values per study so  the results of each study in weight loss. We can show the same data as we would  show individual data, as a distribution.

As you can see that this also forms a normal  distribution, but again here we're showing   sample means so these are all different studies.  Most studies found something like a two and a half   a kilogram weight loss and there's some outliers,  so some studies found more than five kilogram   weight loss. Others found no weight loss.  Or some even found an increase in weight,   because it was lower than zero the weight loss  was negative so that means an increase in weight.

In the first session you've learned  that the normal distribution has   a few characteristics and these  same characteristics apply for   our normal distribution that I  just showed of our sample means. So just to compare the when you draw a  normal distribution or when you look at   your data from one study and you just  show all the individual values then you   can get a normal distribution if this is  a variable that's normally distributed.

And you've learned in the last session that  95% of these values will fall within about two   standard deviations on either side of the mean.  So you've calculated the mean of your study and by definition if these are normally distributed  95% percent of the individual measurements will   fall somewhere between two standard  deviations on either side of the mean.

You can apply these same rules to the  distribution that I've showed you on the   previous slide. So if we're talking about the  distribution of sample means, so this is not one   individual study, but these are like a thousand  studies that we've done over and over again. So in this case you can calculate the mean  of these studies of the the study results.   So the zero here represents the mean of the means, and then the same rules apply that 95% of  the study means will fall anywhere between minus 2 and plus 2 (standard error  in this case) of the mean of means.

And at 95% that's where our 95% confidence  interval comes from. So if we look at our study,   the one that I've showed you  in the beginning, where we   said that there was a 3.7 kilogram weight  loss. Our study would have been somewhere here, and of course I said this is a hypothetical  example to do a study a thousand times, because   you will never be able to do that. So you don't  actually know that your study is or where your   study is in this underlying distribution if  you would have done the study a thousand times.

So that's why you draw a confidence  interval because your confidence   interval says that you're 95% confident  that the true value (so that would be here)   the true mean falls within the confidence  interval that you draw around your measured mean. So let's look at this graph again just take the  pointer so if we look at the graph on the right.

So if our study is about here. Then if we  draw this confidence interval. So I told you   the confidence interval is calculated by using  the standard error, and the standard error is   dependent on the standard deviation, and the size  of your population, or the size of your sample. So if this is our study mean  then we try to estimate the   underlying standard error of the population  by using the standard deviation from our study   and the sample size of our study. Then we  calculate the standard error from there we,   estimate the confidence interval. As you  can see that because our study fell within   this 95%, not too far from the true mean, our  confidence interval will contain the true mean.

But as you can also see from this picture  that 5% of the cases, are outlier studies, and of course you will not know if your case  is an outlier study. So let's look at that. So if this is your study and this is the mean  that you've measured here, and you draw your   confidence interval around it, the true mean  does not fall within your confidence interval.

So this is a decision that you take as a  statistician you decide that you are happy   with a 95% confidence, and that immediately  means that there's there's a 95% chance that   the true mean falls within this  interval, but there's also a 5% chance   that the true mean doesn't fall  within your confidence interval.

This is another way to look at it, if you did one  study 100 times or 100 of the same studies that   you've repeated with a different sample, and  every cross shows your estimate of the effect   and the true effect is shown by the  blue line. The true effect would be 5. Then almost all studies, if they draw  the confidence interval (I say almost all   because it's about 95% of the studies) the line  crosses the line of the truth. So in 95% of these

studies the truth lies within the confidence  interval that they drew around their estimate,   but their estimates they are quite varied, so they  can be close to the truth or they can be further   away from the truth. You also see that there are  a few studies where this is not the case so these   are your 5%. So these are if you do 100 studies  about 5 (in this case 6) but around 5 of them, the confidence interval  will not hold the true mean. I said that this is something that you  can never do in real life but in fact,   this is what you try to do in in systematic  reviews and and meta-analysis. So this is a

forest plot showing different studies  that were published and showing the effect   estimates of each study, plus their confidence  intervals. Then from here you try to estimate (so this is a line of no  effect) and you try to estimate   the truth by combining all these studies  and hopefully, the combined estimate will   be closer to the truth than every single  study than any of these single studies.

So I've described how you theoretically get your  confidence interval, but this is the formula. To work this our you need the your sample  mean, and you need your standard error to   do the calculation, and then you get this  range from almost two times standard error   on either side of the mean.  So how do we interpret this? This is how you can read it, if you see  a result like this presented in a paper   that we can be 95% certain that the true  population lies within a 95% conference interval   for any given sample. So if the confidence  interval is narrow, the sample estimate is   precise, and if the confidence interval  is wide the sample estimate is imprecise.

So going back to our weight loss program, let's  see how we would calculate the confidence interval   for the data that I've shown you so far. So the  only thing we need is our estimate, so that's our weight difference, 3.7, and we need the standard  error. So we want to calculate two things,   we want to calculate the lower end  of the confidence interval, and the   higher end of the confidence interval. So  that's why we'll do the sample mean -1.96   times the standard error, and sample mean +1.96  times the standard error. So if we fill out   the numbers, so that is our 3.7 weight difference,  and the standard error that we calculated before,

and then we come to this confidence interval.  So the confidence interval goes from 3.4 to 4.0, and your estimate will always lie exactly  in between your higher and lower estimate. Okay, so this is the last part of this lecture  and it's about hypothesis testing. So for every   statistical test you will start by defining  your null hypothesis. Your null hypothesis   always states that there is actually  no effect or there's no difference.

So if you have seen a difference or an effect in  your study, you're asking yourself what is that the chance of the observed difference or  effect, is actually due to sampling variation. So in our weight loss example our null  hypothesis would be 'the weight before and   after the intervention is the same' or 'there  is no effect of the intervention on weight'.

So after defining the null hypothesis you can  go ahead and do your statistical tests and   the next two sessions we'll dive deeper into  how to do these tests, so we will skip that   part for now and just assume we've done a  statistical test which gives us a p-value. So what do these p-values mean and how do we  interpret them? So if we have a p-value of 0.001 you interpret this as follows. There is a 1 in 1  000 probability that the mean difference observed   arose by chance, i.e sampling variation. Or  that the probability that you would observe   this estimate, given the null hypothesis, so that  means assuming that the null hypothesis is true,   is 0.001. So that means it's very unlikely  to see your the effect that you've observed,   just by chance. That's why if the p-value is very  low, we say it's very it's highly significant,

and we assume that what we see is a  true effect and not caused by chance. Another example, if your p-value is 0.1,  then that means that there is a 1-in-10   probability that the mean difference observed  arrows by chance, or sampling variation, or that the probability that you would observe  your estimate given the null hypothesis is 0.1. Okay so the p-value says something about  the likelihood of finding a difference if   in fact the null hypothesis is true, and the null  hypothesis always says that there is no effect.   So if we assume the null hypothesis is true we can  also draw again a distribution of sample means, so   this is if we do the same study a thousand times  on different samples from the same population.

So we would expect that most of those studies find  something close to the truth. So they will all   uh vary around that the the true value. The  true value is zero, because there's no weight   loss because we assume that our our weight loss  program is ineffective. We would also assume   that some studies find a small difference. So some  studies might find that there is some weight loss,   and other studies might find that the people have  actually gained weight after doing the program.

So this can all be explained with sampling  variation. Now what a statistical test does is it   looks at how many standard errors, your estimate  in the study that you've done, how many standard   errors it is removed from the value of no effect.  So in this case the value of no effect is 0   and in our weight loss example we've measured  an effect of 3.0, as 3.7 kilogram weight loss, and we also measured that the  standard error was 0.15. So

if you calculate how many standard errors our  estimate is removed from 0, that's actually   quite a lot, so that's all more than 30 standard  errors we have removed. So measuring something   that's 30 standard errors removed from no effect,  the chance of finding that, if this is true,   is really small and that's why we got a very small  p-value so a p-value that was less than .001. So the p-value gives you the strength  of evidence against the null hypothesis.

So the smaller the p-value the stronger  the evidence against the null hypothesis,   so you should see it as a gray scale. If  you have a very small p-value like in our   weight loss example (so that means that there's  strong evidence against the null hypothesis)   it means it's just really unlikely  that the null hypothesis is true   and the smaller the p-value the more unlikely  it is that the null hypothesis is true.

So let's look back at our weight loss  example, so I already mentioned what   we saw in the beginning that we had a very very  small p-value, so we have found strong evidence   that there is in fact a weight loss and that  there is a significant weight loss in our study. So now we have covered all these objectives.  We've talked about inferring from samples to   populations, and we've discussed sampling  variation. The difference between precision   and accuracy. The standard error and how  we needed to get to a confidence interval.   How you arrive to a confidence interval, how to do  hypothesis testing, and how to interpret p-values.

So just to summarize if these are our  results, and you would write this in a paper,   this is how you would describe  these results. "We are 95%   confident that the true effect of the  intervention is weight loss between   3.4 and 4 kilograms and the probability  that the observed difference arose by chance   (i.e. sampling variation) is less than one in a  thousand". So that's what the p-value shows us. Finally just to show you again the paper that  we saw in the beginning, about electronic   cigarettes for smoking cessation. So hopefully  these results are now easier to interpret,   so you see their estimate in days and with the  confidence interval. So actually they think that   the medium time to relapse for people that use  nicotine e-cigarettes can be anywhere between 15   and 56 days, and for the group that use  the nicotine patches they believe that

the true a number of days to to  relapse is anywhere between 8 and 18   days, and for the placebo group this  was anywhere between 5 and 34 days. So hopefully after this lecture it's it will be  easier to read papers like this and interpret   findings where they talk about  confidence intervals and p-values. Thank you for listening!

Ask anything

We've read this whole study set, so questions about it get the best answers.

FlashcardsQuizFill in the blanksWritten testLessonNotesPodcastContent