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

51 ratings

Johns Hopkins University

51 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

Hi, welcome to Lecture One Section B for Statistical Reasoning II.

Â In this lecture section, we'll make things a little bit more concrete by talking

Â about specific type of progression, simple linear regression, and we'll

Â consider situations where our predictors are binary or nominal categorical.

Â So, hopefully by the end of this lecture set you'll understand linear regression in

Â general provides a framework for estimating means and mean differences.

Â And be able to interpret the estimated slope or slopes and

Â intercept from a simple linear regression model with either a binary predictor or

Â a nominal categorical predictor.

Â So now let's bring in some specifics about that Left Hand Side I

Â was leaving as an empty box before.

Â For a linear regression, the equation is actually relatively straightforward.

Â The regression model is the mean value of a continuous outcome.

Â As a linear function of the predictor X one.

Â And it is noted in the previous section and this applies to

Â any type of simple regression, X one can represent a binary predictor.

Â It can be modified to represent a nominal categorical predictor or

Â it can represent a continuous predictor.

Â We could also modify to represent a normal categorical predictor, so

Â we have a lot of flexibility with what our predictor choices look

Â like when we approach this problem as a regression framework.

Â So just to actually clarify that what we will be doing is

Â estimating our regression results from a sample from some larger population.

Â And to indicate that the intercepted slope quantities we get are just estimates of

Â some underlined population level quantities that we can't directly observe.

Â I'm going to dress these up and

Â put hats on them to indicate that they're estimates.

Â And just to keep the notation uniform.

Â And to be comparable to what you'll likely see in textbooks and

Â papers and that sort of thing, even though we're modeling the mean,

Â yes I mean the mean which will be represented with a bar over the top,

Â although variable Y, we'll frequently write this as y hat equals beta

Â non hat plus beta one hat x1 where y hat is analogous to y bar.

Â Just the mean of the y.

Â So, for any given value of x1 we can estimate the mean of y via this equation.

Â And what we'll see and remind you of,

Â remember this slope is what we sort of defined generically compares the outcome,

Â left-hand side for any two groups to differ by one unit x1.

Â And since our left-hand side is now a mean of a continuous variable,

Â this slope compares the mean value of y for

Â two groups who differ by one unit in our predictor x1.

Â And hence, we'll have a nice interpretation.

Â The slope will be interpretable as a mean difference between two groups.

Â So let's look at the first example to get some data on the table and

Â look at some real results.

Â So this is data on anthropometric measures from a random sample of

Â 150 Nepali children who were between zero and 12 months old.

Â So less than a year old.

Â Question we might ask is,

Â what is the relationship between average arm circumference and sex of a child.

Â We've already looked at this before in a t-test context,

Â let's look at how it shapes up as a regression.

Â So the data on these 150 children, the mean arm circumference is 12.4 cm.

Â The within child average variability, or standard deviation, is 1.5 centimeters.

Â And the values range from 7.3 to 15.6 centimeters in this group of

Â children of mixed ages.

Â And a little over half, 51% of this sample is female.

Â Here's a box plot display of the data we'll be looking at.

Â And I just, and I'll do this now, remember we have a binary predictor.

Â One way to handle that is code one group as a zero, one group as a one.

Â So our males we will code as zeros arbitrarily.

Â And our females is ones.

Â And, so this is a box plot display.

Â And you can sort of see that the distribution, couple things.

Â First of all, the values for

Â males tend to be more variable than the values for females.

Â And they tend to rise or sit a little bit higher, larger.

Â For example, a median is at least slightly larger than the median for

Â females 75th percentile.

Â For males is larger than the corresponding percentile for females.

Â But, there is more variability in that middle box as well.

Â This is called a Scatterdot display, Scatterplot display and it's not

Â particularly useful for this type of situation where a predictor's binary, but

Â I just wanted to introduce this now for reasons that I'll show in a few slides.

Â And this is not as informative as the box plot.

Â And what this does is points, or plots all 150 individual measurements of

Â arm circumference versus the sex of the child, when it's coded as zero for

Â males or one for females.

Â So each point here represents one male and

Â his particular arm circumference on the vertical axis.

Â Each point here represents one female and

Â her particular arm circumference on the vertical axis.

Â So here is y's arm circumference a continuous measure, and our X or

Â X1 is not continuous but binary male or female.

Â And as we've laid out previously how are we going to handle sex as an X in

Â regression, well it only takes on two categories and one possibility that's

Â arbitrary is to code it as a zero for male children and a 1 for female children.

Â So, let's take that approach for the moment.

Â And the equation we will estimate using these data looks like this.

Â We estimate the mean arm circumference y hat as a linear function of

Â sex through these equation.

Â So we'll end up with an estimated intercept and slope, as well.

Â So just to be clear and reiterate something,

Â notice this equation first of all, its only estimating two values.

Â We only have two groups of children as defined by their predictor.

Â We have females and males.

Â So we're only ultimately estimating two mean values.

Â The estimate for female children in the generic representation before our

Â estimated mean, arm circumference are y hat ,for female children is

Â the intercept plus the slope for sex times one, since females are one.

Â So the mean for females is the sum of the intercept, and that slope beta one hat.

Â For males, it's simpler, the beta one hat drops out because males are zero and

Â we get just the intercept.

Â So beta one here, if we were to take the difference and average our

Â circumference between females and males, we'd be left with beta one hatf.

Â This estimates the mean difference in arm circumference for

Â female children compared to male children.

Â So it's, it's still a slope estimating the mean difference in y for

Â a one unit difference in x1.

Â But the only possible one unit difference when our x is binary is those who

Â are coded one, to those who are coded zero.

Â So here, done with the aid of the computer and

Â based on these actual data is the resulting equation.

Â Our estimate, our mean arm circumference to be equal to 12.5 plus

Â the slope of negative 0.13 times x sex, or x1, which is a one for females.

Â So the slope, as we've just clarified, equals negative 0.13.

Â And from the previous slide, we know this is the estimated mean difference in

Â arm circumference for female children compared to male children.

Â In other words, female children have lower arm circumference by

Â 0.13 centimeters on average, relative to males.

Â The intercept is equal to 12.5 centimeters and

Â that estimates the mean arm circumference for male children.

Â You might say, well you've only got two groups here.

Â Is that slope really a slope?

Â Does it really describe the slope of a line?

Â Well we only need two points to establish any line in space and

Â what we're estimating are two means.

Â And in fact the slope is the slope of the line that connects the mean for

Â the group coded zero males to the group coded one females.

Â And this slope, it's hard to see scaling wise in this predictor is that difference

Â between the mean for females compared to males of negative 0.13.

Â The coding choice we made for our sex predictor is completely arbitrary.

Â There's no reason females have to be one and males have to be 0.

Â So what I'd like you to ponder, and I'll come back to the review exercises is for

Â this arm circumference and sex analysis what would the values of the intercept and

Â slope be if sex was coded as a one for females, and a zero for males?

Â Let's look at another example a data from our 2011 hospitalizations.

Â Data from the nearly 13,000 members of Heritage Health who had a length of stay,

Â cumulative length of stay of at least one day in the hospital in 2011.

Â So the question we might have is what is the relationship between average length of

Â stay and age of first claim?

Â And what we're going to do is,

Â this is going to be as the data represented, binary.

Â It's either less than 40 or greater than or equal to 40.

Â And I'm arbitrarily going to make the decision to make it

Â a 1 if they're less than 40.

Â And a 0 if they're greater than 40.

Â And in these data, the average length for everyone was 4.3 days,

Â with standard deviation of 4.9 days.

Â And a range from one day total in 2011 to 41 days total.

Â And 29% of the observations in this data were from persons whose first

Â stay in the hospital happened when they were less than 40 years old.

Â Their first 2011 hospital stay.

Â So here's a box plot display of these data.

Â And you can see we've already looked at this.

Â And ostensibly it's stat reasoning one.

Â But the distributions of length of stay are right skewed for both groups.

Â And the distribution shifts up for those who are greater than or

Â equal to 40 relative to the distribution for those who are less than 40.

Â So there's a lot of crossover here.

Â But those.

Â It visually, at least.

Â Those who are older than 40.

Â Greater than or equal to 40.

Â When they were first hospitalized in 2011 tended to

Â have slightly longer length of stays.

Â But that's a little hard to see in the visual so

Â we'll ultimately want to quantify that and see if that holds.

Â So we could fit this regression equation where we relate average length of stay to

Â our predictor x1, which is coded as I noted before.

Â So 1 if the subject is less than 40 years old at there,

Â when they first went in hospital in the 2011.

Â And a 0 if they were greater than or equal to 40 years old.

Â So this slope of negative 2.1 is the estimated indifference for

Â those who were coded one versus zero.

Â It's the estimated mean difference in length of stay for persons who were less

Â than 40 at their first hospital claim in 2011 compared to persons over 40.

Â So the younger group had an average length of stay of

Â 2.1 days less than the older group.

Â And the intercept, estimates the mean length of stay when x1 is 0,

Â that's the group who is over 40 at their age, at their first claim.

Â And the average length of stay for that group was 4.9 days.

Â So what would be the estimated average length of stay for the younger group?

Â Well, we take this average length of stay for the older group, 4.9.

Â And add the difference between the two of negative 2.1 and

Â that would give us the mean length of stay, which would be 2.8 days for

Â the group who was less than 40 when they entered the hospital in 2011.

Â Let's look at another example.

Â Sometimes regression scenarios include predictors which are not continuous,

Â not binary, but are multi-categorical.

Â These are things, especially in the nominal world like subject's race, white,

Â African-American, Hispanic, Asian, or

Â some other classification, or say their city of residence,

Â amongst four different places, Baltimore, Chicago, Tokyo, Madrid for example.

Â So how can we handle this type of situation when we

Â have a nominal categorical variable in a regression framework?

Â So we're going to explore this using the example based on the academic physician

Â salary results we've looked at previously in Stat Reasoning One.

Â So this is the study in which data was collected on 800 U.S. academic physicians.

Â And included information about their yearly salary.

Â And a lot of additional information was collected including the sex of

Â the physician and other factors.

Â One of the other factors that was collected was the geographical region of

Â the U.S of the entire United States where the job was located.

Â So whether their job was located in the West, a part of the U.S.,

Â the northeast, the south, and the midwest.

Â So, the question that we might have to start is do average salaries differ by

Â geographical region and, if so, what is the magnitude of these differences?

Â So can we do this analysis as linear regression?

Â Previously, we would have thought of this as an analysis of variants where we're

Â comparing mean.

Â Salaries across four groups.

Â Can we set up an analysis of variances of regression?

Â And, if so, how can we handle a predictor that takes on four categories.

Â Like, is predict, or region of the United States.

Â Well the first approach, so

Â you might say, well let's arbitrarily give each region a numerical value.

Â And, just for example we'll say, x1.

Â Make it even a one if their job is on the west part of the United States.

Â It's a two if they're in the midwest, three for

Â a south, and four for a northeast.

Â This is totally arbitrary.

Â You could come, you could do this differently.

Â And then we estimate an equation that relates the mean salary to region by this

Â formulation we would in one occurrence of x, takes on a value of 1 through 4.

Â This is not a good idea.

Â That coding I just put out is completely arbitrary.

Â You could have come back and coded as a one for the midwest, a two for

Â the northeast, etcetera, and depending on how we code this.

Â The results we get will be different.

Â We will be treating this as an ordinal categorical variable and

Â there's no logical ordering to the categories.

Â So our estimated regression will depend on how we've

Â arbitrarily coded these four categories.

Â Furthermore, this type of coding assumes that the mean salary

Â difference between regions is incremental.

Â For example, under the coding I put forward, the diff we.

Â This makes the assumption, when it estimates things, that the difference in

Â average salaries between physicians in the South and the west, who differ by two

Â units in x is twice the difference between physicians in the midwest and the west.

Â And that's a strong assumption.

Â That's forcing inordinality on these data that may not be there.

Â And in my consulting collaborations I've seen people run models like

Â this where they just take the predictor as is.

Â And stick it in as coded one, two, three or

Â four and pay no attention to the fact that it's nominal and not ordinal.

Â And that can obviously have an affect on the results they get.

Â So, it's easy to get caught up in this idea when you're running models,

Â of just throwing things in and hitting the button on the computer.

Â But sometimes you want to pause and think about what you're actually doing.

Â So how can we handle this better when we have something that's not

Â inherently ordinal in nature, but is categorical.

Â Well it is kind of what we set up in the first section, but

Â now we'll do it specifically.

Â We designate one region as the reference region, so

Â I'm going to arbitrarily say the West.

Â And we make binary indicators for each of the three other regions.

Â You could do this differently, but

Â the ultimate inclusions would be exactly the same.

Â So I'm going to make three indicators for the other three regions, so I'm going to

Â make x1 equal to one if the position works in the midwest, and a zero if they do not.

Â When I create a variable called x2 which is equal to one if they work in

Â the South US, a zero if not.

Â And an x3 with is equal to one if they work in the Northeast section of the US,

Â and a zero if not, if otherwise, if they work in any of the other three regions.

Â So here's a table showing these x values for each region.

Â The West is the reference region.

Â It doesn't get its own indicator, its value for each of those is zero.

Â Because the West is not in the Midwest, not in the South and not in the Northeast.

Â The Midwest, its indicator is x1, it takes on the value of one.

Â When the observation comes from somebody who works in the Midwest and has zero for

Â the other two indicators.

Â If they're from the South, they're not in the Midwest so

Â the indicator for the Midwest is a zero.

Â The indicator for

Â the South, X2 is a one and the indicator for the North East is a zero.

Â And similarity for those from the North East.

Â They're not in the Midwest, so that's a 0.

Â They're not in the South, so that's a 0.

Â But they are in the Northeast, so that x3 is a 1.

Â So we can now fit the regression model, and it looks like this.

Â And, and this is a fancy equation to estimate only four mean salaries,

Â but it does this in a linear equation framework.

Â And so let's pause this for a minute.

Â So, what is the intercept estimate?

Â Well, this is the estimated salary when all of our x's are zero.

Â Well from the previous slide we saw that all x's were zero when we're looking at

Â the reference group, the West.

Â So here the intercept has meaning.

Â Its mean is, it is the estimated mean salary for physicians from the west.

Â So this intercept will be a number that estimates the mean salary for

Â physicians from the west.

Â And then each slope or each coefficient of the x's estimates the mean

Â salary difference between the region that has that corresponding x value of one and

Â the reference region, the western states.

Â So for example, just to write this out to give you an example.

Â If we looked at physicians in the midwest, their value of x1 was one and

Â their value of x2 and x3 is zero.

Â The model estimates the mean salary for

Â physicians from that group is being intercept plus the slope for x1.

Â Be it a not, plus beta 1.

Â For physicians who work in the West, all their x's are zero so, as

Â we've established before, their estimated mean salary is just the intercept.

Â So the difference in average salaries between those physicians who work in

Â the Midwest and those who work in the West is simply the slope for

Â that indicator of working in the midwest.

Â So here's the resulting equation.

Â The intercept is $194,427.

Â This slope for midwest is $4,416.

Â The slope for the south is negative $35.

Â You can figure this is plus negative 35.

Â So beta two hat the slope to the south equals negative $35.

Â And the slope for the northeast is negative $2222.

Â So let's make sense of this positions of the west.

Â Their average salary is $194,474 annually.

Â Physicians in the; for example, Midwest,

Â their average salary is $194,474 plus the slope of the Midwest

Â this $416 so, this means we can work this out.

Â But, this indicates that those physicians in the Midwest make $4,416 more

Â yearly, on average, than those physicians in the reference group, the West.

Â For the Southern physicians, their estimated salary is this intercept again.

Â Plus the for the indicator of the south plus negative 35.

Â So on average, physicians in the South make $35 less per year

Â than those physicians in the West.

Â And you can write this out for verification but

Â if we were looking at physicians in the North East.

Â Their average salary is $2,322 less than the average of

Â 194,474 made by physicians in the west.

Â So in summary, simple linear regression is a method for estimating the relationship

Â between the mean value of an outcome, y and a predictor, x 1, via linear equation.

Â When x is binary, the slope estimate,

Â generically called beta 1 hat, estimates the main difference in why for

Â the group with x 1 equal to 1, compared to the group with x 1 equal to 0.

Â The intercept estimates the mean value of Y for

Â the group with x1 equal to 0, the reference group.

Â When x is a nominal categorical variable,

Â this can also be done with the ordinal categorical and

Â we'll look at examples with that for some of the other regressions.

Â You need to designate one category to be the reference group and

Â make separate binary axis for all other categories, and

Â the slope of those binary indicators estimates the mean

Â difference between the group whose value is one and the reference group.

Â What we'll do in the next session is show how to interpret the results from

Â linear regressions when we allow our X1 predictor to be continuous.

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