marginalMPT {TreeBUGS}R Documentation

Marginal Likelihood for Simple MPT

Description

Computes the marginal likelihood for simple (fixed-effects, nonhierarchical) MPT models.

Usage

marginalMPT(
  eqnfile,
  data,
  restrictions,
  alpha = 1,
  beta = 1,
  dataset = 1,
  method = "importance",
  posterior = 500,
  mix = 0.05,
  scale = 0.9,
  samples = 10000,
  batches = 10,
  show = TRUE,
  cores = 1
)

Arguments

eqnfile

The (relative or full) path to the file that specifies the MPT model (standard .eqn syntax). Note that category labels must start with a letter (different to multiTree) and match the column names of data. Alternatively, the EQN-equations can be provided within R as a character value (cf. readEQN). Note that the first line of an .eqn-file is reserved for comments and always ignored.

data

The (relative or full) path to the .csv file with the data (comma separated; category labels in first row). Alternatively: a data frame or matrix (rows=individuals, columns = individual category frequencies, category labels as column names)

restrictions

Specifies which parameters should be (a) constant (e.g., "a=b=.5") or (b) constrained to be identical (e.g., "Do=Dn") or (c) treated as fixed effects (i.e., identical for all participants; "a=b=FE"). Either given as the path to a text file with restrictions per row or as a list of restrictions, e.g., list("D1=D2","g=0.5"). Note that numbers in .eqn-equations (e.g., d*(1-g)*.50) are directly interpreted as equality constraints.

alpha

first shape parameter(s) for the beta prior-distribution of the MPT parameters \theta_s (can be a named vector to use a different prior for each MPT parameter)

beta

second shape parameter(s)

dataset

for which data set should Bayes factors be computed?

method

either "importance" (importance sampling using a mixture of uniform and beta-aproximation of the posterior) or "prior" (brute force Monte Carlo sampling from prior)

posterior

number of posterior samples used to approximate importance-sampling densities (i.e., beta distributions)

mix

mixture proportion of the uniform distribution for the importance-sampling density

scale

how much should posterior-beta approximations be downscaled to get fatter importance-sampling density

samples

total number of samples from parameter space

batches

number of batches. Used to compute a standard error of the estimate.

show

whether to show progress

cores

number of CPUs used

Details

Currently, this is only implemented for a single data set!

If method = "prior", a brute-force Monte Carlo method is used and parameters are directly sampled from the prior.Then, the likelihood is evaluated for these samples and averaged (fast, but inefficient).

Alternatively, an importance sampler is used if method = "importance", and the posterior distributions of the MPT parameters are approximated by independent beta distributions. Then each parameter s is sampled from the importance density:

mix*U(0,1) + (1-mix)*Beta(scale*a_s, scale*b_s)

References

Vandekerckhove, J. S., Matzke, D., & Wagenmakers, E. (2015). Model comparison and the principle of parsimony. In Oxford Handbook of Computational and Mathematical Psychology (pp. 300-319). New York, NY: Oxford University Press.

See Also

BayesFactorMPT

Examples

# 2-High-Threshold Model
eqn <- "## 2HTM ##
   Target  Hit  d
   Target  Hit  (1-d)*g
   Target  Miss (1-d)*(1-g)
   Lure    FA   (1-d)*g
   Lure    CR   (1-d)*(1-g)
   Lure    CR   d"
data <- c(
  Hit = 46, Miss = 14,
  FA = 14, CR = 46
)

# weakly informative prior for guessing
aa <- c(d = 1, g = 2)
bb <- c(d = 1, g = 2)
curve(dbeta(x, aa["g"], bb["g"]))

# compute marginal likelihood
htm <- marginalMPT(eqn, data,
  alpha = aa, beta = bb,
  posterior = 200, samples = 1000
)
# second model: g=.50
htm.g50 <- marginalMPT(eqn, data, list("g=.5"),
  alpha = aa, beta = bb,
  posterior = 200, samples = 1000
)

# Bayes factor
# (per batch to get estimation error)
bf <- htm.g50$p.per.batch / htm$p.per.batch
mean(bf) # BF
sd(bf) / sqrt(length(bf)) # standard error of BF estimate


[Package TreeBUGS version 1.5.0 Index]