sim_ertmpt_data {rtmpt}R Documentation

Simulate data from RT-MPT models

Description

Simulate data from RT-MPT models using ertmpt_model objects. You can specify the random seed, number of subjects, number of trials per tree, and some parameters (mainly the same as prior_params from fit_ertmpt).

Usage

sim_ertmpt_data(model, seed, n.subj, n.trials, params = NULL)

Arguments

model

A list of the class ertmpt_model.

seed

Random seed number.

n.subj

Number of subjects.

n.trials

Number of trials per tree.

params

Named list of parameters from which the data will be generated. This must be the same named list as prior_params from fit_ertmpt, except for "mean_of_mu_alpha" and "var_of_mu_alpha", and has the same defaults. The difference to prior_params is, that vectors are allowed, but must match the length of the parameters in the model. It is not recommended to use the defaults since they lead to many probabilities close or equal to 0 and/or 1 and to RTs close or equal to 0. Allowed parameters are:

  • mean_of_mu_alpha: Probit transformed mean probability. If you want to have a group-level mean probability of 0.6, use mean_of_mu_alpha = qnorm(0.6) in the params list. Default is 0 or qnorm(.5).

  • var_of_mu_alpha: Variance of the probit transformed group-level mean probability. If specified, mu_alpha will be sampled from N(mean_of_mu_alpha, var_of_mu_alpha). If not, mu_alpha = mean_of_mu_alpha.

  • mean_of_exp_mu_beta: This is the expected exponential rate (E(exp(beta)) = E(lambda)) and 1/mean_of_exp_mu_beta is the expected process time (1/E(exp(beta)) = E(tau)). The default mean is set to 10, such that the expected process time is 0.1 seconds. For a mean process time of 200 ms, wirte mean_of_exp_mu_beta = 1000/200.

  • var_of_exp_mu_beta: The group-specific variance of the exponential rates. Since exp(mu_beta) is Gamma distributed, the rate of the distribution is just mean divided by variance and the shape is the mean times the rate. If specified, exp(mu_beta) is sampled from Gammashape = mean_of_exp_mu_beta^2/var_of_exp_mu_beta, rate = mean_of_exp_mu_beta/var_of_exp_mu_beta). If not, mu_alpha = mean_of_exp_mu_beta.

  • mean_of_mu_gamma: This is the expected mean parameter of the encoding and response execution times, which follow a normal distribution truncated from below at zero, so E(mu_gamma) < E(gamma). The default is 0. For a mean motor time of 550 ms write mean_of_mu_gamma = 550/1000.

  • var_of_mu_gamma: The group-specific variance of the mean parameter. If specified, mu_gamma is sampled from N(mean_of_mu_gamma, var_of_mu_gamma). If not, mu_gamma = mean_of_mu_gamma.

  • mean_of_omega_sqr: This is the expected residual variance (E(omega^2)). The default is 0.005.

  • var_of_omega_sqr: The variance of the residual variance (Var(omega^2)). If specified, omega_sqr is sampled from GAMMA(shape = mean_of_omega_sqr^2/var_of_omega_sqr, rate = mean_of_omega_sqr/var_of_omega_sqr). If not, omega_sqr = mean_of_omega_sqr. 0.01. The default of the mean and variance is equivalent to a shape and rate of 0.0025 and 0.5, respectivly.

  • df_of_sigma_sqr: Degrees of freedom for the individual variance of the response executions. The individual variance follows a scaled inverse chi-squared distribution with df_of_sigma_sqr degrees of freedom and omega^2 as scale. 2 is the default and it should be an integer.

  • sf_of_scale_matrix_SIGMA: The original scaling matrix (S) of the (scaled) inverse Wishart distribution for the process related parameters is an identity matrix S=I. sf_of_scale_matrix_SIGMA is a scaling factor, that scales this matrix (S=sf_of_scale_matrix_SIGMA*I). Its default is 1.

  • sf_of_scale_matrix_GAMMA: The original scaling matrix (S) of the (scaled) inverse Wishart distribution for the encoding and motor execution parameters is an identity matrix S=I. sf_of_scale_matrix_GAMMA is a scaling factor that scales this matrix (S=sf_of_scale_matrix_GAMMA*I). Its default is 1.

  • prec_epsilon: This is epsilon in the paper. It is the precision of xi (scaling parameter in the scaled inverse Wishart distribution). Its default is also 1.

  • add_df_to_invWish: If P is the number of parameters or rather the size of the scale matrix used in the (scaled) inverse Wishart distribution then add_df_to_invWish is the number of degrees of freedom that can be added to it. So DF = P + add_df_to_invWish. The default for add_df_to_invWish is 1, such that the correlations are uniformly distributed within [-1, 1].

  • SIGMA: Variance-covariance matrix of the process-related parameters. It must match the number of process-related parameters to be estimated. If scalars or vectors are given, they will be transformed into diagonal matrices using diag(SIGMA). If not specified it will be randomly generated using diag(xi)%*%rinvwishart(nu, S)%*%diag(xi), where nu is the number of process-related group-level parameters to be estimated plus add_df_to_invWish, S is the identity matrix multiplied by sf_of_scale_matrix_SIGMA, and xi (randomly generated from N(1, 1/prec_epsilon)) are the scaling factors for the scaled inverse wishart distribution. If SIGMA is used, sf_of_scale_matrix_SIGMA and add_df_to_invWish will be ignored for the process-related parameters.

  • GAMMA: Variance-covariance matrix of the motor time parameters. It must match the number of motor time parameters to be estimated. If scalars or vectors are given, they will be transformed into diagonal matrices using diag(SIGMA). If not specified it will be randomly generated using diag(xi)%*%rinvwishart(nu, S)%*%diag(xi), where nu is the number of motor time group-level parameters to be estimated plus add_df_to_invWish, S is the identity matrix multiplied by sf_of_scale_matrix_GAMMA, and xi (randomly generated from N(1, 1/prec_epsilon)) are the scaling factors for the scaled inverse wishart distribution. If GAMMA is used, sf_of_scale_matrix_GAMMA and add_df_to_invWish will be ignored for the motor time parameters.

Value

A list of the class ertmpt_sim containing

Author(s)

Raphael Hartmann

Examples

########################################################################################
# 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
do+(1-do)*g     ; 0
(1-do)*(1-g)    ; 1

# lures
(1-dn)*g        ; 0
dn+(1-dn)*(1-g) ; 1

# do: detect old; dn: detect new; g: guess
"

model <- to_ertmpt_model(mdl_file = mdl_2HTM)

# random group-level parameters
params <- list(mean_of_mu_alpha = 0, 
               #var_of_mu_alpha = 1
               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)

sim_dat <- sim_ertmpt_data(model, seed = 123, n.subj = 40, n.trials = 30, params = params)

# fixed group-level parameters
params <- list(mean_of_mu_alpha = 0, 
               mean_of_exp_mu_beta = 10, 
               mean_of_mu_gamma = 0.5, 
               mean_of_omega_sqr = 0.005, 
               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,
               SIGMA = diag(9),   # independent process-related params
               GAMMA = diag(2))   # independent motor time params

sim_dat <- sim_ertmpt_data(model, seed = 123, n.subj = 40, n.trials = 30, params = params)


[Package rtmpt version 2.0-1 Index]