fit_ertmpt | R Documentation |
Given model and data, this function calls an altered version of the C++ program by Klauer and Kellen (2018) to sample from
the posterior distribution via a Metropolis-Gibbs sampler and storing it in an mcmc.list called samples
.
Posterior predictive checks developed by Klauer (2010), deviance information criterion (DIC; Spiegelhalter et al., 2002),
99% and 95% highest density intervals (HDI) together with the median will be provided for the main parameters in a list
called diags
. Optionally, the indices
widely applicable information criterion (WAIC; Watanabe, 2010; Vehtari et al., 2017) and
leave-one-out cross-validation (LOO; Vehtari et al., 2017) can be saved. Additionally the log-likelihood (LogLik
) can also be stored.
Some specifications of the function call are also saved in specs
.
fit_ertmpt(
model,
data,
n.chains = 4,
n.iter = 5000,
n.burnin = 200,
n.thin = 1,
Rhat_max = 1.05,
Irep = 1000,
prior_params = NULL,
indices = FALSE,
save_log_lik = FALSE,
old_label = FALSE
)
model |
A list of the class |
data |
Optimally, a list of class |
n.chains |
Number of chains to use. Default is 4. Must be larger than 1 and smaller or equal to 16. |
n.iter |
Number of samples per chain. Default is 5000. |
n.burnin |
Number of warm-up samples. Default is 200. |
n.thin |
Thinning factor. Default is 1. |
Rhat_max |
Maximal Potential scale reduction factor: A lower threshold that needs to be reached before the actual sampling starts. Default is 1.05 |
Irep |
Every
|
prior_params |
Named list with prior parameters. All parameters have default values, that lead to uninformative priors. Vectors are not allowed. Allowed parameters are:
|
indices |
Model selection indices. If set to |
save_log_lik |
If set to |
old_label |
If set to |
A list of the class ertmpt_fit
containing
samples
: the posterior samples as an mcmc.list
object,
diags
: some diagnostics like deviance information criterion, posterior predictive checks for the frequencies and latencies,
potential scale reduction factors, and also the 99% and 95% HDIs and medians for the group-level parameters,
specs
: some model specifications like the model, arguments of the model call, and information about the data transformation,
indices
(optional): if enabled, WAIC and LOO,
LogLik
(optional): if enabled, the log-likelihood matrix used for WAIC and LOO.
summary
includes posterior mean and median of the main parameters.
Raphael Hartmann
Hartmann, R., Johannsen, L., & Klauer, K. C. (2020). rtmpt: An R package for fitting response-time extended multinomial processing tree models. Behavior Research Methods, 52(3), 1313–1338.
Hartmann, R., & Klauer, K. C. (2020). Extending RT-MPTs to enable equal process times. Journal of Mathematical Psychology, 96, 102340.
Klauer, K. C. (2010). Hierarchical multinomial processing tree models: A latent-trait approach. Psychometrika, 75(1), 70-98.
Klauer, K. C., & Kellen, D. (2018). RT-MPTs: Process models for response-time distributions based on multinomial processing trees with applications to recognition memory. Journal of Mathematical Psychology, 82, 111-130.
Spiegelhalter, D. J., Best, N. G., Carlin, B. P., & Van Der Linde, A. (2002). Bayesian measures of model complexity and fit. Journal of the royal statistical society: Series b (statistical methodology), 64(4), 583-639.
Vehtari, A., Gelman, A., & Gabry, J. (2017). Practical Bayesian model evaluation using leave-one-out cross-validation and WAIC. Statistics and Computing, 27(5), 1413-1432.
Watanabe, S. (2010). Asymptotic equivalence of Bayes cross validation and widely applicable information criterion in singular learning theory. Journal of Machine Learning Research, 11(Dec), 3571-3594.
####################################################################################
# Detect-Guess variant of the Two-High Threshold model.
# The encoding and motor execution times are assumed to be equal for each response.
####################################################################################
mdl_2HTM <- "
# targets
do+(1-do)*g
(1-do)*(1-g)
# lures
(1-dn)*g
dn+(1-dn)*(1-g)
# do: detect old; dn: detect new; g: guess
"
model <- to_ertmpt_model(mdl_file = mdl_2HTM)
data_file <- system.file("extdata/data.txt", package="rtmpt")
data <- read.table(file = data_file, header = TRUE)
data_list <- to_ertmpt_data(raw_data = data, model = model)
# This might take some time
ertmpt_out <- fit_ertmpt(model = model, data = data_list, Rhat_max = 1.1)
ertmpt_out
# Type ?SimData for another working example.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.