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

Discrete Data Settings

In this module, we'll discuss testing in discrete data settings. This includes the famous Fisher's exact test, as well as the many forms of tests for contingency table data. You'll learn the famous observed minus expected squared over the expected formula, that is broadly applicable.

- Brian Caffo, PhDProfessor, Biostatistics

Bloomberg School of Public Health

So consider this next example, where I, you know?

Â I took this modified it a little bit

Â from Agresti's wonderful Book on categorical data analysis.

Â so here we're looking at birth weight cross

Â [UNKNOWN]

Â classified by babies' birth weights cross classified by maternal age.

Â And so let's assume that this, the way in which it was sampled as they were, say,

Â 400 people sampled, so that by design, na, neither of the two margins were fixed.

Â And we're kind of interested, then, in treating the

Â cell counts as if they were multinomial Four dimensional,

Â multinomial count with N equal to 400 total

Â total observations.

Â And then what we would like to know is if the variable birth weight is independent

Â of, of maternal age, versus the variable birth weight is not independent.

Â So let's think about the problem this way.

Â And see, we had logic our way to the expected cell counts.

Â Okay.

Â [SOUND]

Â Okay, so let's let's first note

Â that, under the not necessarily,

Â even just under the null hypothesis.

Â Just regardless our estimate of young maternal age is always going to be

Â 100 over 400, and older maternal age will be 300 over 400.

Â The margins of the table where we disregarded birth weight.

Â Do the same thing for birth weight, disregarding maternal age would be 50

Â over 400 and then normal birth weight would be what, 350 over 400.

Â Okay?

Â And the cell probabilities would then give you the specific, you know, combined

Â probabilities, if we want to talk about

Â younger, maternal age and lower birth weight.

Â That would be this the our estimate of this regardless of the hypothesis.

Â or under the alternative hypothesis, would be 20 over 400.

Â But if we're under the null hypothesis, we're assuming

Â maternal birth weight in maternal age and, and birth

Â weight are independent, then we kind of logically construct

Â this probability as the multiple of these two marginal

Â probabilities, because we're probably estimating the margins a little better.

Â So that would be 0.25 times 0.125.

Â Here because we're, we're multiplying the marginal probability of young maternal age

Â times the marginal probability of low birth weight.

Â Okay?

Â So that only, we can only do that under the null hypothesis.

Â So let's,

Â let's work on our expected counts.

Â So our expected counts for the 1,1 cell of low birth weight and young maternal age is

Â this probability, then the number of counts we would

Â expect in there is times the 400 sample size.

Â And we get 12.5 as our expected count.

Â So then you can follow through for all of

Â the other three remaining cells in the same way.

Â [UNKNOWN]

Â get the expected counts.

Â And then compare them using the same

Â formula, observed minus expected squared over expected.

Â And we get our qchi squared statistic, which in this case is 6.86.

Â We then compare it to a qchi squared critical value which is around four.

Â Of course we, we talked about it being you know, the square of the Z statistic.

Â So if that makes sense, that it would be around four.

Â and or we could just calculate our Chi-squared P value, which would be the

Â probability of, of, of getting a test statistic as large as 6.86 or larger.

Â So I hope everyone can follow these calculations.

Â And the idea is that we're basically calculating

Â how distance are observed counts are from kind

Â of our best estimate of what we would

Â expect the counts to be under the hypotheses

Â under the nod potheses of independence, between the row and column variables.

Â I, I should also add before I complete this slide, that the answer we get from

Â this test of independence, is identical to the

Â answer we get from the test of proportions.

Â You get the same chi squared value, the same P value.

Â now the interpretation might be very different as we talked about before, if in

Â one case there was randomization as to which of the rows you like and forces.

Â In thins case if it was a multinomial sample,

Â the, the interpretation results dramatically

Â different and we don't really.

Â cover you know, a lot of things

Â like epidemiological style sampling designs in this

Â class, but you know, suffice it to say, the interpretations can be very different.

Â But nonetheless, the actual number, the P

Â value we see, is identical depending on either,

Â identical regardless of which of the sets of assumptions you see, you make.

Â So that's interesting, and what's even more interesting is that you

Â can formulate Poisson models that then again yield the same conclusions.

Â So here's another example of Agresti's Categorical Analysis book.

Â here's, which, which is a book I highly recommend.

Â And I, I, I think it's, it's, it's a real classic in the area.

Â but, you know, but I should disclose a conflict of interest

Â that Agresti is a great friend and close colleague of mine.

Â [COUGH]

Â any way, so in this example he is looking at, at

Â different collection of o, occupations and

Â looking, cross-classifying it by alcohol use.

Â And suppose the investigators in this trial, or in

Â this study, you know, went out and found 300 Clergy,

Â 250 Educators, 300 Executives, and 350 Retailers, and then

Â you know, asked them a question about their alcohol use.

Â And we'd

Â like to know whether alcohol use differs by occupation.

Â So

Â interest then lies in whether or not in testing whether or not the proportion

Â of high alcohol use is the same in the, in, in the four occupations.

Â so if we label P1, you know, the clergy, the

Â proportion of high alcohol use among the clergy, and so on.

Â We want to test whether they are all equal, but we don't want to specify

Â what proportion it is, so let's say

Â P is the common proportion across all occupations.

Â And then the alternative would be the opposite

Â of that, that at least two are unequal.

Â so our estimate of P this common unknown proportion the

Â obvious estimate of it would be 233 over 1200 and the obvious then well then of

Â course the estimate of 1 minus P would be 967 over 12 1200.

Â So what would?

Â So our observed first count is 32 what would be our expected first count.

Â Well yeah, our com, our estimate, if you, if, under the no hypothesis.

Â Where occupation is irrelevant, we expect about, you know 233

Â over 1200% to be high alcohol users.

Â So we multiply that times the, row count, 300.

Â And we would get the observed cell count.

Â then the, the low alcohol usage, 268, well, you know?

Â They, they have to, you know.

Â These have to add up to the margins, by the way,

Â that the ex, the both the observed and the expected counts

Â have to add up to the margins. So you could, you know take 300 minus

Â the the 1, 1 cell count, to get it.

Â But otherwise, you could just say 300 times the probability of low alcohol

Â usage, which is then 1 minus 233 over 1200, or 967 over 1200.

Â And you would repeat that down and down for for each occupation.

Â Calculate our Chi-squared statistic, observed minus expected

Â squared over expected. The sum of all of them, you get 20 20.6.

Â And we need to compare it to a Chi-squared critical value.

Â But the degrees of freedom change.

Â And it turns out that the general rule

Â of the degrees of freedom for the Chi-squared.

Â In these settings is rows minus 1 times columns minus 1.

Â So in this case there's one, two, three, four rows and two columns.

Â So the degrees of freedom is three.

Â So then here's our P value, P chi squared,

Â 20.59, 3 degrees of freedom, lower tail equals false.

Â It's about zero.

Â It's pretty clear that some of them are different.

Â [SOUND]

Â Okay, here's, here's

Â another example. And we're going to, we're going to do.

Â so this is from Rice's book Mathematical Statistics and Data Analysis.

Â Which is another, first of all, I have no affiliation and

Â have never met Rice, so it's easier for me to say this.

Â But I, I love this book, I

Â think it's wonderful, this Mathematical Statistics and

Â Data Analysis book.

Â So, if you're looking for a book recommendation, I like that one

Â [SOUND].

Â in addition, I really like Agresi's book, but I'm

Â willing to stipulate my conflict of interest in recommending it.

Â but I do really like it.

Â I read it all the time.

Â so anyway in this book does, he has this interesting example,

Â where a bunch of word, words taken from some novels that were

Â [UNKNOWN]

Â one of them was preparat, w, well two of them were known to be Jane Austen novels.

Â And one of them was, was in question as to

Â whether or not it was from written by that author.

Â Let's say they found it later. And

Â there's maybe other ways you would want to analyze this data for this reason,

Â but, you know, we want to use it as an example for the chi squared.

Â So don't think too hard about specifically how you would analyze this data.

Â Because I, I doubt this would be what you would arrive at immediately.

Â But it, it's not unsensible, by the way. It, it's reasonable.

Â so

Â so imagine, let's say, book three, I'm

Â just spit balling here, the magic book three

Â is this book where you don't know whether or not it's from the same author.

Â In this case it was Jane Austen.

Â and you want to test whether, you know, the word

Â distribution of these words, is equivalent across the three books.

Â And you sampled so many words from each of the books.

Â Okay?

Â So that's the setting and let's see if we can

Â figure out some, some expected cell counts to do a

Â [UNKNOWN].

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