Simulate data from a given density function via multinomial sampling
simData(
n,
pars,
tt,
pdfND,
fun.density = Voss.density,
args.density = list(prec = 3),
npars = 5,
return.pdf = FALSE,
normalizePdfs = TRUE
)
A sorted dataframe where rows represent trials. It contains: a column named rt
containing reaction times in seconds, a column named response containing either
response option lower or upper, and a column named condition indicating which
condition a trials belongs to. If return.pdf
is TRUE it returns a list where the
first element is the sorted dataframe, the second through the fifth elements are lists
that contain densities used for simulating data.
Number of observations to be sampled
Parameter values for the density function to be evaluated with. length(pars)
must be a multiple of npars.
time grid on which the density function will be evaluated. Responses not in this time grid cannot appear.
either a vector of length tt specifying the nondecision density for all condition-response pairs,
or a matrix where columns corresponds to the nondecision densities of condition-response pairs. Supplying NULL
implies no nondecision distribution.
Density function to use.
Additional arguments to be passed to fun.density
, aside from tt
, pars
, and a boundary argument ('upper' or 'lower')
Number of parameters fun.density
must be evaluated with. If length(pars) > npars
each npars
values in pars
will be seen as the parameter values of a condition.
Logical, if TRUE genData
returns a list containing the probability density function used and the data, if FALSE genData
returns a dataframe with simulated data.
Logical, should the pdf of the nondecision distribution be normalized?
Simulate data via multinomial sampling.
The response options to sample from should be provided in tt
.
The number of conditions is defined as length(pars) / npars
.
tt = seq(0, 5, .01)
pdfND = dbeta(tt, 10, 30)
n = 100
pars = c(1, 2, .5, .5, .5)
dat = simData(n, pars, tt, pdfND)
head(dat)
Run the code above in your browser using DataLab