A practical and example filled tour of simple and multiple regression techniques (linear, logistic, and Cox PH) for estimation, adjustment and prediction.

Loading...

From the course by Johns Hopkins University

Statistical Reasoning for Public Health 2: Regression Methods

75 ratings

A practical and example filled tour of simple and multiple regression techniques (linear, logistic, and Cox PH) for estimation, adjustment and prediction.

From the lesson

Introduction and Module 1A: Simple Regression Methods

In this module, a unified structure for simple regression models will be presented, followed by detailed treatises and examples of both simple linear and logistic models.

- John McGready, PhD, MSAssociate Scientist, Biostatistics

Bloomberg School of Public Health

All right, welcome back.

Â Now we're going to get into some totally new territory, and

Â we're not going to replicate the results of analyses we

Â did in Statistical Reasoning 1 using simple linear regression.

Â We're going to expand our toolbox now to allow our predictor of interest to go

Â beyond binary or categorical and actually respect it as a continuous measure.

Â So hopefully by the end of this lecture set, you'll understand why treating

Â a continuous predictor as continuous instead of dichitomizing it and making it

Â binary or putting it into several categories can actually be beneficial.

Â Youâ€™ll be able to use the scatter plot display to assess whether

Â an outcome predictor relationship is reasonably described by a line.

Â And youâ€™ll be able to interpret the estimated slope and

Â intercept scientifically from a simply linear regression model with

Â a continuous predictor x1.

Â So let's start with an example.

Â Our arm circumference data.

Â But this time we'll look at the association between arm circumference and

Â a child's height.

Â So this is the same data set we did in the last section,

Â where we looked at arm circumference as a function of child sex, but

Â here we're going to consider it as a function of child height.

Â So, the question we might have is,

Â what is the relationship between average arm circumference and height?

Â Can we quantify this so

Â that we can compare it to relationships in, between arm circumference and

Â height in children less than a year old from other populations?

Â So, again we have the arm circumference data,

Â we laid that out in the last section.

Â And then the height data is such that the mean for the 150 children less than a year

Â old is 61.6 centimeters with a standard deviation of 6.3, and it ranges because

Â there's a range of ages here between 40.9 centimeters and 73.3 centimeters.

Â So some of that's because of the age difference, and

Â some of that's because of individual variability between of several ages.

Â So how can we handle this?

Â Well up till now, this will require us to categorize our predictor of height.

Â So one crude way to categorize this is to actually categorize at the median, and

Â compare the mean arm circumference with a t-test between the group with greater than

Â median height and a group less than median height, and

Â we could also put a confidence interval in that.

Â We can also visually display this, and here's a box plot showing the arm

Â circumference distributions for the two height groups.

Â And I think it's pretty clear from this presentation that

Â arm circumference shifts up the distribution shifts up for

Â the taller group, relative to the shorter group.

Â And the potential advantages of doing it this way, well, we know how to do it.

Â We know how create a mean difference between two groups, do

Â a two sample t-test to get a p value, and this gives us a single summary measure,

Â the sample mean difference for quantifying the arm circumference-height association.

Â But there are some potential disadvantages if this throws away a lot of

Â information in the height data that was originally measured as continuous.

Â This only, we've only, we've taken things that were measured on a continuous

Â scale and put them into two crudely defined, very heterogeneous categories,

Â the height category below the mean, or above the mean.

Â And there'd be a lot of variation in the heights of each of those two

Â categories because we're taking something measured on a continuum and

Â putting it into two groups.

Â So you might say well,

Â we learned how to compare means between more than two groups.

Â Why don't we make our categorization for height less crude?

Â Maybe we'll make four categories and we'll do it arbitrarily by the quartiles.

Â So we'd roughly have a quarter of the data set,

Â 25% of the observations in each of the height groups.

Â And then we could compare mean arm circumference with analysis of variance,

Â if we wanted to test for differences and 95% confidence intervals for

Â the mean differences between the different height quartile groups,

Â that mean difference in arm circumference.

Â So what are the potential advantages?

Â Well, it's always an advantage that we know how to do it.

Â This improves, perhaps a little bit, on our previous approach where we,

Â we were making height binary and crudely putting it into two categories, this, this

Â categorization of four groups is a little less crude than that previous approach.

Â But this still throws away a lot of information in the height data that

Â was originally measured, is continuous.

Â This will also require multiple summary measures,

Â six sample mean differences between each unique combination of height categories,

Â to quantify the arm circumference/height relationship.

Â And most importantly,

Â this does not exploit the structure we see in the previous set of box plots.

Â The fact that as height increases so does arm circumference.

Â So let's take a look at this again.

Â I think it's pretty clear visually that, that these two track pretty

Â closely as height goes up, as evidenced by increase in these ordered quartiles.

Â The arms circumference distribution shift upwards by somewhat similar amounts if

Â you're comparing, for example, the medians between them.

Â If we create these four different height groups and treat them

Â each as their own entity, each of these groups will only have about a quarter of

Â 150 observations, so we'll have somewhere 37 and 38 children in each of the groups.

Â And we'll estimate means for each, mean arm circumference for

Â each, for the four groups each based on only 37 to 38 children.

Â And our precision will be affected by that smaller sample size.

Â When we view this and

Â estimate separate means, arm circumferences for each height group,

Â we are not recognizing the structure in this data, which actually might buy us

Â something in terms of how precisely we can estimate this relationship.

Â So what about treating height as continuous when

Â estimating the arm circumference/height relationship?

Â Well as we sort of alluded to in the first section of this lecture set,

Â linear regression is a potential option.

Â It allows us to associate a continuous outcome

Â with a continuous predictor via a line.

Â And what the line will do is estimate the mean value of our outcome for

Â each continuous value of height or predictor in the sample used.

Â So in other words, we'll be able to eat estimate height,

Â specific mean estimates of arm circumference using height as continuous.

Â This idea makes a lot of sense, but

Â only if a line reasonably describes the outcome/predictor relationship.

Â Now, we get some tentative evidence that suggests that's reasonable.

Â But let's look at a more detailed graphic to try and assess this.

Â So what I'm showing here is a scatter plot, and this is a lot more

Â informative than when our predictor was binary, I think you'll agree.

Â But what I have on this picture here are 150 points,

Â each representing one of the children, and then for

Â each child what's plotted on the vertical access is his or her arm circumference.

Â And it's plotted against his or

Â her height value measured on a continuum in centimeters.

Â And certainly there's some subjectivity in interpreting the association via

Â a graphic, and the longer the look at it the more you can see in the picture.

Â But I'm going to suggest that at least start a line is a reasonable descriptor of

Â the relationship between the average arm circumference and height in these data.

Â And I will proceed to estimate such a line using the computer and

Â present the results to you.

Â So what we can do is estimate a line using the computer, and the line will be of

Â the form y hat or the mean, is the stand in for the mean arm circumference

Â we estimate as a linear function of height measured in centimeters.

Â So, what hi, y-hat estimates is the average arm circumference for

Â a group of children all of the same height, x1.

Â So let me show you what we get when we run this on a computer.

Â We get an estimated equation that says based on these 150 observations we

Â estimate the mean arm circumference, as a function of height to

Â be such that you take 2.7 and multiply the height for the group you're looking at

Â by 0.16 to get the estimated average arm circumference for that group.

Â So our slope here is 0.16,

Â it's positive which corresponds to the relationship we saw on the scatter plot.

Â These are just estimates of the true relationship between height and

Â arm circumference in Nepali children less than a year old based on this sample.

Â So here's a picture or a scatter plot with the regression line superimposed.

Â So I plotted that line that the computer estimated on top of these data and you see

Â it cuts down the middle of the line so that, at any given height, if there's

Â a couple points, some values are above the estimated mean by the line some are below.

Â So there's variation in arm circumference around the estimated mean.

Â But the mean appears to increase with increased height.

Â So for example if we were looking at this line and wanted to estimate the mean arm

Â circumference for children 60 centimeters in height, well we have this equation.

Â We know their height value, the group of children we're looking at is 60.

Â So if we actually plugged 60 into this equation, what we get is an estimated

Â mean arm circumference of 12.3 centimeters for children who are 60 centimeters tall.

Â So in other words, if we looked at 60 on the x axis, the height axis,

Â went up this line, this value on the line is 12.3 centimeters.

Â Notice if you actually look at a thin band around that,

Â most of the points of individual children's arm circumferences at or

Â around 60 centimeters of height do not fall directly on the line.

Â What we're estimating at this point in the line is the mean arm circumferences for

Â children 60 centimeters tall, but the individual arm circumferences for

Â children for 60 centimeters tall will vary about this mean.

Â So you can see some of that variation in these points.

Â The few observations we have at 60 centimeters vary about that mean of 12.3.

Â So how can we interpret the results here?

Â How can we interpret the estimated slope?

Â Well the estimated slope is positive and it's 0.16.

Â What units is it in?

Â Well, arm circumference is in centimeters, and height is in centimeters.

Â So this is 0.16 centimeters in

Â arm circumference per one centimeter in height.

Â So what this slope estimates generically is the average change in

Â arm circumference for a one centimeter increase in height.

Â Or another way to think about this is in our mean difference formulation that

Â beta one hat estimates the mean difference in arm circumference for

Â two groups of children who differ by one unit, or one centimeter, in height.

Â And this difference is such that it compares the taller group to

Â the shorter group where the difference in one centimeter.

Â So, putting in this 0.16,

Â this result estimates that the mean difference in arm circumferences for

Â a one cenmetor, centimeter difference in height is 0.16 centimeters with

Â taller children having the greater arm circumference by 0.16 centimeters.

Â Notice that, and this is something we pointed out about lines, but

Â this estimate is constant across the entire height range of the sample.

Â That's the assumption we're making by estimating this line, that a one unit

Â difference in height results in the same 0.16 centimeter difference in

Â average arm circumference, regardless of the two heights we are comparing, so

Â long as they differ by one centimeter.

Â So for example, I could ask the question based on these results: what is

Â the estimated mean difference in arm circumference for

Â children 60 centimeters tall versus 59 centimeters tall?

Â And the answer is 0.16 centimeters.

Â How about children who are 45 centimeters versus 44?

Â The answer again is 0.16 centimeters.

Â 72 versus 71, I could go on and on 0.16 centimeters.

Â So what have we done by exploiting this linear relationship,

Â well we'll see how to get confidence intervals on this in the next section, but

Â think about this, we were able to use all of the data at

Â once instead of breaking it up into subgroups of smaller numbers of children.

Â And all we had to do was estimate two numbers, the intercept and

Â slope using the entire sample of 150.

Â What's that going to do to our precision of the relationship between

Â arm circumference and

Â height as compared to categorizing the children into different height groups?

Â Well, we can use all the data.

Â And we only have to estimate two numbers to describe this association as only,

Â as opposed to only being able to use a subset of the data like the 38

Â children who were in height quartile 1 to estimate the mean for that group.

Â So by exploring this linear relationship, we see we're going to end up

Â with a more precise estimate of the arm circumference/height relationship.

Â Of course, this would not be an appropriate idea if this relationship were

Â not well described by a line, but when it is, this works well.

Â What if we wanted to compare the estimated mean difference in arm circumference for

Â children 50 cent, 60 centimeters tall versus children 50 centimeters tall.

Â Well we said that a one unit difference in height

Â results in an estimated 0.16 centimeter difference in arm circumference for

Â any two groups who differ by one unit in height.

Â If we were to extend the difference to 10 centimeters in height,

Â this would accrue additively.

Â So a difference in 10 centimeters in height will result in 0.16 plus 0.16

Â up to it, adding it to itself ten times or, in otherwise, 10 times 0.16.

Â So, the difference in estimated mean arm circumference for

Â a 10 unit difference in height is equal to 10 times the estimated mean difference for

Â a 1 unit difference in height.

Â So, 0.16 times 10 is 1.6 centimeters.

Â So this slope is very powerful because it allows us to compare any two

Â groups who differ by any heights observed in our data range in terms of

Â estimating the average difference in arm circumference between them.

Â And just to reiterate this is a really powerful result if our

Â data meets the linearity assumption because we can use all the data to

Â estimate two quantities, the intercept and the slope, which will allow us to

Â quantify differences in the mean across the entire range.

Â We don't have to break it up into smaller subgroups, and lose precision, et cetera.

Â So under the linearity assumption, if that's met, this slope is a very powerful

Â number, because it describes all differences in the mean of the outcome for

Â all possible unit differences and multi-unit differences in the predictor.

Â >> What is the estimated mean difference for

Â children who are 90 centimeters tall versus 89, or 34 versus 33.

Â Your impulse here might be to say 0.16.

Â 0.16 just like we did before.

Â But this is a trick question.

Â And this will have ramifications for interpreting the intercept as well.

Â So the arrange of observed heights in the example is 40.9 to 73.3 centimeters.

Â So even though this line we've estimated theoretically goes on forever in

Â two dimensional space, we can only use the portion that corresponds to the x or

Â height range in our data.

Â So all this part out here is not applic,

Â we can't extrapolate about this relationship to other height group that

Â are outside of what we've observed in this sample.

Â So our regression results only apply to the relationship between arm circumference

Â and height, for children between 41 and 73 centimeters tall from Nepal.

Â So that leads us to question,

Â well then how do we interpret the estimated intercept?

Â Well by convention 2.7, the estimated intercept,

Â estimates the mean y, when x is zero.

Â So this is the estimated mean arm circumference for

Â children zero centimeters tall.

Â Well first of all it's impossible to have children who are zero centimeters tall, so

Â it would, it's a pretty big heads up that this doesn't make sense.

Â And technically speaking, even if we believed there could be children zero

Â centimeters tall, the height range in our data started at 41 centimeters, so

Â we do not have children who are at a value of zero.

Â So, this intercept is an important mathematical place holder, and

Â I'll show why in a second, but it doesn't have any relevance to our sample.

Â That number of 2.7 doesn't tell us anything about any of

Â the children's arm circumference for any group of children in our sample.

Â And this is frequently the case with a linear predictor when we use it as

Â continuous, when, and this is frequently the case when our predictor is continuous.

Â The scientific interpretation of the intercept is scientifically meaningless.

Â But we need this intercept to fully specify the equation of the line.

Â And just note in this scatter plot, it, you can trick yourself into thinking,

Â well, the intercept must be over here, just where it hits the Y axis, but

Â this Y axis starts at 39 centimeters.

Â So, this is a visual trick.

Â If we were to actually include zero on this picture, it would be way over here,

Â and the resulting line that we got between, below 40 and

Â 0 would not actually apply to our population from which the sample is taken,

Â because there are no heights observed for that population in the sample.

Â Why do we need the intercept though?

Â Well, without the intercept, if all I knew was the slope,

Â which tells us the change there'd be no way to put this on the graph.

Â What I'm showing here are four different lines, including our regression line,

Â that all have the same slope of 0.16 centimeters.

Â They are all indistinguishable if we only know the slope.

Â But the intercept actually allows us to verify or

Â choose a specific line with the slope of 0.16 to describe our data.

Â So it's necessary to fully specify where this line sits,

Â even amongst the heights that are way above the intercept of zero.

Â Let's look at another example.

Â Here's data of laboratory measurements on a random sample of 21 clinical patients 20

Â to 67-years-old.

Â So a very wide variability in age in the sample, but what we

Â have on these people is their hemoglobin levels in grams per deciliter and

Â their packed cell volume or hermatocrit in a percentage, a percent of packed cells.

Â So in this sample of 21, the mean hemoglobin is 14.1 grams per deciliter.

Â There's some variability 2.3 grams per deciliter and

Â the values range from 9.6 grams per deciliter to 17.1 grams per deciliter.

Â The packed cell volume, or hematocrit, the average in the sample is 41.1%.

Â So this is actually measured on a continuum,

Â the percentage of cells in an assay that are packed.

Â So this is not binary, so each person's value is a percentage.

Â The standard deviation in the individual percentage measurements amongst the 21

Â people in the sample is 8.1 % and the range goes from 25% to 55%.

Â Here is the scatter plot display of these data of the hemoglobin on the vertical

Â axis versus the packed cell volume on the horizontal axis.

Â So each point here is one of the 21 persons in the sample and

Â it shows their hemoglobin corresponding to their packed cell volume.

Â So this is sparse data, but I'm going to suggest that a line is a reasonable way to

Â start describing the average association between hemoglobin and packed cell volume.

Â So if we go ahead and do this and

Â use the computer, here's the equation I get based on these 21 data points.

Â So, we're estimating, saying that a pers,

Â a mean hemoglobin level for a given group of persons with a packed cell volume of

Â x1% can be estimated by taking this intercept of 5.77

Â plus the slope of 0.2 times the packed cell volume for that group.

Â So how do we interpret this slope?

Â Well, first we might want to get our units straight.

Â The outcome, y hat, the mean hemoglobin, is in grams per deciliter, and

Â x 1 is in percent.

Â So the slope is in units of grams per

Â deciliter per percent of packed cell volume.

Â So this slope is positive,

Â which is consistent with what we saw in our picture here.

Â And this result estimates that the mean difference in hemoglobin levels for

Â two groups of subjects who differ by 1% in hematocrit or

Â packed cell volume, PCV, is 0.2 grams per deciliter.

Â So subjects with the greater PCV have greater average hemoglobin levels.

Â Here's a scatter plot display with regression lines.

Â So again, there's not as many points as there were with the previous example, but

Â what we're estimating here, each point on a line estimates the mean given the packed

Â cell volume, and we're using this linear association to interpolate

Â for that relationship in areas of our data were we don't have any observations.

Â So we can estimate, for example, the mean at hemoglobin for

Â persons with a packed cell volume of 45% even though we didn't have any

Â data points for that, if we're willing to make this linear assumption.

Â So what would be the average difference in hemoglobin levels for

Â subjects with pack cell volume of 40% compared to subjects with 32%?

Â Well again this slope, this slope compares the average hemoglobin levels for

Â subjects who differ in packed cell volume by 1%.

Â So any two groups who differ by pack cell volume of 1%, the group with the higher

Â pack cell volume, the average hemoglobin is 0.2 grams per deciliter greater

Â than the group with the lower, or the difference in packed cell volume is 1%.

Â So we wanted to compare subjects.

Â So 40% versus 32%, well that's a difference in eight units, or

Â 8% packed cell volume.

Â The per unit difference in average mean hemoglobin is 0.2, and

Â we have an eight unit difference so we would, this is additive,

Â we just take eight copies of 0.2 added to itself or multiply it by eight.

Â And this difference is 1.6 grams per deciliter.

Â What is the estimated hemoglobin level for subjects with a packed cell volume of 41%?

Â Well, we could we could actually plug in, you know, we can estimate me,

Â me, specific means for specific groups just by plugging their x

Â value their x1 value into the equation, 41% and if we do the math we say, well,

Â we estimate that on average subjects with hematocrit or packed cell volume of 41%,

Â their average hemoglobin level is 13.97 or nearly 14 grams per deciliter.

Â What's the intercept interpretation here?

Â Well again, it's going to estimate the mean hemoglobin level,

Â when packed cell volume is 0%.

Â Pack cell volume or hematocrit rate cannot be 0%, and

Â in fact, the lowest value in our data sample is 25%.

Â So again, this is just the placeholder that's necessary to specify the full

Â equation of the line so that we can predict individual means given individual

Â group packed cell volume levels, but the number 5.77 does not

Â describe the average hemoglobin for anyone in our sample.

Â One more example, this is interesting, older but interesting data.

Â This was data on a random sample of 534 US workers in the year 1985.

Â And in the data set, had their hourly wages in

Â US dollars and other information about them, and

Â one of the pieces of information it had was their years of formal education.

Â So let's look at these data.

Â So on the whole, remember this is 1985,

Â the average hourly wage amongst the 534 workers in the data

Â set was $9.04 per hour, $9.04 U.S. dollars per hour.

Â There was some variability, though, in these hourly wages.

Â The standard deviation was five dollars and 13 cents per hour, and

Â the range was a dollar per hour ostensibly hopefully for people in the service

Â industries like waiting tables, because their salary is really based on tips.

Â This is the salaries reported by the employers, up to $44.50 per hour.

Â So, a fair amount of variability.

Â And the years of formal education, the average is 13 years.

Â So in the United States, a completion of secondary school or

Â high school is at 12 years of education.

Â So an average of 13 would indicate that the average person in the day had,

Â had, had one year beyond secondary school.

Â And there's standard deviation is 2.6 years and

Â it ranges from 2 years up to 18 years.

Â 18 yeas the education would put somebody at the graduate school level.

Â When we look at this, it is not as clean cut of a display as we saw before, but

Â here's a scatter plot display of these hourly wages versus years of education.

Â And I'm going to argue to start that, and we have very little data for, for

Â persons who have less than six years of education, but

Â they are in our data set, so I'm going to argue to start that,

Â maybe a line is a reasonable way to start with these 150 data points to try and

Â describe the trend in wages as a function of years of education.

Â And that's a poorly drawn line, but it's the idea.

Â So, if we actually did this, and ran this from Stata, or

Â some other computer package, the resulting line looks like this.

Â The average hourly wages for a group of persons given their years of

Â formal education is given by an intercept of negative 0.75,

Â plus the slope of 0.75 times the years of formal education.

Â Absolutely a coincidence that the intercept and

Â slope have the same absolute value of 0.75.

Â That's just a case example with these data, and,

Â as we've seen before, the two do not have to be the same in absolute magnitude.

Â Here's a scatter plot display of a regression line, and so what you see and

Â something we'll get into measuring later,

Â is that well it does appear that mean does increase with years of formal education.

Â But for any given level of education, there's still a fair amount of

Â variability in the individual wages around that group's mean.

Â So what is the interpretation of the slope?

Â Well the slope is 0.75 and

Â the units are dollars per year of formal education.

Â So, what does this suggest, we could say that average, average wages,

Â hourly wages increase by 75 cents per year of formal education,

Â or the expected or estimated average difference in hourly wages between two

Â groups who differ by one year in formal education is 75 cents.

Â And we could certainly use multiples of this to compare those with

Â a college education, 16 years, versus those with a high school, etcetera.

Â What is the interpretation of the intercept at negative 0.75?

Â Well, it, it really has no relevance to anybody in our data set because it's

Â the estimated hourly wages per persons who had no formal education.

Â Now remember our range of formal education was low.

Â It started low, at two years, but there was nobody at zero.

Â And a hourly wage that's negative would imply that the person was

Â paying their employer to work.

Â So, this negative 0.75 has no relevance to the population for

Â which our sample was taken, but is necessary for specifying this full line.

Â So in summary, simple linear regression is a method for relating the mean of

Â an outcome y to a predictor, we'll call it x1, when x1 is a continuous variable.

Â It can also as we seen in previous sections be binary or categorical.

Â So when x1 is a continuous variable the estimated slope for

Â x1, beta one hat, has a mean difference interpretation.

Â And in fact, it always has a mean difference interpretation regardless of

Â what type of variable x1 is.

Â But it estimates the mean difference in y for two groups who differ by one unit of

Â our predictor, x1, or in other words, the change in mean y per unit change in x1.

Â The estimated intercept is required, we need that to fully specify the line, but

Â frequently, it's not a scientifically relevant quantity.

Â It estimates the mean of our outcome when x is 0,

Â and unless there are observations with the a x value of zero in our data set,

Â and hence in our population from which the sample is taken,

Â this intercept may not have a substantive interpretation.

Â In the next section, we'll show how to put confidence limits on these linear

Â regression quantities for both situations when our predictors are binary or

Â categorical, and when they're continuous.

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