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

78 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

So the term correlation gets used a lot not just in statistics, but

Â in everyday life.

Â Well, in this section we're actually going to show how to use the results from

Â linear regression to measure correlation.

Â It's something we get in the output from a computer package that does

Â linear regression models.

Â And we'll show two different ways of measuring this that are related to

Â each other, but have some slight differences in terms of the,

Â how the numbers come out and their interpretations.

Â Now, let's talk about using the results from simple linear regression to

Â get information about the strength of the linear association between our

Â outcome and predictor.

Â So the slope of a regression line estimates the magnitude and

Â direction of the relationship between y and x1.

Â Especially, when x1 continuous,

Â encapsulates how much y differs on average with differences in x1.

Â The slope estimate and the standard error can be used to address the uncertainty in

Â this estimate, with regards to the true magnitude and direction of

Â the association in the population from which the sample was taken.

Â Slopes do not impart any information,

Â however about how well the regression line fits to the data in the sample.

Â The slope gives no indication of how close the points get to

Â the estimated regression line.

Â And one of the things about the slope is it can be made arbitrarily larger or

Â smaller just by changing the units of either x1,

Â when x1 is continuous or y, or both.

Â So let me give you an example where x1 is continuous.

Â This is arm circumference and height.

Â Arm circumference we had measured in centimeters on these 150 Nepali children.

Â And height was measured in centimeters.

Â And hence, the regression equation we got gave us an estimate of the relationship

Â between arm circumference and height when both were measured in centimeters.

Â You may re, may recall under this scenario the slope for height was 0.16 centimeters.

Â We would expect an average difference in

Â arm circumference of 0.16 centimeters per 1 centimeter difference in height between

Â two groups of Nepali children, in this age group.

Â But suppose we had actually gone back and converted our height measure to inches.

Â So each children's height in inches instead of centimeters and

Â re-ran the regression model.

Â We have done nothing to change the relationship between arm

Â circumference height in this sample.

Â We're simply expressing height in different units.

Â If we do this, the resulting slope of height is now 0.41.

Â Because a one unit difference in x is a larger difference than when we

Â were recording height in centimeters.

Â This is estimated 0.41 centimeter difference in

Â arm circumference on average per 1 inch difference in height.

Â So we can arbitrarily inflate the absolute value of the slope or reduce it just by

Â playing around with the units of our outcome, or predictor, or both.

Â There's another quantity that comes out of simple linear regression that can

Â be estimated.

Â It's called the,

Â it has a fancy [LAUGH] kind of silly name, the coefficient of determination.

Â More frequently referred to as R squared.

Â This is a number that ranges from 0 to 1 with larger values, that is values closer

Â to 1, indicating closer fits if you will, of the data points to the regression line.

Â What R squared essentially does is, it's a relative comparison.

Â It measures the strength of the association between our outcome y and

Â our predictor x1, by comparing the overall variability of observed y-values

Â around their regression based estimates of the mean, for groups with

Â the same x-values to variability in the y-values ignoring the information in x.

Â So let's diagram this a little more detailed.

Â So how close, for example does,

Â do the arm circumferences points get to the arm circumference mean

Â estimates based on height, using that linear regression equation?

Â Well to, and

Â understand this, let's just go back to statistical reasoning one for a minute.

Â And say, let's pretend, you know, we didn't know how to do regression.

Â And so we decided to ignore our information about height, because we

Â didn't know how to relate our continuous outcome to a continuous predictor.

Â And we forgot that we could dichotomize height or

Â put it into quartiles and do a t-test or an ANOVA.

Â Well, recall the way we'd originally quantify the variability in

Â arm circumference if we didn't take into account any other information about our

Â children is measure, essentially we can think of it as the average.

Â Average, difference or

Â distance, between any sample value.

Â And the overall sample mean.

Â So this measures how far on average each of the sample, the observed, if you will,

Â y-values, for example, each individual child's height falls from

Â the overall mean height of all 150 children.

Â And it is this example, s or the sample standard deviation is 1.48 centimeters.

Â Some children fall closer to the mean, some fall farther.

Â But on average, the distance above or below the mean is 1.48 centimeters.

Â So if we were to try and

Â visualize, I mean put this is on the scatterplot which includes height although

Â we're ignoring any information right.

Â And what this would look like is a regression issue is just

Â plotting a horizontal line at the overall mean of all 150.

Â And what we do is then measure the distance of each observed child's arm

Â circumference from the overall mean of, they're all 150 arm circumferences.

Â We'd square those distances, add them, average them and

Â take square root to get the average distance of any individual child's arm

Â circumference from the overall mean of all children in the sample.

Â There's another standard deviation of regression,

Â sometimes called as the root mean square error.

Â That sounds fancy, but let's think about it for a minute.

Â Error is another word for deviation.

Â Square is synonymous with square.

Â So this is squared error or squared deviation.

Â Mean would be the average square deviation and root is the square root of that.

Â So, this is basically the square root of the average distance.

Â Just like we saw with the previous quantity, but

Â what this does is measures the distance of each individual y value.

Â Not from the same overall mean of all y-values, but from its x-specific mean.

Â So for example, in this arm circumference and height example we would

Â compare each child's arm circumference value to the estimated mean

Â by regression for all children with the same height or x1 value.

Â So we're allowing the mean estimate in regression to change depending on

Â another factor, our x variable.

Â And we're measuring the discrepancy between our observed y-values and

Â the x-specific means estimated by the regression line.

Â And in this example if we calculate that and

Â don't worry about this detail, divided by n minus 2.

Â You can think of this as the average distance of

Â each observed point around its regression estimated mean, y.

Â It's 1.09, that's less than when we ignored height.

Â So the idea is we get closer,

Â our individual points get closer to their height specific arm circumference means.

Â Their y hats based on their corresponding value of x1,

Â then they do if we ignore the information in x1 and

Â measure the distance of each y from the same overall mean.

Â Right?

Â So what we do here is instead of computing the distance from that flat overall line I

Â drew before, we compute the distance of each point from its

Â corresponding mean estimate based on height from the regression line.

Â We'd square these distances and average them to get the overall squared difference

Â between 150 sample points and their regression line based estimated mean

Â arm circumferences, and we take the square root of that to get the average distance.

Â The idea is if we don't actually reduce our variation in the y-values around

Â their regression estimated means once we've taken into account x1 is

Â essentially our variability in our y-values after accounting for

Â x1 is the same as when we ignored x1.

Â Then knowing x does not yield a better estimate for

Â the mean of y than using the overall mean y bar.

Â We don't do any better than if we estimate the same mean for every one.

Â So in other words,

Â if there's no additional information about our outcome y based on x1.

Â In the arm circumference height example, this would mean that we would not

Â reduce the variability in individual arm circumferences around our height specific

Â means, relative to the variability around one overall mean arm circumference for

Â all children in the sample.

Â However, if s of regression, sometimes written as s with a little subscript y bar

Â x1, which this just means the variation of y given a predictor x1 from regression.

Â The smaller this variability of individual values around the regression estimated

Â means is relative to the overall variability on average when we ignore this

Â other predictor s, then the closer the points are to the regression line.

Â So what R squared functionally measures is how much smaller the variability of

Â individual values around their regression based estimates is

Â than the overall average variability, ignoring our predictor x1.

Â And as such it can be interpreted as the amount of

Â variability in y explained by taking x1 into account.

Â So this you can get from a computer.

Â I'll throw up a bonus and lectures that are optional to show you how

Â explicitly this is calculated, and it may give you a little more intuition to it.

Â But, this generally comes from a computer, and so I got this from the computer

Â the R squared from this regression of arm circumference on height is 0.46, 46%.

Â So, child's height explains an estimated 46% of

Â the overall original variation in arm circumferences.

Â 46% of that variation in the individual arm

Â circumference values around the same overall mean estimate.

Â We can also express this with another quantity called R,

Â not surprisingly, it's something to do with the square root of R squared.

Â Ironically though, R squared is always written with a capital R and r,

Â this quantity, is always written with a lower case r, but they are related.

Â What r is, is essentially the square root of R squared, but with a catch.

Â It's the proper sign R squared.

Â Technically speaking, the square root of R

Â squared has two potential values, r or negative r.

Â And the sign comes into play,

Â because it will tell us about the direction of the relationship.

Â R squared is always a positive number.

Â There's no information in this number about whether y tends to

Â increase with increasing x, or y tends to decrease.

Â But r or the square root of R, with that sign appended to it,

Â gives us information about the direction.

Â r is called the correlation coefficient, not to be confused with

Â regression coefficients, which are our slope and our intercepts.

Â So these are great names, huh?

Â They're not [LAUGH] very distinctive, but

Â correlation coefficient refers to this value.

Â r is just the transformation of R square.

Â In the grand scheme of things, 0, R square is between 0 and 1.

Â If there's no added information in x1, then R squared will be close to 0.

Â The close, the points don't get any closer to the regression line

Â that uses x1 than they do to a flat line giving the overall mean y.

Â If the points all line up perfectly on a line, R squared would be 1.

Â But that's not going to happen in real life where there's biological,

Â sociological and other variability in the measures we're looking at.

Â R squared could be negative or positive.

Â If the relationship between y and

Â x1 is positive, then the corresponding value of r, which will be

Â the positive square root of R squared and it will also be between 0 and 1.

Â If the corresponding relationship between y and x1 is negative however, r will

Â be the negative square root of R squared and it will range from negative 1 to 0.

Â Negative 1 would be, mean perfect negative correlation.

Â Then all of the points, individual values lined up on a line with decreasing slope.

Â r would be higher in absolute value than R squared.

Â So in this example, r would be the positive square root of the R squared

Â value we got of 0.46 because we observed the positive slope, the relationship

Â between arm circumference and height is positive and r is equal to 0.68.

Â So, from this example, child's height explains an estimated 46% of

Â the variation in the arm circumferences.

Â And this, of course, is just an estimate based on the sample.

Â If we wanted to actually account for

Â the uncertainty in our estimated amount of variation explained at

Â the population level, we'd have to put a 95% confidence interval on this.

Â Unfortunately, that's not an easy thing to do and the procedures we have for

Â it is not so good.

Â So, a lot of times when this measure is reported in the literature,

Â unlike other quantities, there will be no information about the uncertainties.

Â So just know that when you see it.

Â It's not the truth, it's just an estimate.

Â [SOUND] So one way to think about this is well,

Â there's still 54% of the original variability in

Â arm circumferences not being explained by taking into account child's height.

Â So some of this remainder left over variability may be explained by

Â other factors above and beyond height.

Â So we'll soon talk about expanding the regression to

Â include more than one predictor.

Â And this will allow us to see if we can even better explain the variability in

Â the outcome y by taking into account more than one predictor in the single model.

Â Let's give another example.

Â If you go back and look at that hemoglobin impact cell volume example we did.

Â If you computed the R squared or the computer did, it's equal to 0.51.

Â So packed cell volume explains an estimated 51% of

Â the original variation in individual hemoglobin levels in the sample.

Â If it was a positive association, so if we compute the correlation coefficient,

Â it's just the positive square root of 0.51 which is 0.71.

Â Correlation coefficient doesn't have as easy to interpret a physical

Â interpretation, but higher absolute values mean stronger correlation and

Â more variability being explained by the predictor.

Â Here's another example we looked at, wages and years of education.

Â And the R squared here is substantially lower than the previous two examples.

Â It's on the order of 0.15 or 15%.

Â The corresponding correlation coefficient is the positive square

Â root of that 15, 0.15 or about 0.4, 0.39.

Â Even when we're comparing means between two groups and we get a mean difference

Â estimate, a confidence interval, and a p value just like we did with the t-test,

Â is with the regression approach, the computer will also give us this R squared,

Â even when we have a binary predictor.

Â And so, if we looked at the R squared value for

Â arm circumference as a function of sex, it comes in at 0.042 or 4.2%.

Â So this means that sex explains about 4.2% of the variation, individual variation,

Â original variation arm circumference.

Â You may recall when we looked at the box plots of the distributions of

Â the arm circumference values for males relative to females,

Â there was a lot of shared values in the two box plots.

Â But the percentiles, median 25th and 75th, for

Â females were shifted slightly lower than males.

Â And we estimated a small mean difference between the two.

Â So that means that, you know,

Â the amount of variability explained by sex is minimal, and this R squared is 4.2%.

Â The corresponding correlation coefficient when x is coded as a 1 for females and

Â 0 for males, is negative square root of that R squared, because there's

Â a negative association between arm circumference and the female sex.

Â If we had coded sex in the opposite direction, the R squared value would

Â be exactly the same, 0.042, but the r value we get would be 0.20.

Â Because we'd be associating arm circumferences males compared to

Â females and males have slightly higher arm circumference.

Â So what? You might think [LAUGH] well, you know,

Â some of these R squared values are large, some aren't.

Â You know, what is a good R squared?

Â There's a couple of important things to keep in mind about these two quantities.

Â First of all, these are estimates based on the sample of data and

Â they're frequently reported without some recognition of sampling variability.

Â So, you just have to think that there's uncertainty in

Â the estimates that are reported, and it will not be accompanied by

Â something like a confidence interval as it would be with a slope, for example.

Â But here's the thing, low R squared and hence r, are not necessarily bad.

Â Many outcomes, especially in medicine and public health, sociology and such,

Â can not or will not be fully or close to fully be explained in terms of variability

Â by any one single predictor, or by any set of multiple predictors for that matter.

Â And this is really important for me to highlight actually,

Â that a lower R squared enhanced absolute value of r is not a non finding.

Â Sometimes when people see these values they think that a lower association level

Â is not indicative with an important association.

Â But many phenomenon in public health and medicine cannot be easily or

Â completely be explained by any one factor or multiple factors for that matter.

Â However, the trends we'd see are important enough to

Â influence medical practice decisions and policy decisions, et cetera.

Â The higher the R squared values you can think of, the better x1 predicts y for

Â individuals in the sample, as well as the population,

Â as individual y-values vary less about their estimated mean based on x1.

Â So this gives us more information about who will benefit, if you will, or

Â suffer from the increased exposure of x1, when the R squared is high.

Â But many times, there's, there may be important overall associations between

Â the mean and y and x1 trends, if you will.

Â Even though, there's still a lot of individual variability in

Â the y-values about their means estimated by the predictor.

Â So, for the example, in the wages example, years of an education explain

Â an estimated 15% of the variability in the hourly wages.

Â The association was statistically significant showing that

Â average wages were greater for portions with more years of age.

Â However, for any single education level, measured by years of education,

Â there's still a fair amount of variation in wages for individual workers.

Â So I can advise that more education is associated with

Â an average increase of wages, but it's hard to guaranteed that any

Â single person will experience an increase in wages, if they get more education.

Â What about slope versus R square?

Â Let's come back to that now.

Â Slope estimates the magnitude of the direction of

Â the association between y and x1.

Â It estimates a mean difference in y for two groups who differ by one unit next.

Â The slope will change if the units change for y and or for our predictor x.

Â And because of this, because the, the size of the slope, the absolute value of it.

Â Is totally affected by our choice of units.

Â Larger slopes,

Â therefore are not indicative of stronger relative to smaller slopes, and smaller

Â slopes are not indicative in weaker linear association relative to larger slopes.

Â The size of the slope is a function of the units we use.

Â R squared and hence r measures the strength of the linear association, and

Â r also includes information about the direction.

Â Neither of these two measures the magnitude,

Â how much the average y differs by one unit of x.

Â And neither R squared or r changes with changes in units.

Â So it's invariant to the choice of units.

Â Because when we change the units,

Â we're not changing anything about the strength of the relationship,

Â just how we quantify the association.

Â If you have r, you can compute R squared simply by taking r and squaring it.

Â If you have R squared, you can almost compute r.

Â But if all you have is R squared, you won't know what sign to assign r.

Â So you need to see a scatterplot, you need to see the regression slope estimate or

Â something that tells you about the direction of the association.

Â R is useful however, even though it doesn't have as

Â easy to pull off a physical interpretation as R squared.

Â Like we said, if you have r, you can get R squared to get a sense of

Â how much variability and one thing is explained by the other.

Â But it's really nice summary measure when we're comparing sets of variables.

Â For example, in a paper and we just want to show how strongly associated pairs of

Â variables are and include information about the direction of the magnitude.

Â So if I was writing a paper on anthropometric associations in Nepali

Â children, I might first present a table like this, where I have age, weight,

Â height and arm circumference in both the rows and columns of this table.

Â And wherever two of them intersect, it gives the correlation between the two,

Â the r value.

Â So, this not only tells me about the relative strength of

Â the linear association, it tells me the sign of it.

Â So for example, not surprisingly, weight and age are positively

Â correlated to a relatively high degree, height and age even more so.

Â Sex, which is in this case, coded as a 1 for females and 0 for

Â males, is negatively associated with weight and height, but

Â to a smaller degree than the other correlations.

Â And this just tells me that females have lower average weight and height values,

Â but there's a fair amount of variation in these values between the two sexes.

Â So in summary, R squared measures the strength of

Â association between a continuous outcome and a predictor in a linear regression

Â format by comparing the variability of the points around the regression line.

Â And remember, even with a binary predictor, there is a regression line.

Â There's just two points on it to the variability in

Â y-values ignoring that predictor.

Â The correlation coefficient r is the properly signed square root of R squared,

Â and hence provides information about the direction of the association as well.

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