BayesFactorSlope {TreeBUGS} | R Documentation |
Bayes Factor for Slope Parameters in Latent-Trait MPT
Description
Uses the Savage-Dickey method to compute the Bayes factor that the slope
parameter of a continuous covariate in traitMPT
is zero vs.
positive/negative/unequal to zero.
Usage
BayesFactorSlope(
fittedModel,
parameter,
direction = "!=",
approx = "normal",
plot = TRUE,
...
)
Arguments
fittedModel |
a fitted latent-trait model fitted with
|
parameter |
name of the slope parameter (e.g.,
|
direction |
alternative hypothesis: whether slope is smaller or larger
than zero ( |
approx |
how to approximate the posterior density of the slope parameter
at zero: |
plot |
if |
... |
further arguments passed to |
Details
The Bayes factor is computed with the Savage-Dickey method, which is
defined as the ratio of the density of the posterior and the density of the
prior evaluated at slope=0
(Heck, 2019). Note that this method cannot
be used with default JZS priors (IVprec="dgamma(.5,.5)"
) if more than
one predictor is added for an MPT parameter. As a remedy, a g-prior (normal
distribution) can be used on the slopes by setting the hyperprior parameter
g
to a fixed constant when fitting the model: traitMPT(...,
IVprec = 1)
(see Heck, 2019).
References
Heck, D. W. (2019). A caveat on the Savage-Dickey density ratio: The case of computing Bayes factors for regression parameters. British Journal of Mathematical and Statistical Psychology, 72, 316–333. doi:10.1111/bmsp.12150
Examples
## Not run:
# latent-trait MPT model for the encoding condition (see ?arnold2013):
EQNfile <- system.file("MPTmodels/2htsm.eqn", package = "TreeBUGS")
d.enc <- subset(arnold2013, group == "encoding")
fit <- traitMPT(EQNfile,
data = d.enc[, -(1:4)], n.thin = 5,
restrictions = list("D1=D2=D3", "d1=d2", "a=g"),
covData = d.enc[, c("age", "pc")],
predStructure = list("D1 ; age")
)
plot(fit, parameter = "slope", type = "default")
summary(fit)
BayesFactorSlope(fit, "slope_D1_age", direction = "<")
## End(Not run)