• Ground truth 1
  • Ground truth 2
  • Ground truth 3

Ground truth 1

There is - no interaction and - no ceiling effect in the moderator, - no floor effect in the outcome. - two main effects on the outcome, one positive, one negative.

knitr::opts_chunk$set(error = TRUE)
set.seed(1710)
library(dplyr)
## 
## Attaching package: 'dplyr'
## The following objects are masked from 'package:stats':
## 
##     filter, lag
## The following objects are masked from 'package:base':
## 
##     intersect, setdiff, setequal, union
library(ggplot2)
library(brms)
## Loading required package: Rcpp
## Loading 'brms' package (version 2.1.0). Useful instructions
## can be found by typing help('brms'). A more detailed introduction
## to the package is available through vignette('brms_overview').
## Run theme_set(theme_default()) to use the default bayesplot theme.
library(broom)
multiplot <- function(x) { x %>% purrr::map(function(.) { tidy(., conf.int = TRUE, par_type = "non-varying") }) %>% 
  bind_rows(.id = "model") %>% 
  ggplot(aes(term, estimate, ymin = lower, ymax = upper, color = model)) + 
  geom_pointrange(position = position_dodge(width = 0.3)) + coord_flip()
}

likert <- function(x) { round(scales::squish(x, c(1,6))) }
dist1 = data_frame(
    pred = rnorm(1000),
    pred_m = likert(pred + 3),
    mod = rnorm(1000),
    mod_m = likert(mod + 3),
    outcome = pred + -1 * mod + rnorm(1000, sd = 3),
    outcome_m = likert(outcome + 3)
)

ggplot(dist1, aes(pred, outcome)) + facet_wrap(~ mod_m) + 
    geom_jitter() +
    geom_smooth(method = 'lm', se = F)

ggplot(dist1, aes(pred_m, outcome_m)) + facet_wrap(~ mod_m) + 
    geom_jitter() +
    geom_smooth(method = 'lm', se = F)

summary(g1m1r <- brm(bf(outcome ~ pred + mod), data = dist1, cores = 3, chains = 3))
## Compiling the C++ model
## Start sampling
##  Family: gaussian 
##   Links: mu = identity; sigma = identity 
## Formula: outcome ~ pred + mod 
##    Data: dist1 (Number of observations: 1000) 
## Samples: 3 chains, each with iter = 2000; warmup = 1000; thin = 1; 
##          total post-warmup samples = 3000
##     ICs: LOO = NA; WAIC = NA; R2 = NA
##  
## Population-Level Effects: 
##           Estimate Est.Error l-95% CI u-95% CI Eff.Sample Rhat
## Intercept    -0.07      0.09    -0.26     0.11       3000 1.00
## pred          1.03      0.09     0.85     1.22       2978 1.00
## mod          -1.12      0.10    -1.30    -0.92       3000 1.00
## 
## Family Specific Parameters: 
##       Estimate Est.Error l-95% CI u-95% CI Eff.Sample Rhat
## sigma     2.86      0.06     2.74     2.99       3000 1.00
## 
## Samples were drawn using sampling(NUTS). For each parameter, Eff.Sample 
## is a crude measure of effective sample size, and Rhat is the potential 
## scale reduction factor on split chains (at convergence, Rhat = 1).
summary(g1m2r <- brm(bf(outcome ~ pred * mod), data = dist1, cores = 3, chains = 3))
## Compiling the C++ model
## Start sampling
##  Family: gaussian 
##   Links: mu = identity; sigma = identity 
## Formula: outcome ~ pred * mod 
##    Data: dist1 (Number of observations: 1000) 
## Samples: 3 chains, each with iter = 2000; warmup = 1000; thin = 1; 
##          total post-warmup samples = 3000
##     ICs: LOO = NA; WAIC = NA; R2 = NA
##  
## Population-Level Effects: 
##           Estimate Est.Error l-95% CI u-95% CI Eff.Sample Rhat
## Intercept    -0.07      0.09    -0.25     0.11       3000 1.00
## pred          1.03      0.09     0.84     1.21       3000 1.00
## mod          -1.12      0.10    -1.31    -0.93       3000 1.00
## pred:mod      0.08      0.10    -0.11     0.27       3000 1.00
## 
## Family Specific Parameters: 
##       Estimate Est.Error l-95% CI u-95% CI Eff.Sample Rhat
## sigma     2.86      0.06     2.74     2.99       3000 1.00
## 
## Samples were drawn using sampling(NUTS). For each parameter, Eff.Sample 
## is a crude measure of effective sample size, and Rhat is the potential 
## scale reduction factor on split chains (at convergence, Rhat = 1).
LOO(g1m1r, g1m2r)
##                 LOOIC    SE
## g1m1r         4945.01 42.05
## g1m2r         4946.13 41.89
## g1m1r - g1m2r   -1.12  1.65
list(g1m1r, g1m2r) %>% multiplot

summary(g1m1 <- brm(bf(outcome_m ~ pred_m + mod_m), data = dist1, cores = 3, chains = 3))
## Compiling the C++ model
## Start sampling
##  Family: gaussian 
##   Links: mu = identity; sigma = identity 
## Formula: outcome_m ~ pred_m + mod_m 
##    Data: dist1 (Number of observations: 1000) 
## Samples: 3 chains, each with iter = 2000; warmup = 1000; thin = 1; 
##          total post-warmup samples = 3000
##     ICs: LOO = NA; WAIC = NA; R2 = NA
##  
## Population-Level Effects: 
##           Estimate Est.Error l-95% CI u-95% CI Eff.Sample Rhat
## Intercept     3.39      0.26     2.90     3.89       3000 1.00
## pred_m        0.52      0.06     0.40     0.63       3000 1.00
## mod_m        -0.58      0.06    -0.69    -0.46       3000 1.00
## 
## Family Specific Parameters: 
##       Estimate Est.Error l-95% CI u-95% CI Eff.Sample Rhat
## sigma     1.84      0.04     1.76     1.92       3000 1.00
## 
## Samples were drawn using sampling(NUTS). For each parameter, Eff.Sample 
## is a crude measure of effective sample size, and Rhat is the potential 
## scale reduction factor on split chains (at convergence, Rhat = 1).
summary(g1m2 <- brm(bf(outcome_m ~ pred_m * mod_m), data = dist1, cores = 3, chains = 3))
## Compiling the C++ model
## Start sampling
##  Family: gaussian 
##   Links: mu = identity; sigma = identity 
## Formula: outcome_m ~ pred_m * mod_m 
##    Data: dist1 (Number of observations: 1000) 
## Samples: 3 chains, each with iter = 2000; warmup = 1000; thin = 1; 
##          total post-warmup samples = 3000
##     ICs: LOO = NA; WAIC = NA; R2 = NA
##  
## Population-Level Effects: 
##              Estimate Est.Error l-95% CI u-95% CI Eff.Sample Rhat
## Intercept        3.27      0.61     2.12     4.47        921 1.00
## pred_m           0.56      0.19     0.16     0.92        915 1.00
## mod_m           -0.54      0.19    -0.92    -0.17        912 1.00
## pred_m:mod_m    -0.01      0.06    -0.12     0.11        893 1.00
## 
## Family Specific Parameters: 
##       Estimate Est.Error l-95% CI u-95% CI Eff.Sample Rhat
## sigma     1.84      0.04     1.76     1.92       2125 1.00
## 
## Samples were drawn using sampling(NUTS). For each parameter, Eff.Sample 
## is a crude measure of effective sample size, and Rhat is the potential 
## scale reduction factor on split chains (at convergence, Rhat = 1).
LOO(g1m1, g1m2)
##               LOOIC    SE
## g1m1        4054.21 29.98
## g1m2        4055.86 30.05
## g1m1 - g1m2   -1.65  0.41
list(g1m1, g1m2) %>% multiplot

summary(g1mc1 <- brm(bf(outcome_m ~ pred_m + mod_m), data = dist1, cores = 3, chains = 3, family = cumulative(threshold = "equidistant")))
## Compiling the C++ model
## Start sampling
##  Family: cumulative 
##   Links: mu = logit; disc = identity 
## Formula: outcome_m ~ pred_m + mod_m 
##    Data: dist1 (Number of observations: 1000) 
## Samples: 3 chains, each with iter = 2000; warmup = 1000; thin = 1; 
##          total post-warmup samples = 3000
##     ICs: LOO = NA; WAIC = NA; R2 = NA
##  
## Population-Level Effects: 
##              Estimate Est.Error l-95% CI u-95% CI Eff.Sample Rhat
## Intercept[1]    -0.93      0.26    -1.45    -0.42       2674 1.00
## Intercept[2]    -0.39      0.26    -0.90     0.12       2701 1.00
## Intercept[3]     0.15      0.26    -0.36     0.64       2724 1.00
## Intercept[4]     0.69      0.26     0.18     1.19       2741 1.00
## Intercept[5]     1.23      0.26     0.72     1.73       2741 1.00
## pred_m           0.54      0.06     0.43     0.66       2334 1.00
## mod_m           -0.58      0.06    -0.71    -0.47       2733 1.00
## 
## Family Specific Parameters: 
##       Estimate Est.Error l-95% CI u-95% CI Eff.Sample Rhat
## delta     0.54      0.02     0.50     0.59       2375 1.00
## 
## Samples were drawn using sampling(NUTS). For each parameter, Eff.Sample 
## is a crude measure of effective sample size, and Rhat is the potential 
## scale reduction factor on split chains (at convergence, Rhat = 1).
summary(g1mc2 <- brm(bf(outcome_m ~ pred_m * mod_m), data = dist1, cores = 3, chains = 3, family = cumulative( threshold = "equidistant")))
## Compiling the C++ model
## Start sampling
##  Family: cumulative 
##   Links: mu = logit; disc = identity 
## Formula: outcome_m ~ pred_m * mod_m 
##    Data: dist1 (Number of observations: 1000) 
## Samples: 3 chains, each with iter = 2000; warmup = 1000; thin = 1; 
##          total post-warmup samples = 3000
##     ICs: LOO = NA; WAIC = NA; R2 = NA
##  
## Population-Level Effects: 
##              Estimate Est.Error l-95% CI u-95% CI Eff.Sample Rhat
## Intercept[1]    -0.83      0.63    -2.04     0.41       1238 1.00
## Intercept[2]    -0.29      0.63    -1.50     0.93       1239 1.00
## Intercept[3]     0.25      0.63    -0.96     1.47       1241 1.00
## Intercept[4]     0.79      0.63    -0.44     2.01       1243 1.00
## Intercept[5]     1.33      0.63     0.11     2.56       1247 1.00
## pred_m           0.57      0.20     0.20     0.96       1212 1.00
## mod_m           -0.56      0.20    -0.94    -0.16       1193 1.00
## pred_m:mod_m    -0.01      0.06    -0.13     0.11       1144 1.00
## 
## Family Specific Parameters: 
##       Estimate Est.Error l-95% CI u-95% CI Eff.Sample Rhat
## delta     0.54      0.02     0.50     0.58       1757 1.00
## 
## Samples were drawn using sampling(NUTS). For each parameter, Eff.Sample 
## is a crude measure of effective sample size, and Rhat is the potential 
## scale reduction factor on split chains (at convergence, Rhat = 1).
LOO(g1mc1, g1mc2)
##                 LOOIC    SE
## g1mc1         3183.64 42.42
## g1mc2         3185.52 42.50
## g1mc1 - g1mc2   -1.87  0.34
list(g1mc1, g1mc2) %>% multiplot

list(g1m1, g1m2, g1mc1, g1mc2) %>% multiplot

Ground truth 2

There is no interaction, but a floor effect in the outcome

dist1 = dist1 %>% mutate(
    outcome_m = likert(outcome - 1)
)
table(dist1$outcome_m)
## 
##   1   2   3   4   5   6 
## 774  93  64  29  24  16
ggplot(dist1, aes(pred, outcome)) + facet_wrap(~ mod_m) + 
    geom_jitter() +
    geom_smooth(method = 'lm', se = F)

ggplot(dist1, aes(pred_m, outcome_m)) + facet_wrap(~ mod_m) + 
    geom_jitter() +
    geom_smooth(method = 'lm', se = F)

summary(g1m1r <- brm(bf(outcome ~ pred + mod), data = dist1, cores = 3, chains = 3))
## Compiling the C++ model
## Start sampling
##  Family: gaussian 
##   Links: mu = identity; sigma = identity 
## Formula: outcome ~ pred + mod 
##    Data: dist1 (Number of observations: 1000) 
## Samples: 3 chains, each with iter = 2000; warmup = 1000; thin = 1; 
##          total post-warmup samples = 3000
##     ICs: LOO = NA; WAIC = NA; R2 = NA
##  
## Population-Level Effects: 
##           Estimate Est.Error l-95% CI u-95% CI Eff.Sample Rhat
## Intercept    -0.07      0.09    -0.25     0.11       3000 1.00
## pred          1.03      0.09     0.86     1.21       3000 1.00
## mod          -1.11      0.10    -1.30    -0.93       3000 1.00
## 
## Family Specific Parameters: 
##       Estimate Est.Error l-95% CI u-95% CI Eff.Sample Rhat
## sigma     2.86      0.06     2.74     3.00       3000 1.00
## 
## Samples were drawn using sampling(NUTS). For each parameter, Eff.Sample 
## is a crude measure of effective sample size, and Rhat is the potential 
## scale reduction factor on split chains (at convergence, Rhat = 1).
summary(g1m2r <- brm(bf(outcome ~ pred * mod), data = dist1, cores = 3, chains = 3))
## Compiling the C++ model
## Start sampling
##  Family: gaussian 
##   Links: mu = identity; sigma = identity 
## Formula: outcome ~ pred * mod 
##    Data: dist1 (Number of observations: 1000) 
## Samples: 3 chains, each with iter = 2000; warmup = 1000; thin = 1; 
##          total post-warmup samples = 3000
##     ICs: LOO = NA; WAIC = NA; R2 = NA
##  
## Population-Level Effects: 
##           Estimate Est.Error l-95% CI u-95% CI Eff.Sample Rhat
## Intercept    -0.06      0.09    -0.25     0.12       3000 1.00
## pred          1.03      0.09     0.85     1.21       3000 1.00
## mod          -1.12      0.10    -1.30    -0.93       3000 1.00
## pred:mod      0.08      0.10    -0.11     0.27       3000 1.00
## 
## Family Specific Parameters: 
##       Estimate Est.Error l-95% CI u-95% CI Eff.Sample Rhat
## sigma     2.87      0.06     2.74     3.00       3000 1.00
## 
## Samples were drawn using sampling(NUTS). For each parameter, Eff.Sample 
## is a crude measure of effective sample size, and Rhat is the potential 
## scale reduction factor on split chains (at convergence, Rhat = 1).
LOO(g1m1r, g1m2r)
##                 LOOIC    SE
## g1m1r         4944.76 42.03
## g1m2r         4946.13 41.83
## g1m1r - g1m2r   -1.37  1.62
list(g1m1r, g1m2r) %>% multiplot

summary(g1m1 <- brm(bf(outcome_m ~ pred_m + mod_m), data = dist1, cores = 3, chains = 3))
## Compiling the C++ model
## Start sampling
##  Family: gaussian 
##   Links: mu = identity; sigma = identity 
## Formula: outcome_m ~ pred_m + mod_m 
##    Data: dist1 (Number of observations: 1000) 
## Samples: 3 chains, each with iter = 2000; warmup = 1000; thin = 1; 
##          total post-warmup samples = 3000
##     ICs: LOO = NA; WAIC = NA; R2 = NA
##  
## Population-Level Effects: 
##           Estimate Est.Error l-95% CI u-95% CI Eff.Sample Rhat
## Intercept     1.65      0.15     1.37     1.94       3000 1.00
## pred_m        0.21      0.03     0.14     0.27       3000 1.00
## mod_m        -0.26      0.03    -0.33    -0.20       3000 1.00
## 
## Family Specific Parameters: 
##       Estimate Est.Error l-95% CI u-95% CI Eff.Sample Rhat
## sigma     1.03      0.02     0.98     1.07       3000 1.00
## 
## Samples were drawn using sampling(NUTS). For each parameter, Eff.Sample 
## is a crude measure of effective sample size, and Rhat is the potential 
## scale reduction factor on split chains (at convergence, Rhat = 1).
summary(g1m2 <- brm(bf(outcome_m ~ pred_m * mod_m), data = dist1, cores = 3, chains = 3))
## Compiling the C++ model
## Start sampling
##  Family: gaussian 
##   Links: mu = identity; sigma = identity 
## Formula: outcome_m ~ pred_m * mod_m 
##    Data: dist1 (Number of observations: 1000) 
## Samples: 3 chains, each with iter = 2000; warmup = 1000; thin = 1; 
##          total post-warmup samples = 3000
##     ICs: LOO = NA; WAIC = NA; R2 = NA
##  
## Population-Level Effects: 
##              Estimate Est.Error l-95% CI u-95% CI Eff.Sample Rhat
## Intercept        0.93      0.34     0.25     1.59       1297 1.00
## pred_m           0.44      0.11     0.24     0.65       1275 1.00
## mod_m           -0.03      0.11    -0.23     0.18       1234 1.00
## pred_m:mod_m    -0.08      0.03    -0.14    -0.01       1226 1.00
## 
## Family Specific Parameters: 
##       Estimate Est.Error l-95% CI u-95% CI Eff.Sample Rhat
## sigma     1.02      0.02     0.98     1.07       2170 1.00
## 
## Samples were drawn using sampling(NUTS). For each parameter, Eff.Sample 
## is a crude measure of effective sample size, and Rhat is the potential 
## scale reduction factor on split chains (at convergence, Rhat = 1).
LOO(g1m1, g1m2)
##               LOOIC    SE
## g1m1        2895.90 85.94
## g1m2        2892.93 87.03
## g1m1 - g1m2    2.98  5.84
list(g1m1, g1m2) %>% multiplot

summary(g1mc1 <- brm(bf(outcome_m ~ pred_m + mod_m), data = dist1, cores = 3, chains = 3, family = cumulative(threshold = "equidistant")))
## Compiling the C++ model
## Start sampling
##  Family: cumulative 
##   Links: mu = logit; disc = identity 
## Formula: outcome_m ~ pred_m + mod_m 
##    Data: dist1 (Number of observations: 1000) 
## Samples: 3 chains, each with iter = 2000; warmup = 1000; thin = 1; 
##          total post-warmup samples = 3000
##     ICs: LOO = NA; WAIC = NA; R2 = NA
##  
## Population-Level Effects: 
##              Estimate Est.Error l-95% CI u-95% CI Eff.Sample Rhat
## Intercept[1]     0.95      0.35     0.27     1.62       3000 1.00
## Intercept[2]     1.69      0.35     1.01     2.37       3000 1.00
## Intercept[3]     2.43      0.36     1.73     3.13       3000 1.00
## Intercept[4]     3.17      0.37     2.43     3.89       3000 1.00
## Intercept[5]     3.90      0.39     3.14     4.68       3000 1.00
## pred_m           0.52      0.08     0.36     0.68       2877 1.00
## mod_m           -0.67      0.09    -0.84    -0.51       3000 1.00
## 
## Family Specific Parameters: 
##       Estimate Est.Error l-95% CI u-95% CI Eff.Sample Rhat
## delta     0.74      0.05     0.65     0.83       3000 1.00
## 
## Samples were drawn using sampling(NUTS). For each parameter, Eff.Sample 
## is a crude measure of effective sample size, and Rhat is the potential 
## scale reduction factor on split chains (at convergence, Rhat = 1).
summary(g1mc2 <- brm(bf(outcome_m ~ pred_m * mod_m), data = dist1, cores = 3, chains = 3, family = cumulative( threshold = "equidistant")))
## Compiling the C++ model
## Start sampling
##  Family: cumulative 
##   Links: mu = logit; disc = identity 
## Formula: outcome_m ~ pred_m * mod_m 
##    Data: dist1 (Number of observations: 1000) 
## Samples: 3 chains, each with iter = 2000; warmup = 1000; thin = 1; 
##          total post-warmup samples = 3000
##     ICs: LOO = NA; WAIC = NA; R2 = NA
##  
## Population-Level Effects: 
##              Estimate Est.Error l-95% CI u-95% CI Eff.Sample Rhat
## Intercept[1]     1.60      0.87    -0.10     3.28       1150 1.00
## Intercept[2]     2.35      0.87     0.65     4.05       1152 1.00
## Intercept[3]     3.09      0.87     1.40     4.81       1158 1.00
## Intercept[4]     3.83      0.88     2.13     5.55       1168 1.00
## Intercept[5]     4.57      0.89     2.85     6.28       1180 1.00
## pred_m           0.72      0.25     0.22     1.22       1118 1.00
## mod_m           -0.44      0.30    -1.03     0.15       1132 1.00
## pred_m:mod_m    -0.07      0.09    -0.24     0.10       1117 1.00
## 
## Family Specific Parameters: 
##       Estimate Est.Error l-95% CI u-95% CI Eff.Sample Rhat
## delta     0.74      0.05     0.65     0.84       1981 1.00
## 
## Samples were drawn using sampling(NUTS). For each parameter, Eff.Sample 
## is a crude measure of effective sample size, and Rhat is the potential 
## scale reduction factor on split chains (at convergence, Rhat = 1).
LOO(g1mc1, g1mc2)
##                 LOOIC    SE
## g1mc1         1607.88 70.18
## g1mc2         1609.27 70.48
## g1mc1 - g1mc2   -1.39  1.76
list(g1mc1, g1mc2) %>% multiplot

list(g1m1, g1m2, g1mc1, g1mc2) %>% multiplot

Ground truth 3

There is an interaction, and a floor effect in the outcome.

dist1 = dist1 %>% mutate(
    outcome = pred + -1 * mod + 0.5*pred*mod + rnorm(1000, sd = 3),
    outcome_m = likert(outcome - 1)
)
table(dist1$outcome_m)
## 
##   1   2   3   4   5   6 
## 784  76  55  36  24  25
ggplot(dist1, aes(pred, outcome)) + facet_wrap(~ mod_m) + 
    geom_jitter() +
    geom_smooth(method = 'lm', se = F)

ggplot(dist1, aes(pred_m, outcome_m)) + facet_wrap(~ mod_m) + 
    geom_jitter() +
    geom_smooth(method = 'lm', se = F)

summary(g1m1r <- brm(bf(outcome ~ pred + mod), data = dist1, cores = 3, chains = 3))
## Compiling the C++ model
## Start sampling
##  Family: gaussian 
##   Links: mu = identity; sigma = identity 
## Formula: outcome ~ pred + mod 
##    Data: dist1 (Number of observations: 1000) 
## Samples: 3 chains, each with iter = 2000; warmup = 1000; thin = 1; 
##          total post-warmup samples = 3000
##     ICs: LOO = NA; WAIC = NA; R2 = NA
##  
## Population-Level Effects: 
##           Estimate Est.Error l-95% CI u-95% CI Eff.Sample Rhat
## Intercept    -0.09      0.10    -0.28     0.11       3000 1.00
## pred          1.12      0.10     0.93     1.31       3000 1.00
## mod          -0.87      0.10    -1.06    -0.67       3000 1.00
## 
## Family Specific Parameters: 
##       Estimate Est.Error l-95% CI u-95% CI Eff.Sample Rhat
## sigma     3.06      0.07     2.93     3.19       3000 1.00
## 
## Samples were drawn using sampling(NUTS). For each parameter, Eff.Sample 
## is a crude measure of effective sample size, and Rhat is the potential 
## scale reduction factor on split chains (at convergence, Rhat = 1).
summary(g1m2r <- brm(bf(outcome ~ pred * mod), data = dist1, cores = 3, chains = 3))
## Compiling the C++ model
## Start sampling
##  Family: gaussian 
##   Links: mu = identity; sigma = identity 
## Formula: outcome ~ pred * mod 
##    Data: dist1 (Number of observations: 1000) 
## Samples: 3 chains, each with iter = 2000; warmup = 1000; thin = 1; 
##          total post-warmup samples = 3000
##     ICs: LOO = NA; WAIC = NA; R2 = NA
##  
## Population-Level Effects: 
##           Estimate Est.Error l-95% CI u-95% CI Eff.Sample Rhat
## Intercept    -0.06      0.10    -0.24     0.13       3000 1.00
## pred          1.09      0.10     0.89     1.29       3000 1.00
## mod          -0.92      0.11    -1.12    -0.71       3000 1.00
## pred:mod      0.60      0.10     0.41     0.79       3000 1.00
## 
## Family Specific Parameters: 
##       Estimate Est.Error l-95% CI u-95% CI Eff.Sample Rhat
## sigma     3.00      0.07     2.88     3.14       3000 1.00
## 
## Samples were drawn using sampling(NUTS). For each parameter, Eff.Sample 
## is a crude measure of effective sample size, and Rhat is the potential 
## scale reduction factor on split chains (at convergence, Rhat = 1).
LOO(g1m1r, g1m2r)
##                 LOOIC    SE
## g1m1r         5073.82 44.74
## g1m2r         5041.13 43.65
## g1m1r - g1m2r   32.69 13.89
list(g1m1r, g1m2r) %>% multiplot

summary(g1m1 <- brm(bf(outcome_m ~ pred_m + mod_m), data = dist1, cores = 3, chains = 3))
## Compiling the C++ model
## Start sampling
##  Family: gaussian 
##   Links: mu = identity; sigma = identity 
## Formula: outcome_m ~ pred_m + mod_m 
##    Data: dist1 (Number of observations: 1000) 
## Samples: 3 chains, each with iter = 2000; warmup = 1000; thin = 1; 
##          total post-warmup samples = 3000
##     ICs: LOO = NA; WAIC = NA; R2 = NA
##  
## Population-Level Effects: 
##           Estimate Est.Error l-95% CI u-95% CI Eff.Sample Rhat
## Intercept     1.40      0.16     1.10     1.72       3000 1.00
## pred_m        0.22      0.04     0.15     0.29       3000 1.00
## mod_m        -0.18      0.04    -0.26    -0.11       3000 1.00
## 
## Family Specific Parameters: 
##       Estimate Est.Error l-95% CI u-95% CI Eff.Sample Rhat
## sigma     1.14      0.03     1.09     1.19       3000 1.00
## 
## Samples were drawn using sampling(NUTS). For each parameter, Eff.Sample 
## is a crude measure of effective sample size, and Rhat is the potential 
## scale reduction factor on split chains (at convergence, Rhat = 1).
summary(g1m2 <- brm(bf(outcome_m ~ pred_m * mod_m), data = dist1, cores = 3, chains = 3))
## Compiling the C++ model
## Start sampling
##  Family: gaussian 
##   Links: mu = identity; sigma = identity 
## Formula: outcome_m ~ pred_m * mod_m 
##    Data: dist1 (Number of observations: 1000) 
## Samples: 3 chains, each with iter = 2000; warmup = 1000; thin = 1; 
##          total post-warmup samples = 3000
##     ICs: LOO = NA; WAIC = NA; R2 = NA
##  
## Population-Level Effects: 
##              Estimate Est.Error l-95% CI u-95% CI Eff.Sample Rhat
## Intercept        1.59      0.38     0.84     2.35        886 1.00
## pred_m           0.16      0.12    -0.07     0.39        919 1.00
## mod_m           -0.25      0.12    -0.48    -0.01        888 1.00
## pred_m:mod_m     0.02      0.04    -0.05     0.09        923 1.00
## 
## Family Specific Parameters: 
##       Estimate Est.Error l-95% CI u-95% CI Eff.Sample Rhat
## sigma     1.14      0.03     1.09     1.18       1876 1.00
## 
## Samples were drawn using sampling(NUTS). For each parameter, Eff.Sample 
## is a crude measure of effective sample size, and Rhat is the potential 
## scale reduction factor on split chains (at convergence, Rhat = 1).
LOO(g1m1, g1m2)
##               LOOIC    SE
## g1m1        3095.82 84.03
## g1m2        3098.08 83.98
## g1m1 - g1m2   -2.26  1.17
list(g1m1, g1m2) %>% multiplot

summary(g1mc1 <- brm(bf(outcome_m ~ pred_m + mod_m), data = dist1, cores = 3, chains = 3, family = cumulative(threshold = "equidistant")))
## Compiling the C++ model
## Start sampling
##  Family: cumulative 
##   Links: mu = logit; disc = identity 
## Formula: outcome_m ~ pred_m + mod_m 
##    Data: dist1 (Number of observations: 1000) 
## Samples: 3 chains, each with iter = 2000; warmup = 1000; thin = 1; 
##          total post-warmup samples = 3000
##     ICs: LOO = NA; WAIC = NA; R2 = NA
##  
## Population-Level Effects: 
##              Estimate Est.Error l-95% CI u-95% CI Eff.Sample Rhat
## Intercept[1]     1.83      0.36     1.17     2.57       3000 1.00
## Intercept[2]     2.43      0.36     1.76     3.15       3000 1.00
## Intercept[3]     3.02      0.37     2.33     3.76       3000 1.00
## Intercept[4]     3.61      0.38     2.91     4.38       3000 1.00
## Intercept[5]     4.21      0.39     3.46     5.00       3000 1.00
## pred_m           0.53      0.08     0.37     0.68       2877 1.00
## mod_m           -0.39      0.08    -0.55    -0.22       3000 1.00
## 
## Family Specific Parameters: 
##       Estimate Est.Error l-95% CI u-95% CI Eff.Sample Rhat
## delta     0.59      0.04     0.52     0.67       3000 1.00
## 
## Samples were drawn using sampling(NUTS). For each parameter, Eff.Sample 
## is a crude measure of effective sample size, and Rhat is the potential 
## scale reduction factor on split chains (at convergence, Rhat = 1).
summary(g1mc2 <- brm(bf(outcome_m ~ pred_m * mod_m), data = dist1, cores = 3, chains = 3, family = cumulative( threshold = "equidistant")))
## Compiling the C++ model
## Start sampling
##  Family: cumulative 
##   Links: mu = logit; disc = identity 
## Formula: outcome_m ~ pred_m * mod_m 
##    Data: dist1 (Number of observations: 1000) 
## Samples: 3 chains, each with iter = 2000; warmup = 1000; thin = 1; 
##          total post-warmup samples = 3000
##     ICs: LOO = NA; WAIC = NA; R2 = NA
##  
## Population-Level Effects: 
##              Estimate Est.Error l-95% CI u-95% CI Eff.Sample Rhat
## Intercept[1]     0.02      0.86    -1.60     1.67       1150 1.00
## Intercept[2]     0.62      0.86    -1.01     2.26       1149 1.00
## Intercept[3]     1.21      0.86    -0.42     2.87       1150 1.00
## Intercept[4]     1.80      0.86     0.16     3.47       1153 1.00
## Intercept[5]     2.40      0.87     0.74     4.09       1159 1.00
## pred_m          -0.01      0.25    -0.49     0.47       1134 1.00
## mod_m           -1.03      0.30    -1.60    -0.46       1138 1.00
## pred_m:mod_m     0.19      0.08     0.03     0.35       1107 1.00
## 
## Family Specific Parameters: 
##       Estimate Est.Error l-95% CI u-95% CI Eff.Sample Rhat
## delta     0.59      0.04     0.52     0.67       2210 1.00
## 
## Samples were drawn using sampling(NUTS). For each parameter, Eff.Sample 
## is a crude measure of effective sample size, and Rhat is the potential 
## scale reduction factor on split chains (at convergence, Rhat = 1).
LOO(g1mc1, g1mc2)
##                 LOOIC    SE
## g1mc1         1637.05 72.69
## g1mc2         1633.81 72.52
## g1mc1 - g1mc2    3.23  4.49
list(g1mc1, g1mc2) %>% multiplot

list(g1m1, g1m2, g1mc1, g1mc2) %>% multiplot