biostats week 5bb part 1

IN CLASS PRACTICE 8

FREQS AND RELATIVE FREQUENCIES

chi squared goodness of fit test, which is used to test hypothesis that an observed frequency distrubution fits some claimed distribution (chi specifically may be used to test hypothesis about a SINGLE PROPORTION)

USE CELL COUNTS TO CALCULATE TEST STATISTICS

IF null is true with 100 people either way: we would expect to se 125 smokers and 87.5 nonsmokers in example, hut we would take frequency than the differencec

the bigger the x^2 gets the smaller it is for the p value which would be less than expected

biostats week 5bb part 1

Transcript

Exposure to cigarette smoke may cause changes in energy metabolism and ultimately cause reduced weight gain in the mother.

So which can then cause decreased height and weight.

Any questions about this example? All right, we're gonna, we're gonna move on to our next journey here, actually.

Before we move on to our next journey, is there any questions about the homework?

So we're gonna kind of make a big shift here with this last little unit.

What's up? Which, which one do you have a question about? Number four? Number four, how did that one kind of go? It was the one that was like talking. They're not randomized again, are they? It was like the study of the effects of exercise and it was like we are 95, 95% confident that the difference is.

And it was like listing numbers in between a specific like interval.

Okay, well, I think it's, it's like different online.

It's number eight. It's that one. Yeah. A study of the effects of exercise used rats bred to have high or low capacity for exercise.

The eight high capacity rats had a mean blood pressure looking high and a standard deviation of 9.

The nine low capacity rats had a mean blood pressure 105.

The standard deviation 13. We are 95% confident that the difference is. So what type of interval are we forming here? Performing a 2 sample t interval because we are comparing the means between, between both groups.

So what are we forming our interval around? How can we compare the mean and group one and group two?

Wouldn't it just be the mean difference? You just take the difference between them? Yeah, you take a difference between both of them in whatever direction you want to and then that's where your interval is going to be around.

Right. It's going to be positive or negative depending on which direction you do it.

But in the calculator, which one are you going to use?

Which calculator function are we going to use? Just be sample T2 interval. 2 sample T interval. Right. And which function are we going to use to enter the data?

Are we going to use stats or data data or no stats? Stats, because we're given the stats. So we're going to get our calculators out. If you haven't done this one yet, let's just make sure understand how to do this one.

So we'll go to stat test, we'll go down to 2 sample T interval.

Right. And then we'll do the stats option and we'll just enter in 89 and 9 and we'll make sure we have our N is 8.

And then we'll enter in 105 and 13. We'll have our N is 8. We'll make sure we have 0.95 as the confidence level.

Right. Then we hit calculate. And depending on how you put in the order of the groups, you might get negative numbers for these, but you still should get these numbers.

Right. So everybody do that and let's see what we get while we're on this same question.

I have a question for number seven. Okay, we'll do that after this one. It'll be along the same lines. Okay, what are we getting in the calculator for this one?

Are we getting 3.9 and 28.1 or negative 3.9, 28.1.

Does this help? Does that make more sense? Cool. All right. Any calculator issues? Okay, so number seven, Same thing, right? Same question or it's not? Same question, same example. But this one asks us to do a two sample T test. So this one also gives us the degrees of freedom. You're probably wondering why is it giving us the degrees of freedom?

Well, it does this because this question sort of angles towards people who maybe would use the table to answer this.

But you probably aren't going to use the table. So which calculator function would you use to solve this one?

You're not going to use a two sample t interval. Right. You'd use a two sample t test. Yeah. And you could do it just like you did the two sample T interval.

Right. You could do the stats option. Just have all those stats entered, two sided test.

Right. And you should get a P value that is somewhere in between 0.01 and 0.02.

The reason is expressed like this is because this question, you know, sort of made a lot of these questions on these homeworks are made to kind of cater to both the audience who did do the homework with table.

But if you do with the calculator, your P value should be in between those two.

Does this make sense? Does no. I'll ask you later. I think it's something with my calculations. Maybe you're typing something in wrong. Yeah. Is most everybody able to get a P value that lies between these two?

Any other questions about the homework before I move on?

You go for the one that has the table and it says from the two sample t tests, we conclude that it starts with a study compared individuals.

I will be happy to do it. So before we do it, I'm going to go over this and we'll get into there.

Everybody see this? All right, so this is statistical output. It Looks like, you know, someone's building a bomb or something.

It's kind of a lot to look at. We have statistics in group one, we have statistics in the control group.

We have obs which is N, essentially like the number of observations.

We have the mean in group one and group two, that's what we're going to be comparing.

Right. And then we have the difference between both means.

Right. That's our ticket there. So we can already see that the H same group has higher level than the control group.

Then we have a confidence interval around that mean.

And then we have a T test statistic that distance and direction from the null.

Then we have our degrees of freedom. And finally down here we have these 3P values that look kind of funny, right?

This one is a left sided P value, this one's a right sided P value.

And then this one is our two sided p value in the middle.

So that exclamation point with the equal sign, that's the two sided P value.

You want to use some softwares will look a little bit different, right?

They're kind of naming functions. This is how Stata does it, which that's where this question was generated in.

So going back to your question, assuming it would be this one, you have a question about.

Right. So what's going on with this P value? So how would you compare this p value to 0.05? Is it less than or greater than? So have we found a significant difference between these two means?

Yep. So individuals with HSAM have same significantly greater abilities on verbal association tests than non HSAM individuals on average.

Yeah, no problem. How we doing? Anybody else got questions? All righty. So we have spent quite a bit of time on our continuous data journey doing inference on data with continuous outcomes.

We did our 1 sample T test comparing a mean outside of study.

We did our paired data comparing those differences between pairs, assuming the null is zero.

And then finally we ended on that two sample test, you know, confidence intervals for those as well.

It was great. Hopefully everybody has caught up or is kept up with that for the most part.

Seems like everyone comes to classes on the up and up.

Now we're going to change directions here for the last couple class meetings and we're going to be back over here in the categorical world.

Right. So within our categorical data we have our nominal and ordinal.

Anybody want to remind us what the distinctions between those two are?

This is going back a few months. Nominal, ordinal, sort of all in the name here or is based off of scale and Then nominal is based off of separate categories.

Yep. So with nominal, the order doesn't matter. And then with ordinal, the order matters in some way.

And then we have that special case of nominal, which is a binary.

So that's the type of data we're going to be working with.

We're going to be doing inference on that. Fear not. The same principles apply, right? The null, the alternative confidence intervals, the null being in the confidence interval or not.

So all of those things are still going to guide us, but it's just going to be on a different type of data.

So review question here. What quantities are we concerned with when we tabulate or summarize categorical data?

What quantities are we concerned with when you summarize or tabulate categorical data?

Say it again. So the mean. Where. When we summarize continuous data, we want to describe the center.

Right. So we take the mean. Right. But let's say we count how many people in this class are going home for Thanksgiving break.

Actually, that's a bad one. We count how many people who are in different class levels.

Close. So let's. All right, so everybody in this class has a freshman, sophomore, juniors.

Right. What if we counted all those up and we had a count of freshmen, sophomore, juniors and seniors?

What do we call those counts? What would be a better way to summarize freshman, sophomore, junior and senior relative to.

Just counts. Frequencies and relative frequencies. Yeah, you got it. So we have our frequencies and relative frequencies.

That's how we summarize our categorical data, our continuous data.

We summarize it for means and standard deviations.

You're right on that. That is a way we can summarize data. But for. For categorical data, we want to describe it differently because it is different in nature.

Either it falls into a category or it does not. We can't take the mean of a categorical data type.

So with this, our same overall inference principles will apply.

But for categorical data, we're going to need to use a different distribution because the data is so different.

Right. So we're going to use this example to kind of guide us through here.

So let's say we ran a study and we collected data on 100 people.

So imagine this goes all the way through 100. And let's say, like our study, we went out to Ogleforth county And we found 100 people and we surveyed them and we said, do you smoke cigarettes?

Yes or no? Not the most interesting study, but hang with me here.

And we tabulated the data. Right. We have smokers and non smokers and we have a frequency and a proportion.

So let's say we get 50 smokers and 50 non smokers in this population and the proportion then would just be 0.5 and 0.5.

Right. I realize this is very, very high proportion of smokers and I'm not trying to call Oglethorpe counting.

This is just a weird example I just threw out. So, bringing in some extra information, let's say we know that in the U.S.

the known proportion of adult smokers is 12.5%. Right. But our random sample here. Right. Our frequencies and relative frequencies show a much higher proportion.

Right. So how can we test if this is due to chance? So this brings us to, and we're going to come back to that example in a minute, but this brings us to a chi square goodness of fit test.

Goodness of fit test is used to test the hypotheses that observe frequency distribution fits or conforms to some claimed distribution.

So in this example we're going to look at the distribution.

Right? The proportions in our study conform to this one and how different they are with P values and test statistics, just like we did before.

So the chi squared test for goodness of fit may be used to test hypotheses about a single proportion.

So the chi square is the distribution we're going to use.

And I like to think of this chi square goodness of fit test, it's sort of like the categorical version of the 1 sample T test.

Recall what was the null in a one sample t test. It was just that outside the study that we were comparing it to.

So with a chi square goodness of fit test, we're taking the proportion, portion frequency proportion in our study, the distribution, and we're saying, hey, how different is it?

Or is it different than the expected proportions outside the study?

So chi square distribution is going to be a bit different than the T distribution.

It's not symmetric, it's always skewed to the right.

There's a different chi squared distribution for each possible value of the degrees of freedom.

So we haven't gotten rid of degrees of freedom yet.

Sorry. Degrees of freedom is a very simple calculation.

In this world though, degrees of freedom is going to be K minus 1.

K is just the number of levels of the outcome. So like in this example we have smoker, non smoker.

So what would the degrees of Freedom be? K minus 1, K is the number of levels in the outcome.

Would it be 49 or 99? So we have a categorical variable. Smoking has two levels, yes or no. So one it should be one, K would be two because we have two levels.

Oh, it's not basic. Okay, it's. And just like with the T distributions and the Z, the total area under the curve is going to be equal to one.

So this is what it looks like. It looks funny. It doesn't look, it's not nice and symmetrical like the T distributions.

But just like with the T distributions, we're going to be calculating test statistics, right distances and directions from the null and then probabilities, right areas under the curve that say, hey, under the null, what's the probability?

We would see this result for something more extreme.

If the probability is very small, gives us the evidence to reject the null.

So here are the steps. First, we want to verify that the requirements are satisfied.

To carry out the test, we want a simple random sample.

We want the conditions for a binomial distribution to be satisfied.

Those conditions include that N times P is greater than 10.

Anybody remember what N and P are? So N is the total number of trials or the total sample size.

And P is that probability of success on any one trial.

This should hopefully be reminding you all of our old friend the binomial distribution.

And then n times 1 minus p, we want that to be greater than 10 as well.

I wouldn't stress too much about that for this class.

I'm not going to just give you stuff where the things aren't satisfied.

Then we have the null and alternative. So the null is always going to be that the proportion equals that expected or known proportion.

Right? It's going to be that our data can form to that proportion from outside the study.

And then the alternative would just be that it doesn't.

Right? Just like with the T distributions, we want to specify a significance level.

We love that. 0.05. And just like with the T distributions, we want to calculate a test statistic, right?

What does the test statistic tell us? Distance and direction from the null. That's like one of our bits of evidence. And then we calculate the P value and state our conclusions.

Notice here, the test statistic looks sort of insane, right?

What we're actually going to do is we're going to calculate the observed, what we actually observed in the data and we're going to subtract that.

What we would subtract from that, what we would expect to see if the over true.

We're going to square that, put that over the expected.

We're going to add that up for each cell. If that didn't make any sense, which it probably didn't, I'm going to show you how to do that in great detail.

And then once again we have that K minus 1 degrees of freedom.

So if we're going to use the table, we have to make that degrees of freedom calculation.

We get a P value. Once again, P value is less than alpha, we reject.

P value is greater than alpha, we fail to reject. So let's go back to our example. In the US the known proportion of smokers is 12.5%.

Our random sample had 1,200, had 50. How can we test if this difference is due to chance?

We're going to do this if the alpha equals 0.05 level.

So what would our null and alternative be here? So remember this chi square test, this goodness of fit test is sort of like the 1 sample T test in that we take our sample data and we're comparing it to some like known thing outside of the step, right?

We see how different it is and if it's significantly different it can give us the evidence to reject.

So what would our null be here as a hint? It would be one of these proportions that's out there and it's not going to be the proportion from our study, it's going to be the one that lives outside the study.

Exactly. Yeah. So the null would be that the proportion equals 0.125 or 12.5%.

And then alternative would be that it doesn't. Right. We're going to use our data to test against that. Everybody see that? Does that make sense? So this is where it gets a little intense here. But to calculate the test of the distance and direction from the mole in this world, we actually use cell counts, right?

So recall before we had our cell counts we had like a little table from this data we tabulated at the frequency of cell.