class: center, middle, inverse, title-slide .title[ # Bayesian Linear Models ] .subtitle[ ## 03 - Interactions ] .author[ ### Stefano Coretta ] .institute[ ### University of Edinburgh ] .date[ ### 2023/07/07 ] --- layout: true ## Many predictors --- <img src="index_files/figure-html/rt-int-1.png" height="500px" style="display: block; margin: auto;" /> --- ```r my_seed <- 9899 rt_bm_3 <- brm( RT ~ IsWord + PhonLev, data = mald, backend = "cmdstanr", cores = 4, file = "./data/cache/rt_bm_3", seed = my_seed ) ``` --- ``` ## Population-Level Effects: ## Estimate Est.Error l-89% CI u-89% CI Rhat Bulk_ESS Tail_ESS ## Intercept 806.93 34.54 752.38 861.65 1.00 3876 3233 ## IsWordFALSE 131.14 12.47 111.01 151.30 1.00 4793 3214 ## PhonLev 24.71 4.73 17.09 32.19 1.00 3914 3289 ``` .bg-washed-yellow.b--gold.ba.bw2.br3.shadow-5.ph4.mt2[ - The `Intercept` is the mean RT when [IsWord=TRUE] and [PhonLev=0]. - `IsWordFALSE` is the **difference** between the mean RT when [IsWord=FALSE] and the mean RT when [IsWord=TRUE]. - `PhonLev` is the **difference** between the mean RT when [PhonLev=1] and [PhoneLev=0]. ] --- <img src="index_files/figure-html/rt-bm-3-plot-1.png" height="500px" style="display: block; margin: auto;" /> --- <img src="index_files/figure-html/rt-bm-3-plot-2-1.png" height="500px" style="display: block; margin: auto;" /> --- <img src="index_files/figure-html/rt-int-2-1.png" height="500px" style="display: block; margin: auto;" /> --- layout: false layout: true ## We need an interaction --- ```r rt_bm_4 <- brm( RT ~ IsWord + PhonLev + IsWord:PhonLev, data = mald, backend = "cmdstanr", cores = 4, file = "./data/cache/rt_bm_4", seed = my_seed ) ``` .bg-washed-blue.b--dark-blue.ba.bw2.br3.shadow-5.ph4.mt2[ - `isWord:PhonLev` is called an **interaction** term. - `isWord:PhonLev` allows the model to capture differences in the effect of `isWord` depending on the value of `PhonLev` (and vice versa). ] --- ``` ## Population-Level Effects: ## Estimate Est.Error l-89% CI u-89% CI Rhat Bulk_ESS Tail_ESS ## Intercept 756.94 47.75 679.47 833.45 1.00 2008 2259 ## IsWordFALSE 229.58 68.39 121.26 341.01 1.00 1590 1633 ## PhonLev 31.75 6.65 21.03 42.54 1.00 1965 2330 ## IsWordFALSE:PhonLev -13.85 9.48 -29.32 1.10 1.00 1614 1700 ``` .bg-washed-yellow.b--gold.ba.bw2.br3.shadow-5.ph4.mt2[ - The `Intercept` is the mean RT when [IsWord=TRUE] and [PhonLev=0]. - `IsWordFALSE` is the **difference** between the mean RT when [IsWord=FALSE] and the mean RT when [IsWord=TRUE], when [PhonLev=0]. - `PhonLev` is the **difference** between the mean RT when [PhonLev=1] and [PhoneLev=0], when [IsWord=TRUE]. - `IsWordFALSE:PhonLev` is the adjustment to the difference in mean RT when [IsWord=FALSE] and [PhonLev=1]. ] --- <img src="index_files/figure-html/rt-bm-4-plot-1.png" height="500px" style="display: block; margin: auto;" />