## 9.2 The estimation and interpretation of standardized regression coefficients in a moderation analysis

### 9.2.1 Variant 1.

We’ve already computed standardized predictors. Now we just need to standardize the criterion, govact.

glbwarm <-
glbwarm %>%
mutate(govact_z = (govact - mean(govact))/sd(govact))

Fit:

model3 <-
update(model1, newdata = glbwarm,
govact_z ~ 1 + negemot_z + age_z + negemot_z:age_z,
chains = 4, cores = 4)
bayes_R2(model3) %>% round(digits = 3)
##    Estimate Est.Error  Q2.5 Q97.5
## R2    0.354     0.022 0.309 0.396
print(model3, digits = 3)
##  Family: gaussian
##   Links: mu = identity; sigma = identity
## Formula: govact_z ~ negemot_z + age_z + negemot_z:age_z
##    Data: glbwarm (Number of observations: 815)
## Samples: 4 chains, each with iter = 2000; warmup = 1000; thin = 1;
##          total post-warmup samples = 4000
##
## Population-Level Effects:
##                 Estimate Est.Error l-95% CI u-95% CI Eff.Sample  Rhat
## Intercept          0.008     0.028   -0.045    0.061       4000 1.000
## negemot_z          0.563     0.029    0.504    0.619       4000 1.000
## age_z             -0.063     0.028   -0.117   -0.007       4000 1.000
## negemot_z:age_z    0.131     0.029    0.074    0.188       4000 1.000
##
## Family Specific Parameters:
##       Estimate Est.Error l-95% CI u-95% CI Eff.Sample  Rhat
## sigma    0.806     0.020    0.769    0.847       4000 1.000
##
## 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).

### 9.2.2 Variant 2.

This time we need to standardize our interaction term, negemot_x_age_z, by hand.

glbwarm <-
glbwarm %>%
mutate(negemot_x_age_z = (negemot_x_age - mean(negemot_x_age))/sd(negemot_x_age))

Now we’re ready to fit.

model4 <-
update(model1, newdata = glbwarm,
govact_z ~ 1 + negemot_z + age_z + negemot_x_age_z,
chains = 4, cores = 4)
bayes_R2(model4) %>% round(digits = 3)
##    Estimate Est.Error Q2.5 Q97.5
## R2    0.354     0.021 0.31 0.394
print(model4, digits = 3)
##  Family: gaussian
##   Links: mu = identity; sigma = identity
## Formula: govact_z ~ negemot_z + age_z + negemot_x_age_z
##    Data: glbwarm (Number of observations: 815)
## Samples: 4 chains, each with iter = 2000; warmup = 1000; thin = 1;
##          total post-warmup samples = 4000
##
## Population-Level Effects:
##                 Estimate Est.Error l-95% CI u-95% CI Eff.Sample  Rhat
## Intercept          0.000     0.029   -0.056    0.056       3171 1.000
## negemot_z          0.168     0.094   -0.020    0.349       1211 1.004
## age_z             -0.366     0.072   -0.510   -0.226       1196 1.005
## negemot_x_age_z    0.508     0.112    0.285    0.728       1172 1.005
##
## Family Specific Parameters:
##       Estimate Est.Error l-95% CI u-95% CI Eff.Sample  Rhat
## sigma    0.807     0.021    0.767    0.849       2907 1.001
##
## 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).

The results correspond nicely to those in Table 9.1.