1 / 44

Multiple Regression III 4/16/12

Multiple Regression III 4/16/12. More on categorical variables Missing data Variable Selection Stepwise Regression Confounding variables. Not in book. Professor Kari Lock Morgan Duke University. To Do. Project 2 Presentation (Thursday, 4/19) Project 2 Paper (Wednesday, 4/25).

reece
Download Presentation

Multiple Regression III 4/16/12

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Multiple Regression III • 4/16/12 • More on categorical variables • Missing data • Variable Selection • Stepwise Regression • Confounding variables Not in book Professor Kari Lock Morgan Duke University

  2. To Do • Project 2 Presentation (Thursday, 4/19) • Project 2 Paper (Wednesday, 4/25)

  3. Categorical Variables • Models are estimated better with fewer coefficients to estimate • A categorical variables requires estimating a coefficient for each category (minus 1) • Unless you have a very large sample size, refrain from including categorical variables with lots of categories (or else group the categories)

  4. Categorical Variables • Sometimes, categorical variables are coded with numbers • If this is the case, R will interpret it as a quantitative variable, not a categorical variable • To make sure it is treated like a categorical variable, BEFORE attaching the data use • dataname$variablename = as.factor(dataname$variablename)

  5. Missing Data • If a cases has missing data for any of the explanatory variables, it will be left out of the regression • If there is lots of missing data, your sample size could be greatly reduced • Consider leaving out variables with lots of missing data, especially if your sample size is small to begin with

  6. Missing Data • If the proportion of cases with missing data is small, then you do not have much to worry about • If there are lots of missing values, you could get a completely wrong answer by just leaving those cases out • Simply ignoring missing data can be very dangerous, but dealing with it appropriately requires another course in statistics • In life after STAT 101, if you want to analyze a dataset with lots of missing data, consult with a statistician

  7. Smokers

  8. Smokers • If smoking was banned in a state, the percentage of smokers would most likely decrease. • In that case, the percentage voting Democratic would… • (a) increase • (b) decrease • (c) impossible to tell

  9. Causation • A significant explanatory variable in a regression model indicates association, but not necessarily causation • CAUSALITY CAN ONLY BE INFERRED FROM A RANDOMIZED EXPERIMENT!!!!

  10. Causation http://www.dilbert.com/strips/comic/2011-11-28/

  11. Variable Selection • The p-value for an explanatory variable can be taken as a rough measure for how helpful that explanatory variable is to the model • Insignificant variables may be pruned from the model • You can also look at relationships between explanatory variables; if two are strongly associated, perhaps both are not necessary

  12. Variable Selection (Some) ways of deciding whether a variable should be included in the model or not: Does it improve adjusted R2? Does it have a low p-value? Is it associated with the response by itself? Is it strongly associated with another explanatory variables? (If yes, then including both may be redundant) Does common sense say it should contribute to the model? What would you eliminate from the model? (handout)

  13. Stepwise Regression • We could go through and think hard about which variables to include, or we could automate the process • Stepwise regression drops insignificant variables one by one • This is particularly useful if you have many potential explanatory variables

  14. Full Model

  15. Pruned Model 1

  16. Pruned Model 2

  17. Pruned Model 3

  18. Pruned Model 4

  19. Pruned Model 5

  20. Pruned Model 5 FINAL STEPWISE MODEL

  21. Project 2 • For project 2, I recommend doing variable selection both ways: • manually choose which variables to include based on p-values, pairwise relationships, and common sense • use stepwise regression • and then choose between these two models

  22. Electricity and Life Expectancy • Cases: countries of the world • Response variable: life expectancy • Explanatory variable: electricity use (kWh per capita) • Is a country’s electricity use helpful in predicting life expectancy?

  23. Electricity and Life Expectancy

  24. Electricity and Life Expectancy Outlier: Iceland

  25. Electricity and Life Expectancy

  26. Electricity and Life Expectancy

  27. Electricity and Life Expectancy • Is this a good model for predicting life expectancy based on electricity use? • (a) Yes • (b) No

  28. Electricity and Life Expectancy • Is a country’s electricity use helpful in predicting life expectancy? • (a) Yes • (b) No

  29. Electricity and Life Expectancy • If we increased electricity use in a country, would life expectancy increase? • (a) Yes • (b) No • (c) Impossible to tell

  30. Confounding Variables • Wealth is an obvious confounding variable that could explain the relationship between electricity use and life expectancy • Multiple regression is a powerful tool that allows us to account for confounding variables • We can see whether an explanatory variable is still significant, even after including potential confounding variables in the model

  31. Electricity and Life Expectancy • Is a country’s electricity use helpful in predicting life expectancy, even after including GDP in the model? • (a) Yes (b) No Once GDP is accounted for, electricity use is no longer a significant predictor of life expectancy.

  32. Which is the “best” model? • (a) • (b) • (c)

  33. Cell Phones and Life Expectancy • Cases: countries of the world • Response variable: life expectancy • Explanatory variable: number of mobile cellular subscriptions per 100 people • Is a country’s cell phone subscription rate helpful in predicting life expectancy?

  34. Cell Phones and Life Expectancy

  35. Cell Phones and Life Expectancy

  36. Cell Phones and Life Expectancy

  37. Cell Phones and Life Expectancy • Is this a good model for predicting life expectancy based on cell phone subscriptions? • (a) Yes • (b) No

  38. Cell Phones and Life Expectancy • Is a country’s number of cell phone subscriptions per capita helpful in predicting life expectancy? • (a) Yes • (b) No

  39. Cell Phones and Life Expectancy • If we gave everyone in a country a cell phone and a cell phone subscription, would life expectancy in that country increase? • (a) Yes • (b) No • (c) Impossible to tell

  40. Cell Phones and Life Expectancy • Is a country’s cell phone subscription rate helpful in predicting life expectancy, even after including GDP in the model? • (a) Yes (b) No

  41. Cell Phones and Life Expectancy • This says that wealth alone can not explain the association between cell phone subscriptions and life expectancy • This suggests that either cell phones actually do something to increase life expectancy (causal) OR there is another confounding variable besides wealth of the country

  42. Confounding Variables • Multiple regression is one potential way to account for confounding variables • This is most commonly used in practice across a wide variety of fields, but is quite sensitive to the conditions for the linear model (particularly linearity) • You can only “rule out” confounding variables that you have data on, so it is still very hard to make true causal conclusions without a randomized experiment

More Related