analyzing and interpreting continuous predictors · 2020-07-05 · whether the baby is a boy or a...

26
Analyzing and Interpreting Continuous Predictors Sarah Blanchard PRC statistical consultant Department of Sociology [email protected]

Upload: others

Post on 14-Jul-2020

1 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Analyzing and Interpreting Continuous Predictors · 2020-07-05 · whether the baby is a boy or a girl (T/F) All radioactivity is man-made (T/F) The continents have been moving their

Analyzing and Interpreting Continuous Predictors

Sarah Blanchard PRC statistical consultant Department of Sociology

[email protected]

Page 2: Analyzing and Interpreting Continuous Predictors · 2020-07-05 · whether the baby is a boy or a girl (T/F) All radioactivity is man-made (T/F) The continents have been moving their

Overview of today’s talk

• Continuous measures and assumptions in modeling

• Analyzing and Interpreting: – Single level models & centering issues – Interactions with categorical predictors – Interactions with continuous predictors – Predicted probabilities in excel

Models will be logistic regression models and coding will be done in SAS (mostly).

Page 3: Analyzing and Interpreting Continuous Predictors · 2020-07-05 · whether the baby is a boy or a girl (T/F) All radioactivity is man-made (T/F) The continents have been moving their

Continuous predictors

• Definition: Variables that can take on any value within a range.

• Examples: age, income, family size, body mass index, years of education, percent of students receiving free lunch – Interval midpoint: detailed income brackets – Scale/index: depression, financial literacy, physical

limitations, self-efficacy

Page 4: Analyzing and Interpreting Continuous Predictors · 2020-07-05 · whether the baby is a boy or a girl (T/F) All radioactivity is man-made (T/F) The continents have been moving their

Today’s examples

• Trends in the decline in science confidence (1974-2010) – General Social Survey (GSS) – Recoding categorical vars into ordinal, scale – Regression: Confidence in science (scicon, 0-1) – Focal explanatory variables:

• Year (1974-2010) • Years of education (educ, count) • Political ideology (3 categories: conservative, moderate,

liberal)

Page 5: Analyzing and Interpreting Continuous Predictors · 2020-07-05 · whether the baby is a boy or a girl (T/F) All radioactivity is man-made (T/F) The continents have been moving their

Creating an ordinal variable from a categorical variable using midpoints:

Page 6: Analyzing and Interpreting Continuous Predictors · 2020-07-05 · whether the baby is a boy or a girl (T/F) All radioactivity is man-made (T/F) The continents have been moving their

Creating a scale:

Scientific Knowledge

The center of the earth is very hot (T/F)

Does the Earth go around the sun or does the sun go around the earth?

Human beings, as we know them today, developed from earlier species of

animals (T/F)

Electrons are smaller than atoms (T/F)

It is the fathers’ gene that decides whether the baby is a boy or a girl (T/F)

All radioactivity is man-made (T/F)

The continents have been moving their locations for millions of years and will continue to move in the future. (T/F)

Lasers work by focusing sound waves (T/F)

Antibiotics kill viruses as well as bacteria (T/F)

The universe began with a big explosion (T/F)

How long does it take for the earth to go around the Sun: one day, one month, or one year?

Human beings, as we know them today, developed from earlier species of

animals (T/F)

Electrons are smaller than atoms (T/F)

The continents have been moving their locations for millions of years and will continue to move in the future. (T/F)

The universe began with a big explosion (T/F)

Page 7: Analyzing and Interpreting Continuous Predictors · 2020-07-05 · whether the baby is a boy or a girl (T/F) All radioactivity is man-made (T/F) The continents have been moving their

Recoding variables indicating scientific knowledge

. sum sci1-sci11 Variable | Obs Mean Std. Dev. Min Max -------------+-------------------------------------------------------- sci1 | 3435 .7330422 .4424345 0 1 sci2 | 3695 .5123139 .499916 0 1 sci3 | 3702 .937061 .2428859 0 1 sci4 | 3966 .7927383 .4053958 0 1 sci5 | 3088 .7176166 .4502318 0 1 -------------+-------------------------------------------------------- sci6 | 2857 .6965348 .4598348 0 1 sci7 | 3760 .8925532 .3097217 0 1 sci8 | 3680 .7997283 .400258 0 1 sci9 | 3962 .5731954 .4946759 0 1 sci10 | 2972 .4767833 .4995447 0 1 -------------+-------------------------------------------------------- sci11 | 2892 .7704011 .4206476 0 1

BOYORGRL EVOLVED HOTCORE EARTHSUN ELECTRON LASERS CONDRIFT RADIOACT VIRUSES BIGBANG SOLARREV

Page 8: Analyzing and Interpreting Continuous Predictors · 2020-07-05 · whether the baby is a boy or a girl (T/F) All radioactivity is man-made (T/F) The continents have been moving their

. alpha sci2-sci11, i c sci4 constant in analysis sample, dropped from analysis Test scale = mean(unstandardized items) average item-test item-rest interitem Item | Obs Sign correlation correlation covariance alpha -------------+----------------------------------------------------------------- sci2 | 1257 + 0.6019 0.3730 .0190121 0.5366 sci3 | 1257 + 0.2715 0.1479 .0268609 0.5930 sci5 | 1257 + 0.4359 0.2001 .0238018 0.5898 sci6 | 1257 + 0.4813 0.2760 .0225492 0.5669 sci7 | 1257 + 0.3833 0.2431 .0250253 0.5771 sci8 | 1257 + 0.4417 0.2665 .023617 0.5699 sci9 | 1257 + 0.5097 0.2733 .0217802 0.5693 sci10 | 1257 + 0.6568 0.4463 .0173278 0.5102 sci11 | 1257 + 0.5000 0.3022 .0221002 0.5599 -------------+----------------------------------------------------------------- Test scale | .0224527 0.5941 -------------------------------------------------------------------------------

Do the items ‘hang’ together?

EVOLVED HOTCORE ELECTRON LASERS CONDRIFT RADIOACT VIRUSES BIGBANG SOLARREV

gen s_scisc= sci2 + sci3 + sci5 + sci6 + sci7 + sci8 + sci9 + sci10 + sci11 gen a_scisc= s_scisc/9

Page 9: Analyzing and Interpreting Continuous Predictors · 2020-07-05 · whether the baby is a boy or a girl (T/F) All radioactivity is man-made (T/F) The continents have been moving their

Single Level Models

• Analyzing the estimated effect of X on Y. – Pi is the probability of reporting high confidence in science – Est. as a function of year, education, political ideology, and gender

logit (pi) = b0 + b1*x1 + b2*x2 + b3*x3 + b4*x4

Page 10: Analyzing and Interpreting Continuous Predictors · 2020-07-05 · whether the baby is a boy or a girl (T/F) All radioactivity is man-made (T/F) The continents have been moving their

Single Level Models

• Analyzing the estimated effect of X on Y. – Pi is the probability of reporting high confidence in science – Est. as a function of year, education, political ideology, and gender

logit (pi) = b0 + b1*x1 + b2*x2 + b3*x3 + b4*x4

Page 11: Analyzing and Interpreting Continuous Predictors · 2020-07-05 · whether the baby is a boy or a girl (T/F) All radioactivity is man-made (T/F) The continents have been moving their

Single Level Models

• Analyzing the estimated effect of X on Y. – Pi is the probability of reporting high confidence in science – Est. as a function of year, education, political ideology, and gender

logit (pi) = b0 + b1*x1 + b2*x2 + b3*x3 + b4*x4 Proc logistic data = data_recode; Model scicon = year educ lib con fem; run;

Analysis of Maximum Likelihood Estimates Standard Wald Parameter DF Estimate Error Chi-Square Pr > ChiSq Intercept 1 18.1335 2.1819 69.0733 <.0001 YEAR 1 -0.00992 0.00110 81.1989 <.0001 EDUC 1 0.1121 0.00409 751.1333 <.0001 lib 1 0.2315 0.0292 62.8992 <.0001 con 1 0.0542 0.0276 3.8674 0.0492 fem 1 -0.3263 0.0234 195.1882 <.0001

Page 12: Analyzing and Interpreting Continuous Predictors · 2020-07-05 · whether the baby is a boy or a girl (T/F) All radioactivity is man-made (T/F) The continents have been moving their

Single Level Models

• Analyzing the estimated effect of X on Y. – Pi is the probability of reporting high confidence in science – Est. as a function of year, education, political ideology, and gender

logit (pi) = b0 + b1*x1 + b2*x2 + b3*x3 + b4*x4 Proc logistic data = data_recode; Model scicon = year educ lib con fem; run;

Analysis of Maximum Likelihood Estimates Standard Wald Parameter DF Estimate Error Chi-Square Pr > ChiSq Intercept 1 18.1335 2.1819 69.0733 <.0001 YEAR 1 -0.00992 0.00110 81.1989 <.0001 EDUC 1 0.1121 0.00409 751.1333 <.0001 lib 1 0.2315 0.0292 62.8992 <.0001 con 1 0.0542 0.0276 3.8674 0.0492 fem 1 -0.3263 0.0234 195.1882 <.0001

Page 13: Analyzing and Interpreting Continuous Predictors · 2020-07-05 · whether the baby is a boy or a girl (T/F) All radioactivity is man-made (T/F) The continents have been moving their

Single Level Models • Plotting predicted values of Y based on X • B=-0.00992

X1 B1X1 Ʃ exp(Ʃ)=exp(Ʃ)/[1+exp((Ʃ)]

1974 -19.582 -0.102 0.903 0.4751975 -19.592 -0.112 0.894 0.4721976 -19.602 -0.122 0.885 0.4701977 -19.612 -0.132 0.876 0.4671978 -19.622 -0.142 0.868 0.4651979 -19.632 -0.152 0.859 0.4621980 -19.642 -0.162 0.851 0.4601981 -19.652 -0.172 0.842 0.4571982 -19.661 -0.181 0.834 0.4551983 -19.671 -0.191 0.826 0.4521984 -19.681 -0.201 0.818 0.4501985 -19.691 -0.211 0.810 0.4471986 -19.701 -0.221 0.802 0.4451987 -19.711 -0.231 0.794 0.4421988 -19.721 -0.241 0.786 0.4401989 -19.731 -0.251 0.778 0.4381990 -19.741 -0.261 0.770 0.435

Page 14: Analyzing and Interpreting Continuous Predictors · 2020-07-05 · whether the baby is a boy or a girl (T/F) All radioactivity is man-made (T/F) The continents have been moving their

Centering continuous predictors in single level models

Uncentered • Zero means something Centered • Key, substantive value • The mean

Page 15: Analyzing and Interpreting Continuous Predictors · 2020-07-05 · whether the baby is a boy or a girl (T/F) All radioactivity is man-made (T/F) The continents have been moving their

Centering continuous predictors in single level models

• Uncentered Results (year)

• Centering around the Mean (year_c) year_c=year-1990;

Parameter DF Estimate Error Chi-Square Pr > ChiSq Intercept 1 18.1335 2.1819 69.0733 <.0001 YEAR 1 -0.00992 0.00110 81.1989 <.0001 EDUC 1 0.1121 0.00409 751.1333 <.0001 lib 1 0.2315 0.0292 62.8992 <.0001 con 1 0.0542 0.0276 3.8674 0.0492 fem 1 -0.3263 0.0234 195.1882 <.0001

Parameter DF Estimate Error Chi-Square Pr > ChiSq Intercept 1 -1.6170 0.0566 816.5132 <.0001 year_c 1 -0.00992 0.00110 81.1989 <.0001 EDUC 1 0.1121 0.00409 751.1333 <.0001 lib 1 0.2315 0.0292 62.8992 <.0001 con 1 0.0542 0.0276 3.8674 0.0492 fem 1 -0.3263 0.0234 195.1882 <.0001

Page 16: Analyzing and Interpreting Continuous Predictors · 2020-07-05 · whether the baby is a boy or a girl (T/F) All radioactivity is man-made (T/F) The continents have been moving their

Centering continuous predictors in single level models

• Uncentered Results (year)

• Centering around the Mean (year_c) year_c=year-1990;

Parameter DF Estimate Error Chi-Square Pr > ChiSq Intercept 1 18.1335 2.1819 69.0733 <.0001 YEAR 1 -0.00992 0.00110 81.1989 <.0001 EDUC 1 0.1121 0.00409 751.1333 <.0001 lib 1 0.2315 0.0292 62.8992 <.0001 con 1 0.0542 0.0276 3.8674 0.0492 fem 1 -0.3263 0.0234 195.1882 <.0001

Parameter DF Estimate Error Chi-Square Pr > ChiSq Intercept 1 -1.6170 0.0566 816.5132 <.0001 year_c 1 -0.00992 0.00110 81.1989 <.0001 EDUC 1 0.1121 0.00409 751.1333 <.0001 lib 1 0.2315 0.0292 62.8992 <.0001 con 1 0.0542 0.0276 3.8674 0.0492 fem 1 -0.3263 0.0234 195.1882 <.0001

Page 17: Analyzing and Interpreting Continuous Predictors · 2020-07-05 · whether the baby is a boy or a girl (T/F) All radioactivity is man-made (T/F) The continents have been moving their

Single Level Model

Page 18: Analyzing and Interpreting Continuous Predictors · 2020-07-05 · whether the baby is a boy or a girl (T/F) All radioactivity is man-made (T/F) The continents have been moving their

Interactions with categorical variables Parameter DF Estimate Error Chi-Square Pr > ChiSq Intercept 1 14.8582 3.5060 17.9602 <.0001 YEAR 1 -0.00828 0.00176 21.9997 <.0001 EDUC 1 0.1119 0.00409 748.0446 <.0001 lib 1 -10.1444 5.2980 3.6663 0.0555 con 1 18.9655 5.1108 13.7707 0.0002 fem 1 -0.3283 0.0234 197.1669 <.0001 libXyr 1 0.00521 0.00266 3.8356 0.0502 conXyr 1 -0.00950 0.00257 13.6895 0.0002

Lib=1

X1 B1X1 lib libXyr Ʃ exp(Ʃ)=exp(Ʃ)/[1+exp((Ʃ)]

1974 -16.3447 -10.1444 10.2845 -0.0797 0.9234 0.48011975 -16.3530 -10.1444 10.2898 -0.0827 0.9206 0.47931976 -16.3613 -10.1444 10.2950 -0.0858 0.9178 0.4786

Page 19: Analyzing and Interpreting Continuous Predictors · 2020-07-05 · whether the baby is a boy or a girl (T/F) All radioactivity is man-made (T/F) The continents have been moving their

Interactions with categorical variables Parameter DF Estimate Error Chi-Square Pr > ChiSq Intercept 1 14.8582 3.5060 17.9602 <.0001 YEAR 1 -0.00828 0.00176 21.9997 <.0001 EDUC 1 0.1119 0.00409 748.0446 <.0001 lib 1 -10.1444 5.2980 3.6663 0.0555 con 1 18.9655 5.1108 13.7707 0.0002 fem 1 -0.3283 0.0234 197.1669 <.0001 libXyr 1 0.00521 0.00266 3.8356 0.0502 conXyr 1 -0.00950 0.00257 13.6895 0.0002

Lib=1

X1 B1X1 lib libXyr Ʃ exp(Ʃ)=exp(Ʃ)/[1+exp((Ʃ)]

1974 -16.3447 -10.1444 10.2845 -0.0797 0.9234 0.48011975 -16.3530 -10.1444 10.2898 -0.0827 0.9206 0.47931976 -16.3613 -10.1444 10.2950 -0.0858 0.9178 0.4786

Page 20: Analyzing and Interpreting Continuous Predictors · 2020-07-05 · whether the baby is a boy or a girl (T/F) All radioactivity is man-made (T/F) The continents have been moving their

Interactions with categorical variables Parameter DF Estimate Error Chi-Square Pr > ChiSq Intercept 1 14.8582 3.5060 17.9602 <.0001 YEAR 1 -0.00828 0.00176 21.9997 <.0001 EDUC 1 0.1119 0.00409 748.0446 <.0001 lib 1 -10.1444 5.2980 3.6663 0.0555 con 1 18.9655 5.1108 13.7707 0.0002 fem 1 -0.3283 0.0234 197.1669 <.0001 libXyr 1 0.00521 0.00266 3.8356 0.0502 conXyr 1 -0.00950 0.00257 13.6895 0.0002

Lib=1

X1 B1X1 lib libXyr Ʃ exp(Ʃ)=exp(Ʃ)/[1+exp((Ʃ)]

1974 -16.3447 -10.1444 10.2845 -0.0797 0.9234 0.48011975 -16.3530 -10.1444 10.2898 -0.0827 0.9206 0.47931976 -16.3613 -10.1444 10.2950 -0.0858 0.9178 0.4786

Page 21: Analyzing and Interpreting Continuous Predictors · 2020-07-05 · whether the baby is a boy or a girl (T/F) All radioactivity is man-made (T/F) The continents have been moving their

Graphing continuous x categorical interactions

Page 22: Analyzing and Interpreting Continuous Predictors · 2020-07-05 · whether the baby is a boy or a girl (T/F) All radioactivity is man-made (T/F) The continents have been moving their

Interactions with continuous variables

• The problem:

Page 23: Analyzing and Interpreting Continuous Predictors · 2020-07-05 · whether the baby is a boy or a girl (T/F) All radioactivity is man-made (T/F) The continents have been moving their

Interactions with continuous variables

• The problem: • A few approaches:

– Collapse into categorical variable based on cutpoints

– Predict values for three meaningful values • X1 varies • X2 is graphed at the mean, -1SD, and +1 SD

http://www.math.yorku.ca/SCS/spida/lm/mreganim3.gif

Page 24: Analyzing and Interpreting Continuous Predictors · 2020-07-05 · whether the baby is a boy or a girl (T/F) All radioactivity is man-made (T/F) The continents have been moving their

Interactions with continuous variables

• The problem: how to show a “surface” • A few approaches:

– Collapse into categorical variable based on cutpoints

– Predict values of Y for a few meaningful values of X2 with X1 varying

• X2 is graphed at the mean, -1SD, and +1 SD

Page 25: Analyzing and Interpreting Continuous Predictors · 2020-07-05 · whether the baby is a boy or a girl (T/F) All radioactivity is man-made (T/F) The continents have been moving their

Interactions with continuous variables

• Establishing cutpoints in educ – <12 yrs, 12 yrs, >12 yrs

Parameter DF Estimate Error Chi-Square Pr > ChiSq Intercept 1 20.6403 2.8322 53.1105 <.0001 YEAR 1 -0.0105 0.00142 54.2684 <.0001 lths 1 -6.8935 5.8645 1.3817 0.2398 coll 1 -6.8651 5.3944 1.6196 0.2032 lib 1 0.2419 0.0292 68.6332 <.0001 con 1 0.0492 0.0276 3.1775 0.0747 fem 1 -0.3263 0.0234 195.1189 <.0001 lthsXyr 1 0.00327 0.00295 1.2290 0.2676 collXyr 1 0.00374 0.00271 1.9120 0.1667

Page 26: Analyzing and Interpreting Continuous Predictors · 2020-07-05 · whether the baby is a boy or a girl (T/F) All radioactivity is man-made (T/F) The continents have been moving their

Interactions with continuous variables

• Establishing cutpoints in educ – <12 yrs, 12 yrs, >12 yrs

Parameter DF Estimate Error Chi-Square Pr > ChiSq Intercept 1 20.6403 2.8322 53.1105 <.0001 YEAR 1 -0.0105 0.00142 54.2684 <.0001 lths 1 -6.8935 5.8645 1.3817 0.2398 coll 1 -6.8651 5.3944 1.6196 0.2032 lib 1 0.2419 0.0292 68.6332 <.0001 con 1 0.0492 0.0276 3.1775 0.0747 fem 1 -0.3263 0.0234 195.1189 <.0001 lthsXyr 1 0.00327 0.00295 1.2290 0.2676 collXyr 1 0.00374 0.00271 1.9120 0.1667

• Plot similarly to before.