Fit a Hierarchical Latent-Trait MPT Model
Fits a latent-trait MPT model (Klauer, 2010) based on a standard MPT model file (.eqn) and individual data table (.csv).
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, modelfilename, parEstFile, posteriorFile, autojags = NULL, ... )
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 g (= the inverse of the variance)
of the standardized slope parameters of continuous covariates.
The default |
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 |
modelfilename |
Name that the modelfile that is made by the function to work with JAGS should get. 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 rguments to be passed to the JAGS sampling function
(i.e., to |
a list of the class traitMPT
with the objects:
summary
: MPT tailored summary. Use summary(fittedModel)
mptInfo
: info about MPT model (eqn and data file etc.)
mcmc
: the object returned from the MCMC sampler.
Note that the object fittedModel$mcmc
is an
runjags object, whereas
fittedModel$mcmc$mcmc
is an mcmc.list
as used by
the coda package (mcmc)
Continuous and discrete predictors are added on the latent-probit scale via:
θ = Φ(μ + X β +δ ),
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 β that correspond to the scale/SD of the predictor variables. Hence, slope estimates will be very small if the covariate has a large variance.
For continuous predictors, the default prior IVprec = "dgamma(.5,.5)"
implies
a Cauchy prior on each standardized β. 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 as in Rouder & Morey (2012),
TreeBUGS implements a latent-probit regression where the prior on the coefficients
β is only scaled with respect to the
covariates 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)'
.
To use a standard-normal priors on the standardized slopes, use IVprec = 'dcat(1)'
.
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 δ[i] (=random-intercepts)
are decomposed by the scaling parameter ξ and the raw deviation ε[i]
(cf. Gelman, 2006):
δ[i] = ξ * ε[i]
ε[i] ~ Normal(0,σ^2)
σ^2 ~ Inverse_Chisquare(df)
Note that the default prior for ξ should be changed to xi="dnorm(0,1)"
, which
results in a half-Cauchy prior (Gelman, 2006).
Daniel W. Heck, Denis Arnold, Nina R. Arnold
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.
Gelman, A. (2006). Prior distributions for variance parameters in hierarchical models (comment on article by Browne and Draper). Bayesian Analysis, 1, 515-534.
Klauer, K. C. (2010). Hierarchical multinomial processing tree models: A latent-trait approach. Psychometrika, 75, 70-98.
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.
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.
Rouder, J. N., & Morey, R. D. (2012). Default Bayes Factors for Model Selection in Regression. Multivariate Behavioral Research, 47, 877-903.
## 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)
Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.