Generate data from MPT models.

Share:

Description

generate.data in MPTinR is a generic function that generates random data or predicted data for MPT models from given parameter values.

Usage

1
2
3
4
## S4 method for signature 'mpt.model'
generate.data(model, parameter.values, n.per.tree, n = 1, random = TRUE, ...)
## S4 method for signature 'mpt'
generate.data(model, n = 1, random = TRUE, ...)

Arguments

model

Either a MPT model (an object of class bmpt.model or mpt.model, returned from make.mpt) or a fitted MPT model (object of class bmpt or mpt, returned from fit.mpt)

parameter.values

named vector or matrix with the parameter estiamtes to be used for data generation. If a vector, names(parameter.values) must correspond to the parameters in the model. If a matrix, each row represents one set of parameter estimates and the colnames(parameter.values) must correspond to the parameters in the model.

n.per.tree

vector or matrix with length/ number of columns corresponding to the number of categories in the model. Each value must correspond to the n per tree for that category. If a matrix, each row represents one set of ns.

n

numeric. Number of random samples to be drawn per set of parameter values (ignored if random = FALSE).

random

logical. If TRUE (the default) random samples from a multinomial distribution are drawn. If FALSE the values predicted from the given parameter estimates are returned (and argument n is ignored).

...

currently ignored.

Details

This function generates data from either a mutlinomial processing tree (MPT) model object as produced by make.mpt (which is either of class bmpt.model or mpt.model) or a fitted MPT model object as produced by fit.mpt (which is either of class bmpt or mpt).

To generate data from a MPT models you also need to specify parameter values and the desired n. Both can be vectors to generate data from a single individual or a matrix to generate data from multiple individuals with each row corresponding to a single individual. The parameter values need to ba a named object, either a vector or a matrix. The names for a vector or the colnames of a matrix need to correspond to the free parameters in the model. Additional parameters or named objects not part of the model should be ignored.

Value

If random is TRUE, a 3-dimensional array with dim(n, n.categories, n.parameter.sets):

first dimension

the number of random draws for each set of parameters (i.e., = n).

second dimension

the response categories in the model

third dimension

the parameter set (i.e., the number of the row in the parameter.values object or the dataset)

If random is FALSE, a vector or matrix containing the (non-rounded) expected values.

Author(s)

Henrik Singmann

See Also

fit.mpt, make.mpt