# Predicting outcomes by combining coefficients

I’m reanalyzing a dataset of student outcome data that I have previously analyzed using frequentist methods. I’ve imputed missing values using MICE and run a bayesian regression of the data (code below). I’m looking at differences in group means on a test that is take before and after a course across demographic groups. In this model test is an indicator variable for pre or posttest.

``````FCI_model_alg <- brm_multiple(
score ~ 1 + test*(collab_pedagogy +  gender_other_new + race_other_new  + female*(black + hawaiian_or_other_pacific_islander + hispanic+ white + hispanic*white) + retake) + (1|course_id:student),
data = MIdata_alg,
seed=1,
chains = 4,
cores=8)
``````

The model runs great, and the coefficients (below) look reasonably similar to what I get from my frequentist analysis.

`````` Links: mu = identity; sigma = identity
Formula: score ~ 1 + test * (collab_pedagogy + gender_other_new + race_other_new + female * (black + hawaiian_or_other_pacific_islander + hispanic + white + hispanic * white) + retake) + (1 | course_id:student)
Data: MIdata_alg (Number of observations: 11214)
Samples: 40 chains, each with iter = 2000; warmup = 1000; thin = 1;
total post-warmup samples = 40000

Group-Level Effects:
~course_id:student (Number of levels: 5607)
Estimate Est.Error l-95% CI u-95% CI Rhat Bulk_ESS Tail_ESS
sd(Intercept)    11.66      0.24    11.19    12.12 1.04      672     2335

Population-Level Effects:
Estimate Est.Error l-95% CI u-95% CI Rhat Bulk_ESS Tail_ESS
Intercept                                         27.58      1.78    24.08    31.06 1.03      987     9042
test                                              11.66      2.08     7.60    15.79 1.06      376     1692
collab_pedagogy                                    5.58      1.02     3.60     7.58 1.01     3667    31943
gender_other_new                                  -0.44      3.76    -7.82     6.91 1.11      221      726
race_other_new                                     1.67      1.78    -1.79     5.16 1.03     1020    10330
female                                            -7.16      1.76   -10.59    -3.71 1.04      620     7502
black                                             -7.61      2.37   -12.23    -2.93 1.04      612     2451
hawaiian_or_other_pacific_islander                 3.14      3.86    -4.46    10.58 1.08      285     1105
hispanic                                          -3.60      1.91    -7.39     0.12 1.02     1386    14867
white                                              6.79      1.59     3.69     9.89 1.04      629     3245
retake                                             3.18      0.84     1.52     4.84 1.04      528     3098
hispanic:white                                     0.85      2.16    -3.34     5.11 1.03      963    12150
female:black                                       2.40      2.87    -3.21     7.98 1.04      551     2236
female:hawaiian_or_other_pacific_islander         -5.45      5.33   -16.08     4.73 1.09      278      759
female:hispanic                                    2.63      2.31    -1.89     7.18 1.02     1858    20145
female:white                                      -5.22      1.89    -8.93    -1.52 1.04      674     4558
test:collab_pedagogy                               2.98      1.27     0.48     5.47 1.12      202      810
test:gender_other_new                              0.45      4.94    -9.51     9.58 1.28      105      320
test:race_other_new                               -1.36      2.02    -5.27     2.62 1.03      871     9918
test:female                                       -0.06      2.06    -4.18     3.90 1.09      274      869
test:black                                        -6.87      3.22   -13.26    -0.61 1.24      115      370
test:hawaiian_or_other_pacific_islander            2.88      4.67    -6.05    12.26 1.16      162      546
test:hispanic                                     -1.43      2.41    -5.99     3.49 1.14      181      360
test:white                                         2.86      1.89    -0.86     6.55 1.11      233      769
test:retake                                        9.24      1.07     7.16    11.37 1.19      140      586
female:hispanic:white                             -1.86      2.71    -7.15     3.48 1.02     1276    16028
test:hispanic:white                               -0.18      2.65    -5.48     4.87 1.12      212      608
test:female:black                                  4.69      3.69    -2.69    11.74 1.18      146      418
test:female:hawaiian_or_other_pacific_islander    -2.07      6.38   -14.50    10.53 1.15      170      871
test:female:hispanic                               0.74      2.87    -4.91     6.31 1.13      202      981
test:female:white                                 -0.29      2.29    -4.71     4.30 1.12      206      555
test:female:hispanic:white                        -1.14      3.32    -7.59     5.35 1.11      222     1063

Family Specific Parameters:
Estimate Est.Error l-95% CI u-95% CI Rhat Bulk_ESS Tail_ESS
sigma    15.42      0.18    15.06    15.76 1.22      127      409

Samples were drawn using sampling(NUTS). For each parameter, Bulk_ESS
and Tail_ESS are effective sample size measures, and Rhat is the potential
scale reduction factor on split chains (at convergence, Rhat = 1).
``````

What I don’t know how to do now is create predicted outcomes for groups that require combining multiple variables. For example, to know how white men did on the posttest I need to combine the white and test:white variables. I know how to do it in a frequentist model, but not in a Bayesian model. Adding the point estimate together is trivial. Figuring out how to combine the uncertainty is what has me stumped. I’m sure this is easy, but any help that you can offer would be greatly appreciated. Thank you!

Generally you do this by obtaining the posterior samples and doing the same computation to each as you indicate you would do to the point estimate. I believe the function `brms::conditional_effects()` does this for you.

1 Like

It looks like that should do the trick. Thank you!!

1 Like