Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Statistical Rethinking - Lecture 10

Statistical Rethinking - Lecture 10

Lecture 10 - Interactions - Statistical Rethinking: A Bayesian Course with R Examples

Richard McElreath

February 05, 2015
Tweet

More Decks by Richard McElreath

Other Decks in Education

Transcript

  1. Why no P < 0.05? • Cannot convert probability into

    certainty • If you want to estimate, P worse than MLE or posterior • If you want to decide, P uncalibrated • If you want to predict, P is worse than cross-validation, AIC, etc. • All of this applies to confidence intervals as well
  2. Tragedy of null-acceptance • p > 0.05: “No effect” •

    Sad history of right-turn-on-red 496 E. Hauer / Accident Analysis and Prevention 3 Table 1 The Virginia RTOR study Before RTOR signing After RTOR signing Fatal crashes 0 0 Personal injury crashes 43 60 Persons injured 69 72 Property damage crashes 265 277 Property damage (US$) 161243 170807 Total crashes 308 337 thing and the Commissioner transmitted something entirely Table 2 Summary Crash type Treatment: Single-v Same-di Opposit Fatal Persona Property Treatment: Single-v Same-di Hauer. 2004. Accident Analysis and Prevention 36:495–500
  3. Regression heuristics • Assume an effect and estimate it •

    Imagine how estimates may mislead • missing variables • sample selection • model structure • Fitting is easy; prediction is hard • Plot, plot, plot! • Embrace the uncertainty • uncertainty about parameters • uncertainty about models
  4. Topics Week 1 Bayesian inference Chapters 1, 2, 3 Week

    2 Linear models Chapters 3 & 4 Week 3 Multivariate models Chapter 5 Week 4 Model comparison Chapter 6 Week 5 Interactions Chapter 7 Week 6 MCMC Chapter 8 Week 7 GLMs I: Counts Chapters 9 & 10 Week 8 GLMs II: Mixtures Chapter 11 Week 9 Multilevel models Chapters 12 & 13 Week 10 Measurement error etc. Chapter 14
  5. • mc-stan.org • Install Rstan 1. Get C++ compiler 2.

    ??? 3. Profit Stanislaw Ulam (1909–1984)
  6. Tulip blooms • 27 replicate blooms across three levels of

    both water and shade blooms 1.0 2.0 3.0 0 100 300 1.0 2.0 3.0 water 0 100 300 1.0 2.0 3.0 1.0 2.0 3.0 shade
  7. Tulip blooms ćF VODFOUFSFE NPEFMT 8IJMF B DPNQMFUF NPEFM BWFSBHJOH

    BOBMZTJT JT QPTTJCMF HPJOH TJNQMJGZ UIF TUPSZ CZ GPDVTJOH PO KVTU UXP NPEFMT  UIF NPEFM XJUI - BOE .# CVU OP JOUFSBDUJPO BOE  UIF NPEFM XJUI CPUI NBJO FČFDUT BOE BDUJPO PG 2/ - XJUI .#  * EP TP KVTU GPS UIF TBLF PG CSFWJUZ :PV DBO ĕU UIF NPEFMT MJLF UIPTF XJUI POMZ POF PG UIF UXP QSFEJDUPS WBSJBCMFT BOE EFNPOTUSBUF FMG UIBU UIF DPODMVTJPOT EPOU TVCTUBOUJBMMZ DIBOHF NBJO FČFDU NPEFM JT BTTVNJOH OBJWF ĘBU QSJPST  #J ∼ /PSNBM(µJ, σ) µJ = α + βX XJ + βT TJ GVMM JOUFSBDUJPO NPEFM JT BMTP BTTVNJOH OBJWF ĘBU QSJPST  #J ∼ /PSNBM(µJ, σ) µJ = α + βX XJ + βT TJ + βXT XJ TJ JT UIF WBMVF PG '**( PO SPX J XJ JT UIF WBMVF PG 2/ - BOE TJ JT UIF WBMVF PG N MFBWJOH UIF DBUFHPSJDBM WBSJBCMF   PVU PG UIJT BOBMZTJT CVU * BDUVBMMZ UIJOL B OBMZTJT SFRVJSFT JU ćF QPJOUT * XJTI UP NBLF EPOU EFQFOE VQPO JU IPXFWFS OH UIF NPEFMT XJUI (+ JT KVTU BT ZPV NJHIU FYQFDU 3 DPEF  (+ǭ ǭ '**(. ʋ )*-(ǭ (0 ǐ .$"( Ǯ ǐ (0 ʋ  ɾ 2Ƿ2/ - ɾ .Ƿ.# E NFDIBOJTUJD NPEFM PG UIF JOUFSBDUJPO POF UIBU VTFT B UIFPSZ BCPVU UIF QMBOUT QIZT HZ UP IZQPUIFTJ[F UIF GVODUJPOBM SFMBUJPOTIJQ CFUXFFO MJHIU BOE XBUFS UIFO B TJNQMF BS UXPXBZ JOUFSBDUJPO JT B HPPE TUBSU  ćF VODFOUFSFE NPEFMT 8IJMF B DPNQMFUF NPEFM BWFSBHJOH BOBMZTJT JT QPTTJCMF *N HPJOH TJNQMJGZ UIF TUPSZ CZ GPDVTJOH PO KVTU UXP NPEFMT  UIF NPEFM XJUI I 2/ - BOE .# CVU OP JOUFSBDUJPO BOE  UIF NPEFM XJUI CPUI NBJO FČFDUT BOE OUFSBDUJPO PG 2/ - XJUI .#  * EP TP KVTU GPS UIF TBLF PG CSFWJUZ :PV DBO ĕU UIF JOH NPEFMT MJLF UIPTF XJUI POMZ POF PG UIF UXP QSFEJDUPS WBSJBCMFT BOE EFNPOTUSBUF ZPVSTFMG UIBU UIF DPODMVTJPOT EPOU TVCTUBOUJBMMZ DIBOHF ćF NBJO FČFDU NPEFM JT BTTVNJOH OBJWF ĘBU QSJPST  #J ∼ /PSNBM(µJ, σ) µJ = α + βX XJ + βT TJ UIF GVMM JOUFSBDUJPO NPEFM JT BMTP BTTVNJOH OBJWF ĘBU QSJPST  #J ∼ /PSNBM(µJ, σ) µJ = α + βX XJ + βT TJ + βXT XJ TJ SF #J JT UIF WBMVF PG '**( PO SPX J XJ JT UIF WBMVF PG 2/ - BOE TJ JT UIF WBMVF PG   *N MFBWJOH UIF DBUFHPSJDBM WBSJBCMF   PVU PG UIJT BOBMZTJT CVU * BDUVBMMZ UIJOL B FSF BOBMZTJT SFRVJSFT JU ćF QPJOUT * XJTI UP NBLF EPOU EFQFOE VQPO JU IPXFWFS 'JUUJOH UIF NPEFMT XJUI (+ JT KVTU BT ZPV NJHIU FYQFDU 3 DPEF  ʄǤ (+ǭ '$./ǭ No interaction: water and shade have independent effects Interaction: water and shade have interdependent effects
  8.   */5&3"$5*0/4  ʋ )*-(ǭ ƻ ǐ Ƽƻƻ Ǯ

    ǐ 2 ʋ )*-(ǭ ƻ ǐ Ƽƻƻ Ǯ ǐ . ʋ )*-(ǭ ƻ ǐ Ƽƻƻ Ǯ ǐ 2. ʋ )*-(ǭ ƻ ǐ Ƽƻƻ Ǯ ǐ .$"( ʋ 0)$!ǭ ƻ ǐ Ƽƻƻ Ǯ Ǯ ǐ /ʃ ǐ ( /#*ʃǙ ' -Ǥ Ǚ ǐ *)/-*'ʃ'$./ǭ(3$/ʃƼ ƿǮ Ǯ /P BOHSZ XBSOJOHT BOZNPSF 4P MFUT MPPL BU UIF FTUJNBUFT 3 DPEF  * !/ǭ(ǂǏǁǐ(ǂǏǂǮ (ǂǏǁ (ǂǏǂ  ǀƾǏƿǁ ǤǃƿǏƿǂ 2 ǂǁǏƾǁ ƼǀƼǏƼǁ . ǤƾǃǏDŽƽ ƾǀǏƼƾ .$"( ǀǂǏƿƻ ƿǁǏƽǀ 2.  ǤƾDŽǏǁǂ )*. ƽǂ ƽǂ /PX DPOTJEFS UIFTF FTUJNBUFT BOE USZ UP ĕHVSF PVU XIBU UIF NPEFMT BSF UFMMJOH VT BCPVU UIF JOĘVFODF PG XBUFS BOE TIBEF PO UIF CMPPNT 'JSTU DPOTJEFS UIF JOUFSDFQUT  α ćF FTUJNBUF Tulip blooms • Estimates gone wild! /PX DPOTJEFS UIF TMPQF QBSBNFUFST *O UIF NBJOFČFDUPOMZ NPEFM (ǂǏǁ UIF ."1 WBMVF GPS UIF NBJO FČFDU PG 2/ - JT QPTJUJWF BOE UIF NBJO FČFDU GPS .# JT OFHBUJWF 5BLF B MPPL BU UIF TUBOEBSE EFWJBUJPOT BOE JOUFSWBMT JO +- $.ǭ(ǂǏǁǮ UP WFSJGZ UIBU CPUI QPTUFSJPS EJTUSJCVUJPOT BSF SFMJBCMZ PO POF TJEF PG [FSP :PV NJHIU JOGFS UIBU UIFTF QPTUFSJPS EJTUSJCV UJPOT TVHHFTU UIBU XBUFS JODSFBTFT CMPPNT XIJMF TIBEF SFEVDFT UIFN 'PS FWFSZ BEEJUJPOBM MFWFM PG TPJM NPJTUVSF CMPPNT JODSFBTF CZ  PO BWFSBHF 'PS FWFSZ BEEJUJPO VOJU PG TIBEF CMPPNT EFDSFBTF CZ  PO BWFSBHF ćPTF TPVOE SFBTPO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Ǐƿǁ ǤǃƿǏƿǂ 2 ǂǁǏƾǁ ƼǀƼǏƼǁ . ǤƾǃǏDŽƽ ƾǀǏƼƾ .$"( ǀǂǏƿƻ ƿǁǏƽǀ 2.  ǤƾDŽǏǁǂ )*. ƽǂ ƽǂ /PX DPOTJEFS UIFTF FTUJNBUFT BOE USZ UP ĕHVSF PVU XIBU UIF NPEFMT BSF UFMMJOH VT BCPVU UIF JOĘVFODF PG XBUFS BOE TIBEF PO UIF CMPPNT 'JSTU DPOTJEFS UIF JOUFSDFQUT  α ćF FTUJNBUF Tulip blooms • Estimates gone wild! /PX DPOTJEFS UIF TMPQF QBSBNFUFST *O UIF NBJOFČFDUPOMZ NPEFM (ǂǏǁ UIF ."1 WBMVF GPS UIF NBJO FČFDU PG 2/ - JT QPTJUJWF BOE UIF NBJO FČFDU GPS .# JT OFHBUJWF 5BLF B MPPL BU UIF TUBOEBSE EFWJBUJPOT BOE JOUFSWBMT JO +- $.ǭ(ǂǏǁǮ UP WFSJGZ UIBU CPUI QPTUFSJPS EJTUSJCVUJPOT BSF SFMJBCMZ PO POF TJEF PG [FSP :PV NJHIU JOGFS UIBU UIFTF QPTUFSJPS EJTUSJCV UJPOT TVHHFTU UIBU XBUFS JODSFBTFT CMPPNT XIJMF TIBEF SFEVDFT UIFN 'PS FWFSZ BEEJUJPOBM MFWFM PG TPJM NPJTUVSF CMPPNT JODSFBTF CZ  PO BWFSBHF 'PS FWFSZ BEEJUJPO VOJU PG TIBEF CMPPNT EFDSFBTF CZ  PO BWFSBHF ćPTF TPVOE SFBTPOBCMF #VU UIF BOBMPHPVT QPTUFSJPS EJTUSJCVUJPOT GSPN UIF JOUFSBDUJPO NPEFM (ǂǏǂ BSF RVJUF EJČFSFOU 'JSTU BTTVSF ZPVSTFMG UIBU UIF JOUFSBDUJPO NPEFM JT JOEFFE B NVDI CFUUFS NPEFM 3 DPEF  *(+- ǭ (ǂǏǁ ǐ (ǂǏǂ Ǯ   +    2 $"#/   (ǂǏǂ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OĘVFODF PG XBUFS BOE TIBEF PO UIF CMPPNT 'JSTU DPOTJEFS UIF JOUFSDFQUT  α ćF FTUJNBUF Tulip blooms • Estimates gone wild! Intercept completely different Influence of shade changes direction? Interaction negative? /PX DPOTJEFS UIF TMPQF QBSBNFUFST *O UIF NBJOFČFDUPOMZ NPEFM (ǂǏǁ UIF ."1 WBMVF GPS UIF NBJO FČFDU PG 2/ - JT QPTJUJWF BOE UIF NBJO FČFDU GPS .# JT OFHBUJWF 5BLF B MPPL BU UIF TUBOEBSE EFWJBUJPOT BOE JOUFSWBMT JO +- $.ǭ(ǂǏǁǮ UP WFSJGZ UIBU CPUI QPTUFSJPS EJTUSJCVUJPOT BSF SFMJBCMZ PO POF TJEF PG [FSP :PV NJHIU JOGFS UIBU UIFTF QPTUFSJPS EJTUSJCV UJPOT TVHHFTU UIBU XBUFS JODSFBTFT CMPPNT XIJMF TIBEF SFEVDFT UIFN 'PS FWFSZ BEEJUJPOBM MFWFM PG TPJM NPJTUVSF CMPPNT JODSFBTF CZ  PO BWFSBHF 'PS FWFSZ BEEJUJPO VOJU PG TIBEF CMPPNT EFDSFBTF CZ  PO BWFSBHF ćPTF TPVOE SFBTPOBCMF #VU UIF BOBMPHPVT QPTUFSJPS EJTUSJCVUJPOT GSPN UIF JOUFSBDUJPO NPEFM (ǂǏǂ BSF RVJUF EJČFSFOU 'JSTU BTTVSF ZPVSTFMG UIBU UIF JOUFSBDUJPO NPEFM JT JOEFFE B NVDI CFUUFS NPEFM 3 DPEF  *(+- ǭ (ǂǏǁ ǐ (ǂǏǂ Ǯ   +    2 $"#/   (ǂǏǂ ƽDŽǁǏƾ ǁǏƽƽ ƻǏƻƻ ƻǏDŽDŽ ǀǏƻǀ  (ǂǏǁ ƾƻǁǏƾ ǀǏǀƼ ƼƻǏƻƼ ƻǏƻƼ ƿǏǁƿ ƾǏƻƽ ćJT DPNQBSJTPO BTTJHOT OFBSMZ BMM PG UIF XFJHIU PG FWJEFODF UP (ǂǏǂ 4P MFUT DPOTJEFS UIF QPTUFSJPS EJTUSJCVUJPO GSPN (ǂǏǂ /PX CPUI NBJO FČFDUT BSF QPTJUJWF CVU UIF OFX JOUFSBDUJPO QPTUFSJPS NFBO JT OFHBUJWF "SF ZPV UP DPODMVEF OPX UIBU UIF NBJO FČFDU PG TIBEF JT UP IFMQ m7.6 m7.7 285 290 295 300 305 310 315 deviance WAIC
  11.   */5&3"$5*0/4 * !/ǭ(ǂǏǃǐ(ǂǏDŽǮ (ǂǏǃ (ǂǏDŽ  ƼƽDŽǏƻƻ ƼƽDŽǏƻƼ

    2 ǂƿǏƽƽ ǂƿǏDŽǁ . ǤƿƻǏǂƿ ǤƿƼǏƼƿ .$"( ǀǂǏƾǀ ƿǀǏƽƽ 2.  ǤǀƼǏǃǂ )*. ƽǂ ƽǂ /PX XIFO XF DPNQBSF UIF QPTUFSJPS NFBOT BDSPTT UIF UXP NPEFMT UIF NBJO FČFDUT BSF U Tulip blooms • Centering helps a little • Refit with centered predictors. Now: Same estimates Interaction still negative } 4BNQMJOH GSPN UIF QPTUFSJPS OPX BOE QMPUUJOH UIF NPEFMT QSFEJDUJPOT XPVME IFMQ JN NFOTFMZ XJUI JOUFSQSFUBUJPO "OE UIBUT UIF DPVSTF * XBOU UP FODPVSBHF BOE QSPWJEF DPEF GPS *O HFOFSBM * EPOU UIJOL JUT TBGF UP JOUFSQSFU JOUFSBDUJPOT XJUIPVU QMPUUJOH UIFN #VU GPS UIF NPNFOU MFUT JOTUFBE MPPL BU UIF WBMVF PG DFOUFSJOH UIF QSFEJDUPS WBSJBCMFT BOE SFFTUJNBUJOH UIF NPEFMT  $FOUFS BOE SFFTUJNBUF 5P DFOUFS B WBSJBCMF NFBOT UP DSFBUF B OFX WBSJBCMF UIBU DPO UBJOT UIF TBNF JOGPSNBUJPO BT UIF PSJHJOBM CVU IBT B OFX NFBO PG [FSP 'PS FYBNQMF UP NBLF DFOUFSFE WFSTJPOT PG .# BOE 2/ - KVTU TVCUSBDU UIF NFBO PG UIF PSJHJOBM GSPN FBDI WBMVF ɠ.# Ǐ ʄǤ ɠ.# Ǥ ( )ǭɠ.# Ǯ ɠ2/ -Ǐ ʄǤ ɠ2/ - Ǥ ( )ǭɠ2/ -Ǯ ćF OFX DFOUFSFE WBSJBCMF IBT UIF TBNF WBSJBODF BT UIF PSJHJOBM CVU OPX IBT B NFBO PG [FSP *O UIJT DBTF DFOUFSJOH SFDPEFT UIF MFWFMT PG XBUFS BOE TIBEF TP UIBU JOTUFBE PG UIFJS SBOHJOH GSPN  UP  UIFZ OPX SBOHF GSPN − UP  $FOUFSJOH JO UIJT BOBMZTJT XJMM EP UXP UIJOHT GPS VT 'JSTU JUMM ĕY PVS QSFWJPVT QSPC MFN XJUI NBYJNVN JUFSBUJPOT 4FDPOE JUMM NBLF UIF FTUJNBUFT FBTJFS UP JOUFSQSFU -FUT SFFTUJNBUF UIF UXP SFHSFTTJPO NPEFMT CVU OPX VTJOH UIF OFX DFOUFSFE WBSJBCMFT .# Ǐ BOE 2/ -Ǐ *N BMTP HPJOH UP SFNPWF UIF *+/$( ĕYFT GSPN CFGPSF CFDBVTF OPX XF EPOU OFFE UIFN #VU * XJMM BEE FYQMJDJU ./-/ MJTUT UP FBDI NPEFM CFDBVTF UIF WFSZ ĘBU QSJPST XFSF VTJOH IFSF QSPWJEF UFSSJCMF SBOEPN TUBSUJOH MPDBUJPOT (ǂǏǃ ʄǤ (+ǭ '$./ǭ '**(. ʋ )*-(ǭ (0 ǐ .$"( Ǯ ǐ (0 ʄǤ  ɾ 2Ƿ2/ -Ǐ ɾ .Ƿ.# Ǐ ǐ
  12. #J ∼ /PSNBM(µJ, σ) µJ = α + βX XJ

    + βT TJ IF GVMM JOUFSBDUJPO NPEFM JT BMTP BTTVNJOH OBJWF ĘBU QSJPST  #J ∼ /PSNBM(µJ, σ) µJ = α + βX XJ + βT TJ + βXT XJ TJ #J JT UIF WBMVF PG '**( PO SPX J XJ JT UIF WBMVF PG 2/ - BOE TJ JT UIF WB  *N MFBWJOH UIF DBUFHPSJDBM WBSJBCMF   PVU PG UIJT BOBMZTJT CVU * BDUVBMMZ UI F BOBMZTJT SFRVJSFT JU ćF QPJOUT * XJTI UP NBLF EPOU EFQFOE VQPO JU IPXFWF UUJOH UIF NPEFMT XJUI (+ JT KVTU BT ZPV NJHIU FYQFDU ʄǤ (+ǭ $./ǭ '**(. ʋ )*-(ǭ (0 ǐ .$"( Ǯ ǐ (0 ʋ  ɾ 2Ƿ2/ - ɾ .Ƿ.# ǐ /ʃ ǐ /-/ʃ'$./ǭʃ( )ǭɠ'**(.Ǯǐ2ʃƻǐ.ʃƻǐ.$"(ʃ.ǭɠ'**(.ǮǮ Ǯ ʄǤ (+ǭ
  13. #J ∼ /PSNBM(µJ, σ) µJ = α + βX XJ

    + βT TJ IF GVMM JOUFSBDUJPO NPEFM JT BMTP BTTVNJOH OBJWF ĘBU QSJPST  #J ∼ /PSNBM(µJ, σ) µJ = α + βX XJ + βT TJ + βXT XJ TJ #J JT UIF WBMVF PG '**( PO SPX J XJ JT UIF WBMVF PG 2/ - BOE TJ JT UIF WB  *N MFBWJOH UIF DBUFHPSJDBM WBSJBCMF   PVU PG UIJT BOBMZTJT CVU * BDUVBMMZ UI F BOBMZTJT SFRVJSFT JU ćF QPJOUT * XJTI UP NBLF EPOU EFQFOE VQPO JU IPXFWF UUJOH UIF NPEFMT XJUI (+ JT KVTU BT ZPV NJHIU FYQFDU ʄǤ (+ǭ $./ǭ '**(. ʋ )*-(ǭ (0 ǐ .$"( Ǯ ǐ (0 ʋ  ɾ 2Ƿ2/ - ɾ .Ƿ.# ǐ /ʃ ǐ /-/ʃ'$./ǭʃ( )ǭɠ'**(.Ǯǐ2ʃƻǐ.ʃƻǐ.$"(ʃ.ǭɠ'**(.ǮǮ Ǯ ʄǤ (+ǭ Change in B per unit change in w?
  14. #J ∼ /PSNBM(µJ, σ) µJ = α + βX XJ

    + βT TJ IF GVMM JOUFSBDUJPO NPEFM JT BMTP BTTVNJOH OBJWF ĘBU QSJPST  #J ∼ /PSNBM(µJ, σ) µJ = α + βX XJ + βT TJ + βXT XJ TJ #J JT UIF WBMVF PG '**( PO SPX J XJ JT UIF WBMVF PG 2/ - BOE TJ JT UIF WB  *N MFBWJOH UIF DBUFHPSJDBM WBSJBCMF   PVU PG UIJT BOBMZTJT CVU * BDUVBMMZ UI F BOBMZTJT SFRVJSFT JU ćF QPJOUT * XJTI UP NBLF EPOU EFQFOE VQPO JU IPXFWF UUJOH UIF NPEFMT XJUI (+ JT KVTU BT ZPV NJHIU FYQFDU ʄǤ (+ǭ $./ǭ '**(. ʋ )*-(ǭ (0 ǐ .$"( Ǯ ǐ (0 ʋ  ɾ 2Ƿ2/ - ɾ .Ƿ.# ǐ /ʃ ǐ /-/ʃ'$./ǭʃ( )ǭɠ'**(.Ǯǐ2ʃƻǐ.ʃƻǐ.$"(ʃ.ǭɠ'**(.ǮǮ Ǯ ʄǤ (+ǭ Change in B per unit change in w? ∂µ ∂X = βX + βXT T
  15. #J ∼ /PSNBM(µJ, σ) µJ = α + βX XJ

    + βT TJ IF GVMM JOUFSBDUJPO NPEFM JT BMTP BTTVNJOH OBJWF ĘBU QSJPST  #J ∼ /PSNBM(µJ, σ) µJ = α + βX XJ + βT TJ + βXT XJ TJ #J JT UIF WBMVF PG '**( PO SPX J XJ JT UIF WBMVF PG 2/ - BOE TJ JT UIF WB  *N MFBWJOH UIF DBUFHPSJDBM WBSJBCMF   PVU PG UIJT BOBMZTJT CVU * BDUVBMMZ UI F BOBMZTJT SFRVJSFT JU ćF QPJOUT * XJTI UP NBLF EPOU EFQFOE VQPO JU IPXFWF UUJOH UIF NPEFMT XJUI (+ JT KVTU BT ZPV NJHIU FYQFDU ʄǤ (+ǭ $./ǭ '**(. ʋ )*-(ǭ (0 ǐ .$"( Ǯ ǐ (0 ʋ  ɾ 2Ƿ2/ - ɾ .Ƿ.# ǐ /ʃ ǐ /-/ʃ'$./ǭʃ( )ǭɠ'**(.Ǯǐ2ʃƻǐ.ʃƻǐ.$"(ʃ.ǭɠ'**(.ǮǮ Ǯ ʄǤ (+ǭ Change in B per unit change in w? ∂µ ∂X = βX + βXT T Change in B per unit change in s? ∂µ ∂T = βT + βXT X
  16. Why centering helps • Meaning of parameters changes when you

    add interaction. Centering disguises that fact.
  17. Why centering helps • Meaning of parameters changes when you

    add interaction. Centering disguises that fact. • Coefficient in model without interaction: • Change in outcome per unit change in predictor • e.g. change in blooms per unit change in water
  18. Why centering helps • Meaning of parameters changes when you

    add interaction. Centering disguises that fact. • Coefficient in model without interaction: • Change in outcome per unit change in predictor • e.g. change in blooms per unit change in water • Coefficient with interaction: • Change in outcome per unit change in predictor, when other predictor is zero • e.g. change in blooms per unit change in water, when shade is zero
  19. Why centering helps • Meaning of parameters changes when you

    add interaction. Centering disguises that fact. • Coefficient in model without interaction: • Change in outcome per unit change in predictor • e.g. change in blooms per unit change in water • Coefficient with interaction: • Change in outcome per unit change in predictor, when other predictor is zero • e.g. change in blooms per unit change in water, when shade is zero • Centered predictors => zero is mean value!
  20. Interpreting interaction GPS ZPVSTFMG UIBU UIF DPODMVTJPOT EPOU TVCTUBOUJBMMZ DIBOHF

    ćF NBJO FČFDU NPEFM JT BTTVNJOH OBJWF ĘBU QSJPST  #J ∼ /PSNBM(µJ, σ) µJ = α + βX XJ + βT TJ "OE UIF GVMM JOUFSBDUJPO NPEFM JT BMTP BTTVNJOH OBJWF ĘBU QSJPST #J ∼ /PSNBM(µJ, σ) µJ = α + βX XJ + βT TJ + βXT XJ TJ XIFSF #J JT UIF WBMVF PG '**( PO SPX J XJ JT UIF WBMVF PG 2/ .#  *N MFBWJOH UIF DBUFHPSJDBM WBSJBCMF   PVU PG UIJT BOBMZTJ TJODFSF BOBMZTJT SFRVJSFT JU ćF QPJOUT * XJTI UP NBLF EPOU EFQFO 'JUUJOH UIF NPEFMT XJUI (+ JT KVTU BT ZPV NJHIU FYQFDU (ǂǏǁ ʄǤ (+ǭ '$./ǭ '**(. ʋ )*-(ǭ (0 ǐ .$"( Ǯ ǐ (0 ʋ  ɾ 2Ƿ2/ - ɾ .Ƿ.# Ǯ ǐ /ʃ ǐ ./-/ʃ'$./ǭʃ( )ǭɠ'**(.Ǯǐ2ʃƻǐ.ʃƻǐ.$"(ʃ.ǭɠ'**( (ǂǏǂ ʄǤ (+ǭ '$./ǭ • a: Mean blooms when water = shade = 0. Here, when water and shade at average values. • bw: Change in blooms per unit change water, when shade = 0 • bs: Change in blooms per unit change shade, when water = 0 • bws: Interaction! Negative? Don’t even try. Just plot. = α. ćF JOUFSDFQU BDUVBMMZ NFBOT TPNFUIJOH XIFO ZPV DFOUFS UIF QSFEJDUPST *U CFDPNFT UIF HSBOE NFBO PG UIF PVUDPNF WBSJBCMF ( )ǭɠ'**(.Ǯ ćJT FBTF PG JOUFSQSFUBUJPO BMPOF JT B HPPE SFBTPO UP DFOUFS QSFEJDUPS WBSJBCMFT 4P IPX DBO XF SFBE UIFTF JNQSPWFE DFOUFSFE FTUJNBUFT )FSFT UIF UBCMF PG FTUJNBUFT 3  +- $.ǭ(ǂǏDŽǮ  ) / 1 ƽǏǀɳ DŽǂǏǀɳ  ƼƽDŽǏƻƼ ǃǏǁǂ ƼƼƽǏƻƼ ƼƿǁǏƻƻ 2 ǂƿǏDŽǁ ƼƻǏǁƻ ǀƿǏƼǃ DŽǀǏǂƿ . ǤƿƼǏƼƿ ƼƻǏǁƻ ǤǁƼǏDŽƽ ǤƽƻǏƾǁ 2. ǤǀƼǏǃǂ ƼƽǏDŽǀ ǤǂǂǏƽǀ ǤƽǁǏƿDŽ .$"( ƿǀǏƽƽ ǁǏƼǀ ƾƾǏƼǂ ǀǂǏƽǃ "OE IFSF BSF KVTUJĕBCMF SFBEJOHT PG FBDI • ćF FTUJNBUF  α JT UIF FYQFDUFE WBMVF PG '**(. XIFO CPUI 2/ - BOE .# BSF BU UIFJS BWFSBHF WBMVFT ćFJS BWFSBHF WBMVFT BSF CPUI [FSP  CFDBVTF UIFZ XFSF DFOUFSFE CFGPSF ĕUUJOH UIF NPEFM • ćF FTUJNBUF 2 βX JT UIF FYQFDUFE DIBOHF JO '**(. XIFO 2/ - JODSFBTFT CZ POF VOJU BOE .# JT BU JUT BWFSBHF WBMVF PG [FSP  ćJT QBSBNFUFS EPFT OPU UFMM ZPV UIF FYQFDUFE SBUF PG DIBOHF GPS BOZ PUIFS WBMVF PG .#  ćJT FTUJNBUF TVHHFTUT UIBU XIFO .# JT BU JUT BWFSBHF WBMVF JODSFBTJOH 2/ - JT IJHIMZ CFOFĕDJBM UP CMPPNT • ćF FTUJNBUF . βT JT UIF FYQFDUFE DIBOHF JO '**(. XIFO .# JODSFBTFT CZ POF VOJU BOE 2/ - JT BU JUT BWFSBHF WBMVF PG [FSP  ćJT QBSBNFUFS EPFT OPU UFMM ZPV UIF FYQFDUFE SBUF PG DIBOHF GPS BOZ PUIFS WBMVF PG 2/ - ćJT FTUJNBUF TVHHFTUT
  21. Plotting interaction • Slope changes with values of other predictor,

    so use more than one plot • Here, need three plots, triptych Lewis Powell (1844–1865), before his hanging for conspiracy to assassinate Abraham Lincoln.
  22. Interaction -1 0 1 0 100 200 300 water.c =

    -1 shade (centered) blooms -1 0 1 0 100 200 300 water.c = 0 shade (centered) blooms -1 0 1 0 100 200 300 water.c = 1 shade (centered) blooms -1 0 1 0 100 200 300 water.c = -1 shade (centered) blooms -1 0 1 0 100 200 300 water.c = 0 shade (centered) blooms -1 0 1 0 100 200 300 water.c = 1 shade (centered) blooms No Interaction slope varies slope constant
  23. Centering doesn’t change predictions Not centered Centered 1 2 3

    0 100 200 300 water = 1 shade blooms 1 2 3 0 100 200 300 water = 2 shade blooms 1 2 3 0 100 200 300 water = 3 shade blooms -1 0 1 0 100 200 300 water.c = -1 shade (centered) blooms -1 0 1 0 100 200 300 water.c = 0 shade (centered) blooms -1 0 1 0 100 200 300 water.c = 1 shade (centered) blooms
  24. -1 0 1 0 100 200 300 water.c = -1

    shade (centered) blooms -1 0 1 0 100 200 300 water.c = 0 shade (centered) blooms -1 0 1 0 100 200 300 water.c = 1 shade (centered) blooms Water depends on Shade Shade depends on Water -1 0 1 0 100 200 300 shade.c = -1 water (centered) blooms -1 0 1 0 100 200 300 shade.c = 0 water (centered) blooms -1 0 1 0 100 200 300 shade.c = 1 water (centered) blooms
  25. Interactions not always linear • Suppose all tulip data collected

    under “cool” temperatures • Under “hot” temperature, tulips do not bloom • Interaction, but not a linear one • blooms goes to zero at threshold
  26. Higher order interactions • Just keep multiplying: m <- lm(

    y ~ x1 * x2 * x3 ) Z J ∼ /PSNBM(µ, σ) β →  γSJ|"J= ≈ −. + .() = . Z J ∼ /PSNBM(µJ, σ), µJ = α + β YJ + β YJ + β YJ + β YJ YJ + β YJ YJ + β YJ YJ + β YJ YJ YJ. main effects 2-way interactions 3-way interaction
  27. Higher order interactions • Dangers of high-order interactions • Hard

    to interpret: “The extent to which the effect of x1 depends upon the value of x2 depends upon the value of x3 , dude.” • Hard to estimate: need lots of data, risk multicollinearity --> regularize • But you might really need them, because conditionality runs deep The Dude abides high-order interactions
  28. Higher order interactions • data(Wines2012) • Judgment of Princeton, 2012

    • New Jersey wines vs fine French wines • Shocker: French judges preferred NJ reds to French reds • Outcome variable: score • Predictors: • region (NJ/FR) • nationality of judge (USA/FR-BE) • flight (red/white)
  29. Higher order interactions • Predictors: region, nationality of judge, flight

    • Consider interactions: • Interaction of region and judge is bias. Bias depends upon flight. • Interaction of judge and flight is preference. Preference depends upon region. • Interaction of region and flight is comparative advantage. Advantage depends upon judge.
  30. Interaction everywhere • Onward to generalized linear models (GLMs) •

    All predictors interact to some extent • Onward to multilevel models (GLMMs) • Massive interaction engines --> allow parameters to be conditional on group membership