View source: R/SBC_fit_rtmpt.R
fit_ertmpt_SBC | R Documentation |
Simulate data from RT-MPT models using ertmpt_model
objects. The difference to sim_ertmpt_data
is that here only scalars are allowed. This makes it usable for
simulation-based calibration (SBC; Talts et al., 2018). You can specify the random seed, number of subjects, number of trials, and some
parameters (same as prior_params
from fit_ertmpt
).
fit_ertmpt_SBC(
model,
seed,
n.eff_samples = 99,
n.chains = 4,
n.iter = 5000,
n.burnin = 200,
n.thin = 1,
Rhat_max = 1.05,
Irep = 1000,
n.subj = 40,
n.trials = 30,
prior_params = NULL,
sim_list = NULL
)
model |
A list of the class |
seed |
Random seed number. |
n.eff_samples |
Number of effective samples. Default is 99, leading to 100 possible ranks (from 0 to 99). |
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. Must be larger or equal to |
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
|
n.subj |
Number of subjects. Default is 40. |
n.trials |
Number of trials per tree. Default is 30. |
prior_params |
Named list of parameters from which the data will be generated. This must be the same named list as
|
sim_list |
Object of class |
A list of the class ertmpt_sbc
containing
ranks
: the rank statistic for all parameters,
sim_list
: an object of the class ertmpt_sim
,
fit_list
: an object of the class ertmpt_fit
,
specs
: some specifications like the model, seed number, etc.,
Raphael Hartmann
Talts, S., Betancourt, M., Simpson, D., Vehtari, A., & Gelman, A. (2018). Validating Bayesian inference algorithms with simulation-based calibration. arXiv preprint arXiv:1804.06788.
########################################################################################
# Detect-Guess variant of the Two-High Threshold model.
# The encoding and motor execution times are assumed to be different for each response.
########################################################################################
mdl_2HTM <- "
# targets
d+(1-d)*g ; 0
(1-d)*(1-g) ; 1
# lures
(1-d)*g ; 0
d+(1-d)*(1-g) ; 1
# d: detect; g: guess
"
model <- to_ertmpt_model(mdl_file = mdl_2HTM)
params <- list(mean_of_exp_mu_beta = 10,
var_of_exp_mu_beta = 10,
mean_of_mu_gamma = 0.5,
var_of_mu_gamma = 0.0025,
mean_of_omega_sqr = 0.005,
var_of_omega_sqr = 0.000025,
df_of_sigma_sqr = 10,
sf_of_scale_matrix_SIGMA = 0.1,
sf_of_scale_matrix_GAMMA = 0.01,
prec_epsilon = 10,
add_df_to_invWish = 5)
R = 2 # typically 2000 with n.eff_samples = 99, but this will run many days
rank_mat <- matrix(NA, ncol = 393, nrow = 2)
for (r in 1:R) {
SBC_out <- fit_ertmpt_SBC(model, seed = r*123, prior_params = params,
n.eff_samples = 99, n.thin = 5,
n.iter = 5000, n.burnin = 2000, Irep = 5000)
rank_mat[r, ] <- SBC_out$ranks
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.