traitMPT {TreeBUGS} | R Documentation |
Fit a Hierarchical Latent-Trait MPT Model
Description
Fits a latent-trait MPT model (Klauer, 2010) based on a standard MPT model file (.eqn) and individual data table (.csv).
Usage
traitMPT(
eqnfile,
data,
restrictions,
covData,
predStructure,
predType,
transformedParameters,
corProbit = TRUE,
mu = "dnorm(0,1)",
xi = "dunif(0,10)",
V,
df,
IVprec = "dgamma(.5,.5)",
n.iter = 20000,
n.adapt = 2000,
n.burnin = 2000,
n.thin = 5,
n.chains = 3,
dic = FALSE,
ppp = 0,
monitorIndividual = TRUE,
modelfilename,
parEstFile,
posteriorFile,
autojags = NULL,
...
)
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 |
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.,
|
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 |
predStructure |
Defines which variables in |
predType |
a character vector specifying the type of continuous or
discrete predictors in each column of |
transformedParameters |
list with parameter transformations that should
be computed based on the posterior samples of the group-level means (e.g.,
for testing parameter differences: |
corProbit |
whether to use probit-transformed MPT parameters to compute
correlations (probit-values of |
mu |
hyperprior for group means of probit-transformed parameters in JAGS
syntax. Default is a standard normal distribution, which implies a uniform
distribution on the MPT probability parameters. A named vector can be used
to specify separate hyperpriors for each MPT parameter (the order of
parameters is determined by the names of the vector or by the default order
as shown in |
xi |
hyperprior for scaling parameters of the group-level parameter
variances. Default is a uniform distribution on the interval [0,10].
Similarly as for |
V |
S x S matrix used as a hyperprior for the inverse-Wishart hyperprior parameters with as many rows and columns as there are core MPT parameters. Default is a diagonal matrix. |
df |
degrees of freedom for the inverse-Wishart hyperprior for the individual parameters. Minimum is S+1, where S gives the number of core MPT parameters. |
IVprec |
hyperprior on the precision parameter |
n.iter |
Number of iterations per chain (including burnin samples). See
|
n.adapt |
number of adaption samples to adjust MCMC sampler in JAGS. The sampler will be more efficient if it is tuned well. However, MCMC sampling will still give correct results even if the warning appears: "Adaptation incomplete." (this just means that sampling efficiency could be better). |
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). |
dic |
whether to compute DIC using
|
ppp |
number of samples to compute posterior predictive p-value (see
|
monitorIndividual |
whether to store MCMC samples of the MPT
parameters |
modelfilename |
name of the generated JAGS model file. Default is to write this information to the tempdir as required by CRAN standards. |
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 |
autojags |
JAGS first fits the MPT model as usual and then draws MCMC
samples repeatedly until convergence. For this, the function
|
... |
further arguments to be passed to the JAGS sampling function
(i.e., to |
Value
a list of the class traitMPT
with the objects:
-
summary
: MPT tailored summary. Usesummary(fittedModel)
-
mptInfo
: info about MPT model (eqn and data file etc.) -
mcmc
: the object returned from the MCMC sampler. Note that the objectfittedModel$mcmc
is an runjags object, whereasfittedModel$mcmc$mcmc
is anmcmc.list
as used by the coda package (mcmc)
Regression Extensions
Continuous and discrete predictors are added on the latent-probit scale via:
\theta = \Phi(\mu + X \beta +\delta
),
where X
is a design matrix includes centered continuous
covariates and recoded factor variables (using the orthogonal contrast
coding scheme by Rouder et al., 2012). Note that both centering and
recoding is done internally. TreeBUGS reports unstandardized regression
coefficients \beta
that correspond to the scale/SD of the predictor
variables. Hence, slope estimates will be very small if the covariate has a
large variance. TreeBUGS also reports standardized slope parameters
(labeled with std
) which are standardized both with respect to the
variance of the predictor variables and the variance in the individual MPT
parameters. If a single predictor variable is included, the standardized
slope can be interpreted as a correlation coefficient (Jobst et al., 2020).
For continuous predictor variables, the default prior IVprec =
"dgamma(.5,.5)"
implies a Cauchy prior on the \beta
parameters
(standardized with respect to the variance of the predictor variables).
This prior is similar to the Jeffreys-Zellner-Siow (JZS) prior with scale
parameter s=1
(for details, see: Rouder et. al, 2012; Rouder & Morey,
2012). In contrast to the JZS prior for standard linear regression by
Rouder & Morey (2012), TreeBUGS implements a latent-probit regression where
the prior on the coefficients \beta
is only standardized/scaled with
respect to the continuous predictor variables but not with respect to the
residual variance (since this is not a parameter in probit regression). If
small effects are expected, smaller scale values s
can be used by
changing the default to IVprec = 'dgamma(.5, .5*s^2)'
(by plugging
in a specific number for s
). To use a standard-normal instead of a
Cauchy prior distribution, use IVprec = 'dcat(1)'
. Bayes factors for
slope parameters of continuous predictors can be computed with the function
BayesFactorSlope.
Uncorrelated Latent-Trait Values
The standard latent-trait MPT model assumes a multivariate normal distribution of the latent-trait values, where the covariance matrix follows a scaled-inverse Wishart distribution. As an alternative, the parameters can be assumed to be independent (this is equivalent to a diagonal covariance matrix). If the assumption of uncorrelated parameters is justified, such a simplified model has less parameters and is more parsimonious, which in turn might result in more robust estimation and more precise parameter estimates.
This alternative method can be fitted in TreeBUGS (but not all of the
features of TreeBUGS might be compatible with this alternative model
structure). To fit the model, the scale matrix V
is set to NA
(V is only relevant for the multivariate Wishart prior) and the prior on
xi
is changed: traitMPT(..., V=NA, xi="dnorm(0,1)")
. The
model assumes that the latent-trait values \delta_i
(=random-intercepts) are decomposed by the scaling parameter \xi
and
the raw deviation \epsilon_i
(cf. Gelman, 2006):
\delta_i = \xi
\cdot \epsilon_i
\epsilon_i \sim Normal(0,\sigma^2)
\sigma^2
\sim Inverse-\chi^2(df)
Note that the default prior for \xi
should
be changed to xi="dnorm(0,1)"
, which results in a half-Cauchy prior
(Gelman, 2006).
Author(s)
Daniel W. Heck, Denis Arnold, Nina R. Arnold
References
Heck, D. W., Arnold, N. R., & Arnold, D. (2018). TreeBUGS: An R package for hierarchical multinomial-processing-tree modeling. Behavior Research Methods, 50, 264–284. doi:10.3758/s13428-017-0869-7
Gelman, A. (2006). Prior distributions for variance parameters in hierarchical models (comment on article by Browne and Draper). Bayesian Analysis, 1, 515-534.
Jobst, L. J., Heck, D. W., & Moshagen, M. (2020). A comparison of correlation and regression approaches for multinomial processing tree models. Journal of Mathematical Psychology, 98, 102400. doi:10.1016/j.jmp.2020.102400
Klauer, K. C. (2010). Hierarchical multinomial processing tree models: A latent-trait approach. Psychometrika, 75, 70-98. doi:10.1007/s11336-009-9141-0
Matzke, D., Dolan, C. V., Batchelder, W. H., & Wagenmakers, E.-J. (2015). Bayesian estimation of multinomial processing tree models with heterogeneity in participants and items. Psychometrika, 80, 205-235. doi:10.1007/s11336-013-9374-9
Rouder, J. N., Morey, R. D., Speckman, P. L., & Province, J. M. (2012). Default Bayes factors for ANOVA designs. Journal of Mathematical Psychology, 56, 356-374. doi:10.1016/j.jmp.2012.08.001
Rouder, J. N., & Morey, R. D. (2012). Default Bayes Factors for Model Selection in Regression. Multivariate Behavioral Research, 47, 877-903. doi:10.1080/00273171.2012.734737
Examples
## Not run:
# 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 <- traitMPT(EQNfile, d.encoding,
n.thin = 5,
restrictions = list("D1=D2=D3", "d1=d2", "a=g")
)
# convergence
plot(fit, parameter = "mean", type = "default")
summary(fit)
## End(Not run)