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

76 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

Okay, in this section we'll consider simple logistic regression when our

Â predictor of interest is now continuous.

Â And hopefully, this will give you some insight as to why we need to transform

Â the estimated binary outcome from a proportion to a log odds.

Â Why this transformation is necessary to be able to properly estimate logistic

Â regression equations, in general, to include predictors that are continuous.

Â We'll also talk about something called a lowess plot.

Â Which is analogous to a scatter plot presentation with simple linear

Â regression.

Â That helps us get a snapshot of the relationship between the log odds

Â over outcome and the continuous predictor x1.

Â And this will allow us to evaluate whether the relationship is relatively

Â linear in nature which is an assumption of the logistic regression model.

Â We'll also learn how to interpret the slope and

Â intercept from simple logistic regression models with the continuous predictor, and

Â translate this into an estimated odds ratio.

Â This will be very similar to what we did in the last section.

Â So let's just take a little bit more deeper look at the background of

Â the underlying model.

Â Why do we have to model the log odd which is already a function of x 1?

Â Well this is became an issue when our predictor can be continuous.

Â So let's just think about for a minute.

Â Well you might say, well John, the initial summary statistics we had for

Â binary data was a proportion.

Â It's a perfect way to summarize binary data, the proportion or

Â probability of the outcome occurring.

Â So why don't we just go ahead and fit a regression model that

Â estimates the proportion as a linear function of our predictor.

Â And we want this to work for all situations, including the situation where

Â our predictor is measured as a continuous variable.

Â Well here's the potential rub with this, the potential difficulty,

Â is that the way we define proportions, they have to be between zero and one.

Â So if we're estimating the proportion as a function of a continuous predictor,

Â x, we have to have an estimation procedure to give us the logistic regression,

Â intercept, and slope.

Â It estimates them such that it ensures that all predictions of the proportion or

Â probability we get for all x1 values in our sample of data.

Â All of the resulting combination of the intercept plus the slope times every x1

Â value yields an estimate between 0 and 1 for the outcome of the proportion.

Â And that's actually a difficult estimation procedure.

Â To constrain the slopes and

Â intercepts we get such that they always work with the x1 values in our sample

Â data to give us an estimate of the proportion between 0 and 1.

Â That's actually complicated.

Â So, maybe your first thought is well, we can be a little more flexible.

Â What if we turn the proportion into the odds and

Â try and model that as a function,

Â a linear function of our predictor.

Â Where our predictor can be continuous.

Â Well, this might work a little better, but here's the deal with the odds.

Â If the proportion itself, or probability, can lie between 0 and

Â 1, then let's think about what the odds can be.

Â Well, let's take the lower bound on the probability proportion.

Â If that's close to 0 then our odds is going to be

Â such that the numerator's close to 0, and the denominator's close to 1.

Â So when the probability or proportion is close to 0, the odds is close to 0.

Â However when our probability gets large, gets close to 1, the numerator is close to

Â 1, and the denominator will be close to 0, pushing this towards positive infinity.

Â So odds lives on a more open range than proportion or probability.

Â But it's still constrained by the fact that all the estimates of the odds

Â are positive.

Â And if we have a continuous predictor trying to estimate intercept and

Â slope such that all predicted odds for all observations in our data set turn out to

Â be positive, is again a tricky estimation issue.

Â So you'll recall, hopefully, from stat reasoning one,

Â if we take something that lives on the positive number line and log it.

Â The range of possible values covers the entire number line from

Â negative infinity to positive infinity.

Â So if we translate things to the log odds scale,

Â any estimated value of the log odds is quote, unquote, legal.

Â And there's no constraints on estimating the intercept and

Â slope given a range of x1 values in a data set.

Â So this is the most flexible approach and

Â that's why we do things on the log odd scale.

Â If we were to transform this formulation where we take the log odds

Â equal to a linear function over x.

Â If we exponentiate both sides and

Â then solve for the p or proportion in the log odds.

Â Another way to express this equation is like this.

Â That we're actually modeling the probability or

Â proportion as this function here.

Â And you'll notice that this is just another way of saying that no matter

Â what we get for our beta 1.

Â And regardless what the resulting predicted equation is for

Â a given value of x1, the numerator of this probability formulation or

Â version of the equation will always be positive because e is a positive number.

Â And a positive number raised to any power, be it negative or positive, is positive.

Â And the denominator is always one larger than the numerator.

Â So this formulation, if we keep, if we estimate things on the log odds scale

Â as a linear function of our x is when we translate back to the probability scale,

Â we will always get an estimated probability between 0 and 1.

Â So it's just another way of saying that this estimation process yields legal

Â values.

Â And we'll show later in this lecture set

Â how to convert from the log odd scale to the probability scale.

Â Let's get into some examples with continuous predictors to

Â really solidify what we're doing here.

Â So data here is taken from the 2009-10 NHANES,

Â or National Health and Nutrition Examination Survey.

Â There's a sample of over 6,400 US residents in these data, between 16 and

Â 80 years old.

Â And what I want to look at here, based on the 6,400 residents is

Â the association between being obese and HDL cholesterol level.

Â So the HDL levels in the sample were averaged to be 52.4 mg/dl.

Â But range from a very low 11 to 144,

Â which is a very high value.

Â 15% of the sample is classified as

Â obese in terms of using their BMI measurement to make that classification.

Â So the question we might want to ask is, can we estimate the association between

Â the risk of being obese and HDL cholesterol level?

Â And we can certainly use logistic regression and estimate a line

Â that relates the log odds of being obese to a linear function of HDL cholesterol.

Â So here in this formulation p is the probability of being obese and

Â this is the log odds.

Â And x1 is the HDL cholesterol level in milligrams per deciliter.

Â We can certainly get the computer to do this, the question is,

Â is this a good idea?

Â The formulation here makes a strong assumption about the nature

Â of the relationship between the log odds of obesity and the HDL cholesterol level.

Â As measured on the continuous scale.

Â So how can we take a look and see whether this is reasonable?

Â Well, when we had continuous outcomes and a continuous predictor,

Â we could do a scatterplot.

Â And see whether it was reasonable to assume

Â a linear relationship between the mean of our continuous outcome and our predictor.

Â What we're actually assuming is linear when we have a binary outcome is the log

Â odds of the outcome as a function of the predictor.

Â There's no way to directly present this, but

Â there's something that the computer can do to help aid us in this investigation.

Â And this here is something called a LOWESS plot,

Â which I think of as a smoothed scatterplot.

Â Which tries to plot a visual of the observed log

Â odds of the outcome here, obesity, as a function of HDL cholesterol level.

Â What this plot does is, for every value

Â of HDL cholesterol level in our data set, it goes to that value.

Â It chooses a small window of values around that.

Â And for all points in that window,

Â it computes the proportion of persons who are obese.

Â And it gives a little more weight to the points that are closer to

Â the value we're estimating this to than the points farther away.

Â It computes that proportion, turns it into an odds, and takes the log of it, and

Â then plots that against that particular value of HDL cholesterol level.

Â And then the window moves over a little bit to the next observed value and

Â does the same thing.

Â And so this plots the log odds in small windows of HDL and connects them.

Â And we can get a sense of what the shape of the relationship is like.

Â And so for the most part, this visual shows something that's relatively linear.

Â You may say, well, John, there's this huge drop-off here.

Â This is one of the problems with this type of graph.

Â The ends of it can be heavily influenced by one or two data points, or

Â at least a small proportion.

Â So in order to investigate what was going on here, I went back and

Â looked at the data.

Â The 99th percentile of the HDL cholesterol values is 101.

Â So there's very few data points over here that are above 101 mg/dL.

Â But it looks like not so many of them were obese, so that pulls this curve down.

Â But if we looked at them between the 1st and 99 percentile cluster levels and

Â looked at this function, it would be well described by this line here.

Â So I'm going to go ahead and

Â say it's reasonable to assume this association is linear.

Â And I'm going to estimate an equation using the computer to explain this.

Â So if we use the computer to estimate the results of this logistic regression,

Â what we get is something that looks like this.

Â The log odds of obesity is equal to an intercept of -0.05 +

Â -0.033, our slope, times cholesterol level.

Â So how can we interpret this slope of -0.033?

Â Well, to start, it shows that, at least based on the sample data, the association

Â between the log odds of obesity and HDL cholesterol level is negative.

Â Indicating higher HDL is associated with lower log odds, hence, lower risk.

Â But let's interpret the slope.

Â Well, generically speaking, we've said a slope of a linear equation

Â equals the difference in the left-hand side for

Â two groups who differ by one unit.

Â So I'll call it HDL + 1- log odds for

Â group with value HDL, just indicating that these are generically 1 unit apart.

Â And again, we've said a difference in log odds is akin to the log of the first

Â thing, Over the second thing.

Â So this is the log odds ratio of being obese for

Â two groups who differ by 1 mg/dL in HDL cholesterol level.

Â So if we exponentiate this, we get the estimated odds ratio of being obese for

Â two groups, Who differ by 1 unit in HDL.

Â So this odds ratio estimate is 0.967, or about 0.97.

Â So this suggests that the odds ratio of being obese for

Â two groups of persons who differ by on unit, which is one mg/dL in HDL levels,

Â is 0.97 for the higher HDL group to the lower.

Â So in other words, higher HDL subjects by one mg/dL have 3%

Â lower odds of being obese when compared to the lower group,

Â and again, where the difference is one mg/dL.

Â And this estimate is for any two groups who differ by one mg/dL

Â in HDL in our population from which the sample was taken.

Â And it only applies to the HDL values we solve in the data set.

Â So we saw an extreme range of 11 to 144 mg/dL.

Â And any one unit difference in that range,

Â this odds ratio describes the relative odds of obesity.

Â So your interpretation of beta 0,

Â well, beta 0 = -0.05.

Â And generically speaking, beta 0 is the log odds of obesity,

Â For persons with x1 or HDL equal to 0.

Â So again, this is just a placeholder.

Â Because we don't have any persons in our data set, thankfully,

Â with an HDL cholesterol level of 0.

Â We need this to fully specify our regression equation so that we could, for

Â example, predict the log odds for specific groups based on their HDL level.

Â But it doesn't have any scientific relevance to our data set.

Â So whether we exponentiate it or not, this is just a placeholder in our line.

Â You might say, well, I'm interested in comparing the relative odds of being obese

Â for two groups of people who differ by more than one unit, so, for example,

Â those who differ by 20 mg/dL.

Â And to put some concrete numbers on this, how about 100 mg/dL versus 80?

Â And, well,

Â this will turn out to be like it was in other linear comparisons we made.

Â But let's just write it out to be sure.

Â If we did the log odds when x1 = 100,

Â it's just, generically speaking,

Â the intercept + 100 times the slope.

Â Versus the log odds when the cholesterol

Â level is 80 = the intercept + 80 times the slope.

Â We take that difference, we get 20 times the slope,

Â or 20 times -0.033, which is -0.66.

Â This estimates the log odds ratio of obesity for

Â x1 = 100 to x1 = 80.

Â If we exponentiate this, we get the odds ratio estimate,

Â which turns out to be about 0.51.

Â So you see that 3% decrease over 20 years compounds pretty quickly.

Â The resulting odds ratio for

Â those at 100 compared to those at 80 milligrams per deciliters is 0.51.

Â For those at 100 milligrams per deciliter at 49% lower odds.

Â So this relationship is additive on the slope scale and

Â we'll show in the practice problems, how we could do this directly

Â from the original odds ratio without writing things out on the log scale.

Â Here's another example,

Â data on a random sample of 192 Nepali children between 1 and 3 years old,

Â so it's the same population from what we've been looking at Nepali children.

Â One of the things we might be interested in in this age range what's

Â the relationship between breast feeding, at this age, And the age of the child.

Â We might want to be able to estimate and quantify that so

Â we can compare it to other populations, children one to three years old.

Â So what we're going to do is we're going to estimate,

Â express the age association by a linear equation, we'll look at the log odds that

Â a child is breastfed has a function his or her age in months.

Â So here's a smoothed low s scatterplot of the log odds versus age,

Â Of the child and the age ranges, again,

Â from 12 to 36 months.

Â And there's a little bit of a curve here but to start, I'm going to

Â suggest that fitting in a line is not a bad approximation to what we're seeing.

Â So I`m going to go ahead and do this on the computer.

Â The estimated equation I get looks like this, the log odds of being breastfed

Â is equal to 7.3 + -0.24 times age in months.

Â So again, we have a negative association, at least for these data.

Â So let`s try and interpret these quickly now.

Â We won't go through the same detail we did before, but we've said that this

Â slope compares the outcome for two groups who differ by one unit in the x.

Â Our x is age in months, so this is the outcome function

Â for two groups of children who differ by one month of age.

Â And, of course, we're looking at difference in log odds so

Â this is the log odds ratio of being breast fed for

Â two groups who differ by one month in age.

Â And that's equal to -0.24, if we exponentiate that,

Â we get the odds ratio estimate.

Â It equals about 0.79.

Â So each month of age multiplies the relative odds of being breastfed by 0.79.

Â Or another way to say it, each month of age is associated with a 21% reduction

Â in the odds of being breastfed, okay?

Â So again, this estimate is for any two groups of children who differ by one month

Â of age in this population of Nepalese children between 12 and 36 months old.

Â So here's a question I'll leave for you to do and

Â we'll go over in the review questions is what is the estimated relative odds,

Â ie odds ratio, of being breast fed for

Â children who are 30 months old compared to children who are 6 months old?

Â What is the interpretation of the slope here?

Â Well age of children could potentially be zero so it's not as absurd

Â except our age range is between 12 and 24 months, we don't have any newborns.

Â So the log odds of being breastfed at birth or

Â when age is zero is estimated by the intercept.

Â But this doesn't really estimate the log odds of being breastfed at birth because

Â we don't have any newborns in our data set, we start at one years old.

Â So even though there are zero month old babies when they're born new,

Â this estimate it does not apply to them because we don't

Â have any in the sample we're using the estimated.

Â So this is going to be a placeholder,

Â again, that doesn't describe the log odds for anyone in their data set.

Â We could exponetiate it to get the odds for this group but again,

Â it doesn't describe anyone in our data.

Â One more example, in the last section I showed you an example where something that

Â could've been measured on a continuum, gestational age, was actually categorized.

Â And I suggested there was a reason for that.

Â Now I don't have, I'm not privy to the raw data so

Â I can't show you an actual low s-plot that I generate here.

Â But I did have the group data by groups of gestational age and

Â was able to come up with these logistic regression estimates.

Â But I just want to show you something quickly here.

Â So I don't know if you recall, but the reference group,

Â there were four gestational age groups, was 37 to 40 weeks, and then we

Â had indicators for being 34 weeks, 35 weeks,

Â And 36 weeks and this was looking at the log odds of respiratory failure.

Â Let's just graph this just crudely for a moment.

Â Suppose this is Our categories,

Â these are ordinal categories, 34, 35, 36, and

Â then 37 to 41 so I'll just say 37 plus here.

Â So we start with the reference group, the estimated log odds,

Â let's make it a 5.5, I'm just going to draw this here, I'm not, so it's -5.5.

Â Okay, so then the first 36 weeks how much larger is this than

Â -5.5 on the log odd scale, well I'm going to do using units of 0.5 so

Â it's 2 units larger, so its value is -3.5, 36.

Â And then, how much larger is 35 weeks in the same reference group?

Â Well, it's 2.8 units which puts it at about,

Â -2.7 on the log onto scale, I'm not drawing this perfectly to scale.

Â And then finally, when we get to the lowest gestational age group it was 3.4

Â units higher than the reference.

Â Which puts it at, And

Â again, this isn't perfectly drawn to scale but -2.1 there.

Â So what I'm showing here is that, for

Â the first three groups it looks like the relationship is roughly linear,

Â but then it really drops between the 36 and 37 weeks.

Â So in order to capture this disconnect here between these three groups and

Â the full term babies ,instead of smoothing that out t his

Â categorization schema recognizes that difference in trajectory.

Â I didn't draw this very well but I'm just trying to give you some insight.

Â So sometimes it makes sense to take something on a continuum and

Â model it as categorical if there is not evidence in the data that the association

Â is strictly linear between the log odds, the outcome, and our continuous predictor.

Â So in summary, simple logistic regression can be done with binary, categorical, and

Â continuous predictors.

Â When the predictor x1 is continuous,

Â the model estimates a linear relationship between the log odds y and x1 and

Â there are ways to see whether that assumption is met.

Â And there are visual tools for that.

Â And the regress, the resulting the estimated slope from logistic regression

Â with a continuous predictor still has a log odds ratio interpretation and

Â the intercept, a log odds when x1 = 0 interpretation,

Â although in many cases that's not relevant to our data.

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