Presentation is loading. Please wait.

Presentation is loading. Please wait.

Multiple Regression III 4/16/12 More on categorical variables Missing data Variable Selection Stepwise Regression Confounding variables Not in book Professor.

Similar presentations


Presentation on theme: "Multiple Regression III 4/16/12 More on categorical variables Missing data Variable Selection Stepwise Regression Confounding variables Not in book Professor."— Presentation transcript:

1

2 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

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

4 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)

5 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)

6 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

7 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

8 Smokers

9 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

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

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

12 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

13

14

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

16 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

17 Full Model

18 Pruned Model 1

19 Pruned Model 2

20 Pruned Model 3

21 Pruned Model 4

22 Pruned Model 5

23 FINAL STEPWISE MODEL

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

25 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?

26 Electricity and Life Expectancy

27 Outlier: Iceland

28 Electricity and Life Expectancy

29

30 Is this a good model for predicting life expectancy based on electricity use? (a) Yes (b) No

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

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

33 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

34 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.

35 Which is the “best” model? (a) (b) (c)

36 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? Cell Phones and Life Expectancy

37

38

39

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

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

42 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 Cell Phones and Life Expectancy

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

44 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

45 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


Download ppt "Multiple Regression III 4/16/12 More on categorical variables Missing data Variable Selection Stepwise Regression Confounding variables Not in book Professor."

Similar presentations


Ads by Google