Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

BayesFactorSlope

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 traitMPT with predictor variables that have been defined via predStructure.

parameter

name of the slope parameter (e.g., "slope_d_covariate").

direction

alternative hypothesis: whether slope is smaller or larger than zero ("<" or ">") or unequal to zero ("!=").

approx

how to approximate the posterior density of the slope parameter at zero: approx="normal" uses a normal approximation to all samples and approx="logspline" uses a nonparametric density estimate of the package logspline. Usually, both methods provide similar results.

plot

if TRUE, the prior and posterior densities and the ratio at slope=0 are plotted.

...

further arguments passed to logspline, which is used to approximate the density of the posterior distribution.

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 evalauted at slope=0. 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).

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)

TreeBUGS

Hierarchical Multinomial Processing Tree Modeling

v1.4.7
GPL-3
Authors
Daniel W. Heck [aut, cre] (<https://orcid.org/0000-0002-6302-9252>), Nina R. Arnold [aut, dtc], Denis Arnold [aut], Alexander Ly [ctb], Marius Barth [ctb] (<https://orcid.org/0000-0002-3421-6665>)
Initial release
2021-01-08

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.