STAT 101 Dr. Kari Lock Morgan 11/27/12 Multiple

Published  . 0 views
↓ Download
STAT 101 Dr. Kari Lock Morgan 11/27/12 Multiple
1 / 1
STAT 101 Dr. Kari Lock Morgan 11/27/12 Multiple - slide 1 of 45 STAT 101 Dr. Kari Lock Morgan 11/27/12 Multiple - slide 2 of 45 STAT 101 Dr. Kari Lock Morgan 11/27/12 Multiple - slide 3 of 45 STAT 101 Dr. Kari Lock Morgan 11/27/12 Multiple - slide 4 of 45 STAT 101 Dr. Kari Lock Morgan 11/27/12 Multiple - slide 5 of 45 STAT 101 Dr. Kari Lock Morgan 11/27/12 Multiple - slide 6 of 45 STAT 101 Dr. Kari Lock Morgan 11/27/12 Multiple - slide 7 of 45 STAT 101 Dr. Kari Lock Morgan 11/27/12 Multiple - slide 8 of 45 STAT 101 Dr. Kari Lock Morgan 11/27/12 Multiple - slide 9 of 45 STAT 101 Dr. Kari Lock Morgan 11/27/12 Multiple - slide 10 of 45 STAT 101 Dr. Kari Lock Morgan 11/27/12 Multiple - slide 11 of 45 STAT 101 Dr. Kari Lock Morgan 11/27/12 Multiple - slide 12 of 45 STAT 101 Dr. Kari Lock Morgan 11/27/12 Multiple - slide 13 of 45 STAT 101 Dr. Kari Lock Morgan 11/27/12 Multiple - slide 14 of 45 STAT 101 Dr. Kari Lock Morgan 11/27/12 Multiple - slide 15 of 45 STAT 101 Dr. Kari Lock Morgan 11/27/12 Multiple - slide 16 of 45 STAT 101 Dr. Kari Lock Morgan 11/27/12 Multiple - slide 17 of 45 STAT 101 Dr. Kari Lock Morgan 11/27/12 Multiple - slide 18 of 45 STAT 101 Dr. Kari Lock Morgan 11/27/12 Multiple - slide 19 of 45 STAT 101 Dr. Kari Lock Morgan 11/27/12 Multiple - slide 20 of 45 STAT 101 Dr. Kari Lock Morgan 11/27/12 Multiple - slide 21 of 45 STAT 101 Dr. Kari Lock Morgan 11/27/12 Multiple - slide 22 of 45 STAT 101 Dr. Kari Lock Morgan 11/27/12 Multiple - slide 23 of 45 STAT 101 Dr. Kari Lock Morgan 11/27/12 Multiple - slide 24 of 45 STAT 101 Dr. Kari Lock Morgan 11/27/12 Multiple - slide 25 of 45 STAT 101 Dr. Kari Lock Morgan 11/27/12 Multiple - slide 26 of 45 STAT 101 Dr. Kari Lock Morgan 11/27/12 Multiple - slide 27 of 45 STAT 101 Dr. Kari Lock Morgan 11/27/12 Multiple - slide 28 of 45 STAT 101 Dr. Kari Lock Morgan 11/27/12 Multiple - slide 29 of 45 STAT 101 Dr. Kari Lock Morgan 11/27/12 Multiple - slide 30 of 45 STAT 101 Dr. Kari Lock Morgan 11/27/12 Multiple - slide 31 of 45 STAT 101 Dr. Kari Lock Morgan 11/27/12 Multiple - slide 32 of 45 STAT 101 Dr. Kari Lock Morgan 11/27/12 Multiple - slide 33 of 45 STAT 101 Dr. Kari Lock Morgan 11/27/12 Multiple - slide 34 of 45 STAT 101 Dr. Kari Lock Morgan 11/27/12 Multiple - slide 35 of 45 STAT 101 Dr. Kari Lock Morgan 11/27/12 Multiple - slide 36 of 45 STAT 101 Dr. Kari Lock Morgan 11/27/12 Multiple - slide 37 of 45 STAT 101 Dr. Kari Lock Morgan 11/27/12 Multiple - slide 38 of 45 STAT 101 Dr. Kari Lock Morgan 11/27/12 Multiple - slide 39 of 45 STAT 101 Dr. Kari Lock Morgan 11/27/12 Multiple - slide 40 of 45 STAT 101 Dr. Kari Lock Morgan 11/27/12 Multiple - slide 41 of 45 STAT 101 Dr. Kari Lock Morgan 11/27/12 Multiple - slide 42 of 45 STAT 101 Dr. Kari Lock Morgan 11/27/12 Multiple - slide 43 of 45 STAT 101 Dr. Kari Lock Morgan 11/27/12 Multiple - slide 44 of 45 STAT 101 Dr. Kari Lock Morgan 11/27/12 Multiple - slide 45 of 45
Description: STAT 101 Dr. Kari Lock Morgan 112712 Multiple Regression SECTION 10.3 Categorical variables Variable selection Confounding variables revisited US States We will build a model to predict the of the state that voted for Obama (out of the

Related Topics

Download Presentation

"STAT 101 Dr. Kari Lock Morgan 11/27/12 Multiple" is the property of its rightful owner. Permission is granted to download and print the materials on this website for personal, non-commercial use only, and to display it on your personal computer provided you do not modify the materials and that you retain all copyright notices contained in the materials. By downloading content from our website, you accept the terms of this agreement.

Presentation Transcript

slide1. STAT 101
Dr. Kari Lock Morgan
11/27/12 Multiple Regression SECTION 10.3
Categorical variables
Variable selection
Confounding variables revisited<br>
slide2. US States We will build a model to predict the % of the state that voted for Obama (out of the two party vote) in the 2012 US presidential election, using the 50 states as cases
Sample? Population?
This can help us to understand how certain features of a state are associated with political beliefs<br>
slide3. Categorical Variables For this to make any sense, each x value has to be a number.
How do we include categorical variables in a regression setting?<br>
slide4. Categorical Variables Take one categorical variable, and replace it with several “dummy” variables
A dummy variable is 1 if the case falls into the category represented by the dummy variable, and 0 otherwise
Create one dummy variable for each category of the categorical variable<br>
slide5. Dummy Variables<br>
slide6. Dummy Variables When using dummy variables, one has to be left out of the model
The dummy variable left out is called the reference level
When using region of the country (Northeast, South, Midwest, West) to predict % Obama vote, how many dummy variables will be included?
One b) Two c) Three d) Four There are four categories, but one is left out as the reference level<br>
slide7. Dummy Variables Predicting % vote for Obama with one categorical variable: region of the country
If “midwest” is the reference level:<br>
slide8. Voting by Region Based on the output above, which region had the highest percent vote for Obama?
Midwest
Northeast
South
West<br>
slide9. Voting by Region What is the predicted % Obama vote for a state in the northeast?
13%
47%
55%
60% .4697 + 0.1309(1) + 0 + 0 = 0.60<br>
slide10. Voting by Region What is the predicted % Obama vote for a state in the midwest?
50%
47%
0%
45% 0.4697 + 0 + 0 + 0<br>
slide11. Categorical Variables The p-value for each dummy variable tests for a significant difference between that category and the reference level
For an overall p-value for the significance of the categorical variable with multiple categories, use
z-test
T-test
Chi-square test
ANOVA Quantitative response, categorical explanatory with multiple categories<br>
slide12. Categorical Variables ANOVA for Regression: ANOVA for Difference in Means:<br>
slide13. Categorical Variables in R R automatically creates dummy variables for you if you include a categorical explanatory variable
The first level alphabetically is usually the reference level
If you want to change the reference level, see me<br>
slide14. Categorical Variables Either all dummy variables associated with a categorical variable have to be included in the model, or none of them
RegionS and RegionW are not significant, but leaving them out would clump the South and the West with the reference level, Midwest, which does not make sense<br>
slide15. Regression Model<br>
slide16. West Region With only region as an explanatory variable, interpret the positive coefficient of RegionW.

With all the other explanatory variables included, interpret the negative coefficient of RegionW. In this data set, states in the West voted more for Obama than states in the Midwest. States in the West voted less for Obama than would be expected based on the other variables in the model, as compared to states in the Midwest.<br>
slide17. Smoking Given all the other variables in the model, states with a higher percentage of smokers are more likely to vote
(a) Republican
(b) Democratic
(c) Impossible to tell The coefficient is positive, so the % Obama vote is lower in states with a higher percentage of smokers<br>
slide18. Smoking The correlation between percent of people smoking in a state and the percent of people voting for Obama in 2012 was
(a) Positive
(b) Negative
(c) Impossible to tell This only tells you the relationship given the other variables in the model.<br>
slide19. 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 We cannot make conclusions about causality from observational data.<br>
slide20. Causation A significant explanatory variable in a regression model indicates association, but not necessarily causation

CAUSALITY CAN ONLY BE INFERRED FROM A RANDOMIZED EXPERIMENT!!!!<br>
slide21. Goal of the Model? If the goal of the model is to see what and how each variable is associated with a state’s voting patterns, given all the other variables in the model, then we are done
If the goal is to predict the % of the vote that will be for the democrat, say in the 2016 election, we want to prune out insignificant variables to improve the model<br>
slide22. 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, as long as adjusted R2 doesn’t go down too much
You can also look at relationships between explanatory variables; if two are strongly associated, perhaps both are not necessary<br>
slide23. 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?<br>
slide24. Full Model Highest p-value<br>
slide25. Pruned Model 1 Highest p-value<br>
slide26. Pruned Model 2 Highest p-value<br>
slide27. Pruned Model 3 Highest p-value<br>
slide28. Pruned Model 4 Highest p-value<br>
slide29. Pruned Model 5 Highest p-value<br>
slide30. Pruned Model 6<br>
slide31. Pruned Model 5<br>
slide32. Pruned Model 7<br>
slide33. Pruned Model 5 FINAL STEPWISE MODEL<br>
slide34. Full Model<br>
slide35. Variable Selection There is no one “best” model
Choosing a model is just as much an art as a science
Adjusted R2 is just one possible criteria
To learn much more about choosing the best model, take STAT 210<br>
slide36. 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?<br>
slide37. Electricity and Life Expectancy<br>
slide38. Electricity and Life Expectancy Outlier: Iceland<br>
slide39. Electricity and Life Expectancy<br>
slide40. Electricity and Life Expectancy<br>
slide41. Electricity and Life Expectancy Is this a good model for predicting life expectancy based on electricity use?
(a) Yes
(b) No The association is definitely not linear.<br>
slide42. Electricity and Life Expectancy Is a country’s electricity use helpful in predicting life expectancy?
(a) Yes
(b) No The p-value for electricity is significant.<br>
slide43. Electricity and Life Expectancy If we increased electricity use in a country, would life expectancy increase?
(a) Yes
(b) No
(c) Impossible to tell We cannot make any conclusions about causality, because this is observational data.<br>
slide44. Project 2 Part 3: Two Variable Comparisons
Could have been done entirely before Exam 2
Relationships between explanatory variables
Can ignore beauty variables besides bty_avg
Only need to report significant relationships
This is a great part of the project to divvy up
Poster
Regular poster board – can get it at Duke bookstore
Include all components of the project, but up to you what to display from each and how to display it<br>
slide45. To Do Read 10.3
Do Homework 8 (due Thursday, 11/29)
Do Project 2 (poster due Monday, 12/3, paper due 12/6)<br>