TreeBUGS (version 1.5.0)

betaMPTcpp: C++ Sampler for Hierarchical Beta-MPT Model

Description

Fast Gibbs sampler in C++ that is tailored to the beta-MPT model.

Usage

betaMPTcpp(
  eqnfile,
  data,
  restrictions,
  covData,
  corProbit = FALSE,
  n.iter = 20000,
  n.burnin = 2000,
  n.thin = 5,
  n.chains = 3,
  ppp = 0,
  shape = 1,
  rate = 0.1,
  parEstFile,
  posteriorFile,
  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.

covData

Data that contains covariates, for which correlations with individual MPT parameters will be sampled. Either the path to a .csv file (comma-separated: rows=individuals in the same order as data; first row must contain covariate labels). Alternatively: a data frame or matrix (rows=individuals, columns = variables; covariate labels as column names). Note that in betaMPT, correlations are computed for discrete variables that are coded numerically (in traitMPT, this can be suppressed by using predType="f")

corProbit

whether to use probit-transformed MPT parameters to compute correlations (probit-values of +Inf are truncated to max(5,max(probit)); similarly for -Inf). Default for beta-MPT: MPT parameters are used on the probability scale [0,1].

n.iter

Number of iterations per chain (including burnin samples). See run.jags for details.

n.burnin

Number of samples for burnin (samples will not be stored and removed from n.iter)

n.thin

Thinning rate.

n.chains

number of MCMC chains (sampled in parallel).

ppp

number of samples to compute posterior predictive p-value (see posteriorPredictive)

shape

shape parameter(s) of Gamma-hyperdistribution for the hierarchical beta-parameters \(\alpha_s\) and \(\beta_s\) (can be a named vector to provide different hyperpriors for each parameter)

rate

rate parameter(s) of Gamma-hyperdistribution

parEstFile

Name of the file to with the estimates should be stored (e.g., "parEstFile.txt")

posteriorFile

path to RData-file where to save the model including MCMC posterior samples (an object named fittedModel; e.g., posteriorFile="mcmc.RData")

cores

number of CPUs to be used

Author

Daniel Heck

Examples

Run this code
if (FALSE) {
# fit beta-MPT model for encoding condition (see ?arnold2013):
EQNfile <- system.file("MPTmodels/2htsm.eqn", package = "TreeBUGS")
d.encoding <- subset(arnold2013, group == "encoding", select = -(1:4))
fit <- betaMPTcpp(EQNfile, d.encoding,
  n.thin = 5,
  restrictions = list("D1=D2=D3", "d1=d2", "a=g")
)
# convergence
plot(fit, parameter = "mean", type = "default")
summary(fit)
}

Run the code above in your browser using DataLab