simulate.model: Simulate RT Data

Description Usage Arguments Details Value Examples

View source: R/random.R

Description

Simulate stochastic responses either for one subject or multiple subjects. The simulation is based on the model object. For one subject, the user must supply true parameters, p.vector at ps argument. For multiple subjects, the user can supply a matrix (or a row vector), indicating true parameters for each subject, separately on each row (via ps argument). This is the fixed-effect model. If the user wants to simulate from a random-effect (i.e., hierarchical) model, in which case p.prior must be supplied and ps will be ignored. Note in some cases, a random-effect model may fail to draw data from the model, because true parameters are drawn from p.prior and a specific model, like DDM, may has certain ranges from different parameters.

Usage

1
2
3
## S3 method for class 'model'
simulate(object, nsim = NA, seed = NULL, nsub = NA,
  prior = NA, ps = NA, ...)

Arguments

object

a model object.

nsim

number of trials/responses. n can be a single number for a balanced design or matrix for an unbalanced design, where rows are subjects and columns are design cells. If the matrix has one row then all subjects have the same n in each cell, if it has one column then all cells have the same n; Otherwise each entry specifies the n for a particular design subject x design cell combination.

seed

an integer specifying if and how the random number generator should be initialized.

nsub

number of subjects

prior

parameter priors. A list of distributions based on which the true parameters fro each subject are drawn. It is usually created by BuildPrior and will be saved as "p.prior" attribute.

ps

p.vector matrix. Each row represent a subject.

...

additional optional arguments.

Details

ps can be a row vector, in which case each subject has identical parameters. It can also be a matrix with one row per subject, in which case it must have ns rows. The true values will be saved as "parameters" attribute.

Value

a data frame

Examples

1
2
3
4
5
6
7
8
model <- BuildModel(
  p.map     = list(a = "1", v = "1", z = "1", d = "1", sz = "1",
  sv = "1", t0 = "1", st0 = "1"),
  match.map = list(M = list(s1 = "r1", s2 = "r2")),
  factors   = list(S = c("s1", "s2")),
  constants = c(st0 = 0, d = 0),
  responses = c("r1", "r2"),
  type      = "rd")

ggdmc documentation built on Sept. 2, 2018, 1:03 a.m.