How to calculate estimated error for monotonic effects?

The estimated error is the standard deviation of the posterior draws (ie. the sample from the posterior distribution of the monotonic effects).

Here is how to estimate the four summaries (Estimate, Est.Error, Q2.5 and Q97.5) for each monotonic effect in turn.

# Extract the posterior draws for the level "40_to_100"
posterior_draws <- posterior_linpred(
  fit,
  newdata = tibble(income = "40_to_100")
)
# Calculate the summaries.
c(
  Estimate = mean(posterior_draws),
  Est.Error = sd(posterior_draws),
  Q2.5 = quantile(posterior_draws, 0.025),
  Q97.5 = quantile(posterior_draws, 0.975)
)

It might also be interesting to know how to compute the monotic effects from the model parameters that appear in summary(fit). This is explained by Eq. (3) in this paper: https://osf.io/preprints/psyarxiv/9qkhj.

D <- 3 # number of income levels - 1

as_draws_df(fit) %>%
  # Rename the parameters as in Eq. (3)
  rename(
    b = bsp_moincome,
    zeta1 = `simo_moincome1[1]`,
    zeta2 = `simo_moincome1[2]`,
    zeta3 = `simo_moincome1[3]`
  ) %>%
  mutate(
    mo_effect0 = b_Intercept,
    mo_effect1 = b_Intercept + b * D * (zeta1),
    mo_effect2 = b_Intercept + b * D * (zeta1 + zeta2),
    mo_effect3 = b_Intercept + b * D * (zeta1 + zeta2 + zeta3)
  )
1 Like