simData: Simulate data from a given density function via multinomial...

Description Usage Arguments Details Value Examples

View source: R/simData.R

Description

Simulate data from a given density function via multinomial sampling

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
simData(
  n,
  pars,
  tt,
  pdfND,
  fun.density = Voss.density,
  args.density = list(prec = 3),
  npars = 5,
  return.pdf = FALSE,
  normalizePdfs = TRUE
)

Arguments

n

Number of observations to be sampled

pars

Parameter values for the density function to be evaluated with. length(pars) must be a multiple of npars.

tt

time grid on which the density function will be evaluated. Responses not in this time grid cannot appear.

pdfND

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.

fun.density

Density function to use.

args.density

Additional arguments to be passed to fun.density, aside from tt, pars, and a boundary argument ('upper' or 'lower')

npars

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.

return.pdf

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.

normalizePdfs

Logical, should the pdf of the nondecision distribution be normalized?

Details

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.

Value

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.

Examples

1
2
3
4
5
6
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)

DstarM documentation built on Aug. 29, 2020, 1:06 a.m.