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

all right so what I want to start off with  today is doing a simulation again to help   us understand the content the content  we want to understand using simulation is the idea of a confidence interval to start off  with today and hopefully we'll also understand   hypothesis testing we will introduce hypothesis  testing today so let's start simple let's again   assume we're in a situation where the  population standard deviation is known so we're going to do a in general 100 times  1 minus Alpha percent confidence interval CI to estimate something to estimate a population mean new

most commonly the percentage people use is 95  percent that's the most common percent to use   it's not like you have to use 95 it's just the  most common thing people use people are kind of   stuck on it you should be able to deal with  99 or 90 or even 98.7 percent theoretically if this is 95 that means 1 minus Alpha is 0.95 and so Alpha itself is 0.05 Alpha is called the  level of significance the the entire thing here is   called the confidence level confidence level and  Alpha itself is called the level of significance Alpha itself has more meaning  in the context of hypothesis   testing which again we're going to start  talking about hypothesis testing today

as you know what does a level  of significance really represent we're trying to estimate a population  mean mu and the simplest case is going   to is to go ahead and assume  assuming that the population   standard deviation Sigma and therefore  also the variance Sigma squared is known okay it's just a simpler calculation  in that setting because we don't have   to worry about the T distribution it's  not really realistic in most real life   applications because in real life applications  if you don't know mu why would you know Sigma right in most in most real life applications you  wouldn't know either one but to keep things simple

we go ahead and at first assume we know Sigma   and the formula written with capital  x bar instead of lowercase x bar is really a formula involving random samples a  statistic that is a random variable it's got a   distribution X bar is a point estimator  right our favorite Point estimator it's a statistic it can be computed  from a random sample but a random sample in the abstract is just a list of random variables  and random variables with the same distribution and so this has got a distribution as  well that's important it's sometimes   called a sampling distribution I  haven't really emphasized that as   much as I should have it's often  called a sampling distribution it's a point estimator it's unbiased right

expected value of x bar is Mu the mean of  the mean is the mean that's a big big deal okay fundamental thing to know a lot of statistics  but we want to widen it to an interval estimator call the confidence interval  we need a margin of error Dr Wetzel usually calls it capital E for  error some books call it m for margin   of error or maybe m-e-m-o-e for margin  of error MO okay it doesn't matter I wrote it as a capital either as if it's  a random variable and that is the case in   the case where Sigma is not known and you have  to use S the pop the sample standard deviation   but when we know Sigma it's actually not a random  variable maybe I should have used a lowercase e

the formula for that margin of error is z sub  Alpha over 2 times Sigma over square root of n Sigma over square root of n by the way is the standard deviation of X bar  you could call that Sigma sub X bar root of the variance of X bar you  might remember I hope you remember   back in chapter seven we had a formula for the  variance of X bar to be Sigma squared over n   and we're taking the square root of that we've got a name it's sometimes  called the standard error standard error actually the name standard  error is inconsistently applied sometimes

um here the standard error I'm I'm using  this name to represent the standard   deviation of X bar meaning standard  deviation of its sampling distribution however the word standard error sometimes applies  even when you use S instead of Sigma even when you   use a statistic here instead of a parameter you  get the distinction Sigma is a parameter it's   a fixed but unknown perhaps unknown number we're  pretending we know it now N is a fixed sample size   this is a number if I use an S there instead of a  sigma a capital essay then it becomes a statistic and it's just an estimator for this thing

as usual when the subscript there is for  the Z that subscript represents the area   to the right of that Z value if this is a  standard normal distribution right here n01 then Z sub Alpha over 2 is the number along the  axis so that the area under the curve to the right   of that number is Alpha over 2. that's shaded area  is Alpha over two so again in the most common case   where Alpha is .05 if Alpha is .05 that means  Alpha over 2 is .025 and Z sub point zero two   five is a number you should probably remember  until the day you die is 1.96 approximately right if you do statistics every day you  should remember that for the rest of your life

confirmation go to the distribution menu  on your calculator go to in the norm area 0.975 that's a CDF value and area to the  left if I want the area to the right to be 0.025 1.96 very close but if you had some other value of  alpha then you'd get a different number let's try to understand this via simulation now let's say we're simulating  from a uniform distribution or simulate sampling from a uniform Distribution on the  interval from 0 to 10 like we did before

with this we'll go ahead and use  a spreadsheet to keep it simple if we assume the spreadsheet's  random number generator is good then we're essentially pretending we know the   exact mean and the exact  standard deviation in fact mu would be 5 right halfway between the endpoints what's the variance Sigma  squared look in the table for uniform distribution it's  B minus a squared over 12.   you could confirm that by integration and the  12 seems kind of mysterious why is it a 12.

that's just the way it turns out  you can confirm it by integration so in this case that's going to  be 10 squared over 12 100 over 12. which you could also reduce if you liked  25 thirds oh that be 8.3 repeating and then   the standard deviation is going to be the square  root of that which will be a little less than 3. oops 25 over 3 up 8.3 repeating  take the square root of that   about 2.887 let's round it to that 2.887 . so we're pretending we know  effectively what Sigma is here what do I want to do to do the  simulation to help us understand this

I'm going to use Rand on the spreadsheet to  get random samples from this distribution samples a certain size and what should I use for  N I could use anything I want let's make it not   be too big so I'm not copying and pasting way  down the spreadsheet maybe n is 10 or something and we'll see we'll compute this interval  and see if it captures the true mean or net let's do a 95 interval if I do that the idea is it  should capture the true mean about 95 of the time let's see if that holds it's probably going to be easier actually this in  this case if I do the random sampling across the rows instead of columns because  I'm going to want to calculate   the X bars and the confidence  intervals and be able to go down

various rows to see whether they capture you  or not so 10 times Rand is what I can use epic enough you guys in back okay and don't be bothered by the fact  that the numbers change all the time random samples of size 10 say n is 10 a b  c d a b c d e f g h i j go to column J here I memorized that e is the fifth letter in  the alphabet but I haven't memorized that   J is the tenth I should do that for my own okay there's a random sample of size  10 from the u010 distribution what's the mean

again it changes all the time that time it's  5.76 that's a that's a point estimate that's   an observed value of the point estimate or it's  a little X bar an observed value of capital x bar and we can do that over and over again  let's do so it's a random sample of size   10 but let's do this sampling oh a hundred  times so I got a hundred samples of size 10.

here we go those are the point estimates let's  widen these to interval estimates a left end point and a right end point okay observe value and I use the  actual observed value of x bar minus 1.96 I'm doing a 95 confidence  interval here times Sigma was the   square root of 8.3 repeating that was the  2.887 divided by square root of n n is 10.

that'll be the left endpoint the right endpoint will be something  similar except the plus sign right Sigma again is about 2.887 divide by square root of 10 .   okay this this particular interval 3.67  to 7.25 is capturing the true mean five it is centered at 5.46 can I calculate I hope uh wait a minute  that doesn't look right what did I do wrong uh uh

or is it right maybe okay I'm just double checking  the margin of Errors the same on either side so   7.25 minus 7.25 minus uh 5.46 is what I'm doing in  my calculator right now gives 1.79 and 5.46 minus   3.67 is also 1.79 okay margin of error  for this particular one is 1.79 in fact because Sigma I'm pretending is known to be 2.887 the margin of error here is not going to change  but X bar does change so the interval changes if we don't know Sigma though and we got to  use S then the margin of error can even change copy and paste these down

synthesis these are 95 confidence  intervals about 95 percent of them   should contain five and five percent  will not there is one that does not maybe there's a fancy way to use countif  to count the number that do not but uh   I'm not quite sure how let's see if  I can just visually do it there's one I'm probably going too fast there's a second one you got to look at both columns  that's the hard part here oh almost there but not quite oops ah I don't know what happened  there there's a third one

oh sorry my scrolling is not doing so hot here so  we're up to three of them that do not contain five uh I think oh there's a fourth one just barely there's a fifth one right there is going to be exactly five not necessarily  right because they're simulation randomness there is a sixth one so it looks like 94 of them  contain five in this case and six percent if not it's all approximations  right because of randomness that's the idea behind the confidence  level when you do the simulation 95 percent

approximately will contain mu can the 95 be  interpreted as a probability um yes and no you could interpret the 95 confidence   level as a probability if you are  thinking about it before the fact   I am about to do some random sampling and compute  a confidence interval and I would like to be a 95   consequence interval and I'm wondering before the  fact what are the chances that it will contain you if you're doing a 95 confidence interval  you would say the probability is 0.95 but when you actually do the interval when you  gather the sample and compute it get an interval and you look at that interval and say what  are the chances that that mu is in there you can't really assign a probability to that

I mean if somebody knows Mew and you  want to talk about betting odds I mean   effectively you could sort of think of it as a  probability but once you've done the sampling   all the randomness is gone probability  is about Randomness before the fact so we usually avoid thinking of the  confidence levels of probability we interpret it as well a level of confidence  I'm 95 confident in this interval I'm pretty sure but since we're always thinking about it after   the fact we don't typically  think of it as a probability

but if you do simulation if you imagine doing  random sampling from the same population with   the same sample size over and over and over again  you could say about 95 of the intervals will   contain you and and five percent will not but you  never know which ones do and which ones don't yeah   right I'm I'm pretending I know the population  here I'm assuming this is an accurate simulator with Rand I'm pretending I know the true mean is five   is it really random though is  the spreadsheet really random that's not what you mean some people call  technology things like this on spreadsheets   pseudo random is technically speaking  they they are generating their numbers   by non-random processes and if you want to be  technical about it but it simulates randomness and so you can never quite be sure that it's   quote unquote perfect or even  necessarily close to perfect

it's usually good enough though if it's  pretty good and I guess we trust it   basically can I clarify anything there what if we had used the sample  standard deviation in each case 100 times 1 minus Alpha percent  confidence interval to estimate mu sometimes you just say form you  but in reality it's to estimate you   when you're in the more realistic  situation where Sigma is unknown

then the formula is X bar cat notices Capital plus   or minus t sub Alpha over 2 times capital  S over square root of n that's capital s both the point estimator in the center of the  interval and the margin of error are random   variables statistics that can be computed from a  random sample and therefore are random variables   X bar has a distribution by the central limit  theorem it's approximately normal even if your   population is not normal as long as n is large  enough s has a distribution is s's distribution   normal can't be exactly normal because s can't be  negative could it be approximately normal Maybe n is large enough again is there a central limit  theorem for S we won't get into that at the moment

where you compute the T value based on a certain  number of degrees of freedom which you know   sometimes we call Little gamma sometimes I call  it DF for degrees of freedom it's n minus 1. that's the degrees of freedom this degrees  of freedom always n minus 1 in statistics   no it's not some people think it is  because that's the most common thing to use in statistics degrees of  freedom is not always n minus 1.

chapter 10 we'll see examples where it's  not chapter 11 we'll see examples which not second most common thing to use is n  minus two it depends on the situation okay there are situations where it's n  minus three or n minus 4 or n minus   5 or in chapter 10 actually something even more  complicated something that involves the most uh unpleasant formula and statistics called the  Smith satirth rate formula that I I've hardly   ever computed by hand because it's just it's  almost impossible to use without making a mistake you can look it up Smith's shatter three formula

DF is not always n minus one but in this context  it is n minus one sample size minus one use a t   distribution with n minus 1 degrees of freedom a  t distribution has a PDF a density that looks like   a normal distribution it's bell-shaped looks  like a standard normal it's centered at zero however it's not a normal distribution  the formula for its PDF is different you know a normal distribution the PDF  formula involves e to a power looking in   chapter seven and fixing the typos you  see a t distribution does not involve e I could call that a capital T sub n minus one distribution what's different about  it how compared to our normal it's a   bit more besides having a different  formula it's a bit more spread out

it's mean as zero but it's standard deviation  is bigger than one it's not standard normal and it's got heavier tails than a normal  distribution does if you graphed a normal   distribution on the same scale the standard normal  distribution it would be a little taller and less   spread out this would be a maybe a standard  normal distribution in the same picture here however as n gets larger the black and the red curves get closer and closer  together as the degrees of freedom gets larger the black curve looks more and more  like a normal curve you could say in   the limit as n goes to Infinity they  they merge they approach each other

so when that is large you can kind of  get away with using a normal distribution   if you really wanted to and it would be a  pro give you approximately the same answer so again let's let's use the calculator to find  T sub Alpha over 2 for example if Alpha is 0.05 so Alpha over 2 is 0.025 and we're after  Little T sub .025 related to our simulation n   is 10 for our simulation so if we use degrees  of freedom to be 9 what will we get here need n for t

an area of 0.975 degrees of freedom  is 9. should be a bit bigger than 1.96 2.262 so I'm about to use this formula here on  the spreadsheet with that value of T 2.262   but remember s is still a random variable the  different samples of size 10 will have different   observed values of s now they could call Little  F's in each case so again not only is the point   estimate going to be a random variable but  the margin of error is going to be a random   variable in this case I'm more justified  in calling this entire thing a capital e of course you'd want to use  avoid using lowercase e anyway   because that might make people think  it's the number e which is not in

the table in the back of the book for the T distribution if you wanted  to use that to find the T value here T distribution table where is it  okay here it is it's table five no that standard normal excuse me Table Six  starts on page 699 goes over a couple pages there's gamma that's the degrees of  freedom go to nine degrees of freedom   these numbers are areas to the  left instead of areas to the right so Alpha is .05 so that Alpha is over 2  is .025 means we use 0.975 there's 2.262 sorry

so let's use that now in the spreadsheet we're still using the observed  values of X bar from column l of course the numbers are going to  change again so now I subtract 2.262 times not the 2.887 anymore right that was Sigma but instead The observed value of the standard  deviation the stdev don't put a p on it leave the P off still divide by square root of 10.

notice for this particular sample here that I I  haven't entered this yet where the mean was 5.4776 the left endpoint when we use Sigma was 2.887  is 3.688 but this left endpoint is 3.486 lower because the margin of error is bigger here because   2.262 is bigger than 1.96 that's  probably the main reason it's lower   the standard deviation could be smaller than  2.887 I'm not figuring it out here I guess explicitly I'm not showing it anywhere actually maybe it would be good to see  the standard deviation in each case a separate column here the different samples are going to  give you different standard deviations

their sample standard deviations their estimators  for 2.887 observe estimates I should say although remember s is not unbiased for Sigma  right s squared is unbiased for Sigma squared   s itself the standard deviation sample standard  deviation is not unbiased for Sigma the population   standard deviation unfortunately but  uh I guess we don't worry about it again T is two point two six two I'm just going to  use S from column P divide by square root of 10.

huh okay there I got there I'm getting a  bigger number 3.73 than 3.64 . even though   2.262 is bigger than 1.96 I guess well yeah  this s is less than 2.887 significantly enough   to make this left endpoint not smaller than  this one I think usually it will be smaller and in this case it's smaller once I  entered it things changed smaller than that 2.262 there's my value of s divided by square  root of 10. again things will change again so again column p is the S values based on those S  values we get a left endpoint and a right endpoint

somebody email me right now remind me  to actually share this file with you I   don't want to go ahead and count how many of  these contain or don't contain five anymore somebody could email me right now I don't  know why it's dividing by zero there so did I oh thank you yeah so used to going down columns  instead of across rows Okay so it should be the case that around five  percent of these intervals do not contain five about 95 of them should I'm not going to go ahead and count them this time

Ask anything

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

FlashcardsQuizFill in the blanksWritten testLessonNotesPodcastContent