The density (d*()) and random generation (r*()) functions
of the sdm, ddm and ezdm models, of the circular mixture models
(mixture2p, mixture3p and imm), of the signal detection models
(sdt_yn, sdt_mafc, sdt_rating, sdt_dpsdt, sdt_metad,
sdt_ranking and sdt_cdp) and of the psychometric function take their
per-observation arguments as vectors, or as matrices with one row per
observation, and recycle them as stats::dnorm() and stats::rnorm()
do. This page states the rules; the help page of each of these
distributions repeats them under "Vector arguments".
The other distribution functions do not follow these rules yet:
dcswald() and rcswald(), dm3() and rm3(), and dmpt() and
rmpt().
Vector arguments
r*(n, ...)returns exactlyndraws: a vector, or a data frame or matrix withnrows. Every per-observation argument (a parameter, a stimulus, a number of trials) is recycled to lengthnwithrep_len(), as instats::rnorm(): drawiuses elementi, and a matrix is read element by element; only a set of values per draw, such asthresholds, takes rowiof a matrix (see below). A shorter vector is repeated, also whennis not a multiple of its length. Until bmm 1.6.0 at the earliest,rddm()withn = 1and parameter vectors still returns one draw per element, with a deprecation warning.nis a single number of at least 0. A fraction is truncated, as instats::rnorm(), andn = 0gives an empty vector, or a matrix or data frame with zero rows and the usual columns. Unlikestats::rnorm(), which takes the length of a vectorn, these functions stop on one;rddm()still takes its length, with a deprecation warning.d*(x, ...)returns one value per observation: as many as the longest ofx(its rows, when the observations are rows of counts) and the per-observation arguments, the others recycled to that length. Valueiis what the call on thei-th elements alone returns. A matrix in an argument that takes one number per observation, such asxord, holds one observation per element, as instats::dnorm(). Whenxor any per-observation argument is empty, the result is empty, as instats::dnorm(). ANULLargument, such as a misspelt column of a data frame, counts as empty, except where the default isNULL, as forcriterionorkcrit: there it means that the argument is not given. Where an observation is a vector of counts (dsdt_rating(),dsdt_dpsdt(),dsdt_metad(),dsdt_ranking()anddsdt_cdp()), or the pair ofmean_rtorvar_rtvalues ofdezdm(version = "4par"), a vector is always one observation: pass a matrix with zero rows for none, as an empty vector stops. An emptykcritofdsdt_cdp()andrsdt_cdp()stops as well;kcrit = NULLgives the R/K model. Counts in a data frame, a tibble included, are read as the matrix of its rows, and so aremean_rtandvar_rtofdezdm(version = "4par").dsdm()with a data framexis the exception: it returns a data frame of the same shape, one density per cell, and cuts longer parameters to the number of cells.A set of values that describes one observation, such as the
thresholdsof the rating models or the item locationsmu(anddist) ofdmixture3p()anddimm(), is a vector when every observation shares it and a matrix with one row per observation otherwise: rowibelongs to observationi, or to drawi. Item locations are padded withNApast each row's set size, and a data frame of them is read as the matrix of its rows. As for counts, an empty vector of them stops: pass a matrix with zero rows for no observations.Configuration arguments such as
version,distof the ranking models,log,parametrizationandn_neware single values and are never recycled. An argument that a version does not use, such aszrofdezdm(version = "3par"), is ignored.
Missing values
rmixture2p(), rmixture3p() and rimm() return NA for a draw whose
parameters include an NA or NaN, and warn "NAs produced" once per call,
as stats::rnorm() does. The other draws follow the parameters as usual,
though a seed need not give them the values it gives when no parameter is
missing. dmixture2p(), dmixture3p() and dimm() return NA for such
an observation. An NA in the item locations mu or the distances dist
of dmixture3p(), dimm() and their r*() functions is padding past a
row's set size, not a missing value: it shortens that row's item set (see
"Vector arguments"), and an NA in the target column or before a row's
last location stops.
