1. Home
  2. Explore
  3. Statistics
  4. Regression Diagnostics

Study methods

Flashcards
Quiz
Fill in the blanks
Written test
Lesson
Notes
Podcast
Content

Regression Diagnostics

Transcript

Lecture 9: Regression Assumptions and Diagnostics By the end of this lecture, you should be able to: Know how to identify heteroskedastic errors Know how to interpret a logged independent variable Know how to interpret interactive effects Know how to identify and deal with autocorrelation Know how to identify and deal with multicollinearity Recall that the equation for a regression equation is: dependent variable-hat plus b-hat times the independent variable plus a-hat plus e-hat.

Remember that e-hat equals the actual value of our dependent variable for an individual observation minus the estimate of our dependent variable for that observation. Now, after calculating all of our errors for a particular regression model, if we take the mean of those errors, the average should be 0. Why? Because our regression models assume we perfectly estimate our dependent variable on average. Now, our regression models will overestimate and underestimate particular observations,

but all of those over estimations and under estimations will cancel each other out, leading to an average error of 0. What is very important to note, however, is that even though the math always works out and we always get an average error of 0, we shouldn’t necessarily be confident in our results. When we use ordinary least squares regression, the regression model assumes that we have included every single relevant independent variable in our model. And as a result, that all of our independent variables collectively help us perfectly predict our dependent variable. And if our model makes an error in predicting, we assume that error is random. Something happened for a particular observation that was a random event that changed the value of the dependent variable. For example, let’s say we’re running a model, using survey data, where we use party identification as the dependent variable and income as the independent variable.

For one particular observation, the survey respondent accidently choose the wrong answer for their income because they took the survey too quickly. For that particular observation, the model might incorrectly predict that respondent’s party identification because they gave the wrong information about their income. This is a random error. It is not something that happens to every respondent. Regression allows for random error like this. Our course, we never have perfect models. We never have every single independent variable in our models. As a result, our errors are not random. Our errors because predictable for certain observations. This leads us to the second assumption of regression: Homoskedasticity. This means that we assume that the variance of the error term is the same across all values of our independent variables. This picture shows illustrates a model that meets the assumption of homoscedasticity.

In this model, Savings on the y-axis here is the dependent variable and Income is the independent variable. These lines here represent different values of income. And these normal curves here represent the distribution of the errors for observations at these different income levels. So, the regression model made predictions for observations at these different levels of income, here, here, and here- and the errors here are just the difference between the actual

value of savings and the estimated savings from the model. The mean of all of these errors should be 0. And the errors are distributed in a similar pattern across these values. They all are distributed like a normal curve. Most often, our regression models violate homoskedaticity. When we violate homoscedasticity, we call it hetereoskedacity. This just means that the variance of the error term is not the same across all values of our independent variable.

Substantively, this means that our model estimates our dependent variable better at some values of our independent variable and worse at other values of our independent variable. This picture shows illustrates a model that is heteroskedastic. In this model, Savings is the dependent variable and Income is the independent variable. These lines here represent different values of income. And these curves here represent the distribution of the errors for observations at these different income levels. So, the regression model made predictions for observations at these different levels of income, here, here, and here- and the errors are just the difference between the actual value of savings and the estimated savings from the model. Now, the mean of all of these errors should be 0. But the errors are distributed in a different pattern across these values. The regression model is really good at predicting savings when income is low, as illustrated by this thin distribution here.

Most of the errors are close to 0. On the other hand, the regression model does a poor job at predicting savings when income is high, as illustrated by this flat distribution here. Most of the errors are larger and far away from 0. Heteroskedacity is a problem. We don’t want it in our regression models. While our coefficients, b-hat, should be close to predicting the true coefficient b, between our independent and dependent variables, our model is inefficient.

Our estimates are less precise, meaning our error is larger. And if our error is larger, we are less likely to get significant results and our R-square is reduced. So, now I am going to show you how to test for Hetereoskedacity in SPSS. But you don’t need to know how to do this in SPSS for the exam. I just want you to know how to do it, so that is why I am showing you. The first step is running the regression model. The second step is calculating the estimates. You did this in Lecture 8. The third step is calculating the errors. You do, Transform, Compute. Then you type SqErrors in the target variable box. Then you type in the “Numeric Expression” box you type, Open parentheses- name of the dependent variable (which is the name SPSS gives it) minus open parentheses Estimate, close parentheses, close parentheses, star star 2. The double star tells SPSS to square your variable. Make sure to use the correct variable names that SPSS uses in the Numeric Expression box

and do not include any spaces in your equation. Then you graph the squared errors on the y-axis against the independent variable on the x-axis. Remember to run graphs, you run, Graphs, Legacy Dialog, Scatter/Dot, Simple Scatter. Put the square errors on the y-axis and the independent variable on the x-axis. The last step is to inspect the graph. So imagine I expect education to have a positive effect on income.

I ran a model in SPSS with education as the independent variable and income as the dependent variable. Then I created estimates. In SPSS, I ran Transform, Compute. Then I called the variable Estimate. The equation was 0.267 times Education plus 3.741. Then I created the errors. In SPSS, I ran Transform, Compute. Then I called the variable SqError. The (equation was Open parentheses- Income1 (which is the name SPSS gives it) minus open

parentheses Estimate, close parentheses, close parentheses, star star 2. Then I graphed them. In SPSS, I choose Graphs, Legacy Dialogs, Scatter/Dot, Simple Scatter. I put the SqErrors on the y-axis and education on the x-axis since it was the independent variable. As you can see from this graph, the errors across education are not random. The errors are larger at low levels of education. And they follow a cyclical pattern.

One obvious way to deal with hetereoskedacity is to add additional independent variables to your models. It is possible that there are key independent variables that should be included in the regression model to make it make better predictions. And if it makes better predictions, the errors should be smaller. Leaving them out leaves out important information, would could lead to errors like this. So, imagine that education wasn’t the only independent variable that should have an impact on income. Age could as well. Older people should have more income than younger people. So I ran a new regression model in SPSS. I had income as the dependent variable and education and age as the independent variables. I then created estimates, holding age constant, and created the squared errors. Then I plotted the square errors against education. As you can see from this graph of the original regression model with education as the only

independent variable, the errors across education are not random. The errors are larger at low levels of education and they follow a cyclical pattern. This is a graph of the errors from the new model. As you can see, these errors are a little bit better. Education is not correlated with the errors. With one exception, the squared errors are evenly distributed between 0 and 100 across all values of education.

Now I am going to talk about another reason we get heteroskedacity- when we run our models, we assume that our independent variables have a linear effect on our dependent variable. In other words, we assume that the effect of our independent variable on our dependent variable is the same across all values of the independent variable. This assumption is called “Linear in the Parameters,” which means that our b-hats are the same across all values of the independent variable. It does not change.

Or, in other words, the effect of our independent variable on our dependent variable is the same across all values of the independent variable. However, we may have a theoretical reason to believe that our independent variable does not have a linear effect on our dependent variable. Instead, we might, for example, think our independent variable has a positive logged effect on our dependent variable. If that is the case, we think that at lower levels of our independent variable, the effect of our independent variable on our dependent variable is strong. A small change in our independent variable leads to a large change in our dependent variable. But at higher levels of our independent variable, the effect of our independent variable on our dependent variable is weak. A small change in our independent variable results in a small change in our dependent variable. We can account for this logged effect in our regression models. We do it by transforming the independent variable.

We natural log the independent variable and then run a regression. To do this in SPSS, we do Transform, Compute. Then you type LogX in the target variable box. Then you type in the “Numeric Expression” box you type, LN open parentheses, name of your independent variable, close parentheses. Make sure to use the correct variable names that SPSS uses in the Numeric Expression box and do not include any spaces in your equation. Then we run a regression with the logged variable as the independent variable. The model is Dependent Variable-hat equals b-hat times the logged independent variable plus a-hat. So imagine I expect education to have a positive effect on income, but I expect it to be a logged effect. In SPSS, I do Transform, Compute. I typed LogX in the target variable box. Then I typed in the “Numeric Expression” box you type, LN open parentheses, education, close parentheses. Then I ran the regression.

I put income1 as my dependent variable and LogX as my independent variable. Here are the results. Recall that the original model that had education as the independent variable. These are the squared errors. Clearly, there is a pattern in these errors. There are larger at smaller levels of education. Here are the squared errors from the new model with education logged as the independent variable. Note that I am plotting these errors against Education, not education logged.

As you can see, these errors no longer have a pattern. Since we correctly identified that education should have a logged effect on income and accounted for it in our model, the errors are no longer heteroskedastic. They’re random now. It is important to note that we have to interpret the coefficients for our logged independent variables differently than the coefficients for regular independent variables. When we interpret the coefficients, we say that when our independent variable changes

by 1%, our dependent variable changes by b-hat*0.01. So if our b-hat is 3.019, we say, when Education changes by 1%, Income changes by 0.3019*0.01 or 0.0319. Next, there are other ways our independent variables can have a non-linear effect on our dependent variables. For example, the effect of one independent variable on our dependent variable may depend on the level of another independent variable. So, for example, imagine X1 and X2 are our independent variables and Y is our dependent variable.

The effect of X1 on Y is positive when X2 is 0 and negative when X2 is 1. So the effect of X1 on Y depends on the level of X2. This is known as an interactive effect. This is what an interactive effect model would look like. Dependent variable hat equals b1 times the first independent variable plus b2 times the second independent variable plus b3 times the interactive variable plus a-hat. Note that the interactive variable here is the product of the first and second independent variables.

So, I will briefly explain how to interpret interactive effects. The b1 of the first independent variable is the effect of the first independent variable when the second independent variable is 0. B1 times the first independent variable plus b2 times 0 plus b3 times the first independent variable times 0 results in b1 times the first independent variable because these terms here and here drop out. Now, if b1 is significant, that means that the first independent variable has a significant

impact on the dependent variable when the second independent variable is 0. You should note this effect in your interpretation. Alternatively, if b1 is insignificant, that means that the first independent variable does not have a significant impact on the dependent variable when the second independent variable is 0. Next, the b2 of the second independent variable is the effect of the second independent variable when the first independent variable is 0.

B1 times 0 plus b2 times the second independent variable plus b3 times 0 times the second independent variable results in b2 times the second independent variable because these terms here and here drop out. Now, if b2 is significant, that means that the second independent variable has a significant impact on the dependent variable when the first independent variable is 0. You should note this effect in your interpretation.

Alternatively, if b2 is insignificant, that means that the second independent variable does not have a significant impact on the dependent variable when the first independent variable is 0. In order to run an interactive effects models in SPSS, you have to start by making the interactive term. To do this in SPSS, we do Transform, Compute. Then you type Interactive in the target variable box. Then you type in the “Numeric Expression” box you type, the first independent variable name times the second independent variable name. Make sure to use the correct variable names that SPSS uses in the Numeric Expression box and do not include any spaces in your equation. Then we run a regression with the interactive variable as the independent variable. The model is Dependent Variable-hat equals b-hat 1 times the first independent variable plus b-hat 2 times the second independent variable plus b-hat 3 times the interactive variable plus a-hat.

So imagine I believed that both education and gender influence income. But I think their effects on income depend on one another. They don’t independently influence income. They jointly influence income. So I need to use a model with an interactive term. The first step is to create the interactive term. To do this in SPSS, I did Transform, Compute. Then I typed Interactive in the target variable box. Then I typed in the “Numeric Expression” box Education times gender.

Then I ran a regression with income as the dependent variable and education, gender, and the interactive variable as the independent variables. Here are the results. So the first step in interpreting this model is writing out the equation. It is 50 times education minus 730 times gender plus 280 times interactive plus 100. The next step is to interpret the individual variables. I will start with Education. As you can see, Education’s coefficient is not significant.

This tells me that when gender is 0, or when only looking at men, Education has no effect on income. So we know education does not have an effect on men’s income? But what about women’s income? We could calculate that effect. Instead of making gender 0 in this model, let’s make it 1. We get 50 times education minus 730 times one plus 280 times 1 times education plus 100. This equals 50 times education minus 730 plus 280 times education plus 100.

We could simplify this equation by combing 50 times education and 280 times education, which gives us 330 times education. We could also combine -730 and 100, which gives us 630. So the effect of Education on Income for women is 330. But is this effect statistically significant? We actually can’t tell from SPSS’s output. Recall that when we determine if a coefficient is significant, we use a t-test. The t-test is just b divided by the standard error of b.

Normally, this equation here gives us the standard error of b. Unfortunately, the equation for the standard error of two combined is different. This is the standard error of the coefficients b1 and b3. And this is the standard error of the coefficients b2 and b3. Since these standard errors are different, and since SPSS doesn’t realize that these standard errors are different, then we cannot use the significant tests in SPSS because it assumes this is the standard error, not this or this.

Of course, when we set one variable equal to 0, the standard error is this here since we are only looking at one variable. So, at first it may seem like a lot of work to look at the significance of an interactive variable across multiple values of the other interactive variable. But it’s actually not a lot of work. There is an easy way to do it in SPSS. You can 0 center one of the variables at a key value of the variable, create a new interactive term, and run a new regression model.

So let’s say I wanted to know the effect of Education on women’s income. Remember that in the original model, Gender equaled 0 for men and 1 for women. I created a new Gender variable, called Gender2, which flipped the Gender variable. So 0 was for women and 1 was for men. Then I created a new interactive variable which was the product of Gender2 and Education. Then I ran a regression model with Income1 as the dependent variable, and new Gender2

variable, the education variable, and the new interactive variable as independent variables. Here are the results. Recall from our original model, we said that Education would have a b-hat of 330 for women. As you can see, SPSS calculated a coefficient of 330 for women in this model. And it’s significant at the 0.001 level. So, based off the model for Men and the model for women I can conclude: There is no evidence to suggest that education influences men’s income.

On the other hand, there is evidence that it affects women’s income. The education variable was positive and significant for women at the 0.001 level. All else equal, as education increases by 1, income increase by 330 for women. Note that in my interpretation I was clear that for men there was no evidence that education affected income, but for women, it did. So we’ve interpreted the Education variable. What about the gender variable?

In this table, it tells us that when education is 0, gender has no effect on income when education is 0, since gender is not statistically significant. But what happens when education is at a high level? Then does Gender have a significant effect on income? To figure this out, I have to 0 center education at its highest level. So it’s highest level is 9. So if I create a new education variable called Education9, and I calculated it as Education

minus 9, the new variable will equal 0 when Education is 9. Then I have to create a new interactive variable which is the product of Education9 and Gender. Then I run a regression with Income as the dependent variable, Education9, Gender, and the new interactive variables as independent variables. Here are the results…. So, based on my results, I can say that there is no evidence to suggest that gender has an influence on income at low levels of education.

But at higher levels of education, gender has a positive impact on income. The coefficient was significant at the 0.001 level. All else equal, women earn 2520 more than men at high levels of education. Note that when I interpreted these results, I indicated what level education was at. Next, the 4th assumption of ordinary least squares regression deals with time series models, where we have multiple observations for our subjects over time.

In these models, we assume that the error term is not correlated with time. Alternatively, we assume that the value of our dependent variable in one time period is not correlated with the value of our dependent variable in a previous time period. When we violate this assumption, it is called autocorrelation. The error term is correlated with time. It is not random. So imagine we ran a model that used Japan’s Defense Spending as a Percentage of GDP as the dependent variable. This is a time series model because we are looking at Japan’s defense spending over time. In this model, US troop deployments as the independent variable. As you can see from this equation, as the number of US troops in Japan increases, Japan’s defense spending decreases. Now, since this is a time series model, we need to assess whether the errors are correlated with time. So now I am going to show you how use SPSS to determine if a regression model’s errors are correlated with time.

The first step is to run the regression model. The second step is to calculate the estimates. You run Transform, Compute. You type “Estimates” in the Target Variable box. Then you type your regression equation into the numeric expression box. Unlike in Lecture 8, in this equation, you’re not holding any of the variables constant. Make sure to use the correct variable names that SPSS uses in the Numeric Expression box and do not include any spaces in your equation. Then click OK. Next, you have to calculate the errors. You do Transform, Compute. You type Errors in the Target Variable box. Then you put your dependent variable name minus Estimates in the Numeric Expression box. Make sure to use the correct variable names that SPSS uses in the Numeric Expression box and do not include any spaces in your equation. Then click OK. Step 4 is to plot the errors against time. So you do, Graphs, Legacy Dialog, Scatter/Dot, Simple Scatter.

You put the Errors on the y-axis and the time variable on the x-axis. Click ok. Then you inspect the graph. So, I followed this process for the model estimating Japan’s defense spending. As you can see from this graph, the errors are correlated with time. There is a clear pattern with these errors. Prior to 1960, the errors are positive. From 1960 to 1980, they are negative. And after 1980, they are positive again. If there wasn’t a pattern, then the errors would be equally likely to be positive or negative throughout this entire graph. Instead, the errors are more likely to be positive here, more likely to be negative here, and more likely to be positive here. So, now that we know we have autocorrelation, how do we deal with it? One way is to create a brand new count variable to include in the model. The variable starts at 0 during the first time unit (in this case, it is 0 in year 1)

and increases by 1 as time goes on. So year 1 would be 0, year 2 would be 1, et cetera. So I ran a new model, with that used Japan’s Defense Spending as a Percentage of GDP as the dependent variable, and US troop deployments as the first independent variable, and a time count variable as the second independent variable. Here are the results. Now to see if the errors have improved. Remember that these are the errors from the original model without the count variable.

Observe the pattern across time. These are the errors from the new model, with the count variable. As you can see, the errors are more random now. Observations are equally likely to be positive or negative regardless of the time period. Now, our new model is superior to our old model because we have taken into account that time influences variations in our dependent variable. But we have to be able to interpret this model before we move on.

So, in to interpret this new variable, we say- all else equal, as time increases by 1, defense spending as a percentage of GDP increases by 0.0003. This is the same way we interpret a regular independent variable in a regression model. Another way to address autocorrelation is to include a lagged dependent variable as an independent variable in your model. You create a lagged dependent variable by taking the value of the dependent variable in one time period and using it as an independent variable value in the next time period. The lagged variable just allows you to determine if the value of the dependent variable in one year influences the value of the dependent variable in the next year. So, in our case, we want to know if Japan’s defense spending in one year influences defense spending in the next year. If we include a lagged dependent variable as an independent variable in our original model, here are the results.

Now to see if the errors have improved. Remember that these are the errors from the original model without the count variable. Observe the pattern across time. These are the errors from the new model, with the count variable. As you can see, the errors are more random now. Observations are equally likely to be positive or negative regardless of the time period. Now, our new model is superior to our old model because we have taken into account that time influences variations in our dependent variable. But we have to be able to interpret this model before we move on. So, in to interpret this new variable, we say- all else equal, as defense spending in the previous year increases by 1, defense spending increases by 0.940. This is the same way we interpret a regular independent variable in a regression model. The last assumption we will talk about is the assumption of no multicollinearity.

With no multicollinearity, we assume that the independent variables are not related to each other. When we violate this assumption, we have multicollinearity in our models. That means that our independent variables are correlated. When this happens, it is almost like we have the same independent variable twice in our model. As a result, we are less likely to get significant results. SPSS cannot tell which independent variable is influencing the dependent variable since they are so similar.

It is super easy to detect multicollinearity in SPSS. All you have to do is run a correlation analysis between your independent variables. If they are highly correlated, then you may have a multicollinearity problem. A simple solution to addressing multicollinearity is leaving one of the highly correlated independent variables out of the model. Alternatively, you can run two models, one with each of the independent variables.

Ask anything

We've read this whole study set, so questions about it get the best answers.

FlashcardsQuizFill in the blanksWritten testLessonNotesPodcastContent