extract.modmed.mlm.brms {multilevelmediation}R Documentation

Post-processing of results from modmed.mlm.brms

Description

Post-processing of results from modmed.mlm.brms

Usage

extract.modmed.mlm.brms(
  brms.obj,
  type = c("indirect", "a", "b", "cprime", "covab", "indirect.diff", "a.diff", "b.diff",
    "cprime.diff"),
  ci.type = c("ECI"),
  ci.conf = 0.95,
  modval1 = NULL,
  modval2 = NULL
)

Arguments

brms.obj

Result of boot.modmed.mlm

type

Character indicating which piece of information to extract from the model "indirect": value of the indirect effect. "a": Current value of a path. "b": Current value of b path. "cprime": Current value of c path. "covab": Random effect covariance between a and b paths, if both paths have associated random effects. "indirect.diff": difference in indirect effect at two values of the moderator (set by modval1 and modval2). "a.diff": difference in a at two values of the moderator (set by modval1 and modval2). "b.diff": difference in b at two values of the moderator (set by modval1 and modval2). "cprime.diff": difference cprime at two values of the moderator (set by modval1 and modval2).

ci.type

Character indicating the type of confidence interval to compute. For now, just "ECI" is supported, an equal-tailed credible interval.

ci.conf

Numeric value indicating the confidence level for the credibility interval.

modval1

If enabled, other quantities such as the indirect effect, a, b, and cprime, will be computed at this particular value of the moderator. Otherwise, value of these quantities is directly extracted from the model output (i.e., these would represent values of the effects when the moderator = 0).

modval2

Second value of the moderator at which to compute the indirect effect.

Details

This function generally assumes that type="all" was used when initially fitting the model, making all necessary information available for computation of indirect effects, differences between effects, and so on. If type="all" was not used, there is no guarantee that credibility intervals for the effects of interest can be extracted.

Value

A list with two elements:

Examples


data(BPG06dat)

# Note: 2000 iterations is just an example so that run time is not too long.
# Pick something larger (e.g., 5000+) in practice

# Only fixed effects with random intercept
fit<-modmed.mlm.brms(BPG06dat,"id", "x", "y" , "m", cores = 2,
                     iter = 2000, control = list(adapt_delta=0.95),
                     seed = 1234)


res.indirect <- extract.modmed.mlm.brms(fit, "indirect")
res.a <- extract.modmed.mlm.brms(fit, "a")
res.b <- extract.modmed.mlm.brms(fit, "b")
res.cprime <- extract.modmed.mlm.brms(fit, "cprime")

# Summary of results is in CI slot, example.
# Here, 95% credibility interval is denoted by q2.5 and q97.5
res.indirect$CI

# Matrix of draws in another slot:
res.indirect$draws




[Package multilevelmediation version 0.3.1 Index]