Learn R Programming

simFrame (version 0.5.4)

generate: Generate data

Description

Generic function for generating data based on a (distribution) model.

Usage

generate(control, …)

# S4 method for DataControl generate(control)

Arguments

control

a control object inheriting from the virtual class "VirtualDataControl" or a character string specifying such a control class (the default being "DataControl").

if control is a character string or missing, the slots of the control object may be supplied as additional arguments. See "'>DataControl" for details on the slots.

Value

A data.frame.

Methods

control = "character"

generate data using a control class specified by the character string control. The slots of the control object may be supplied as additional arguments.

control = "missing"

generate data using a control object of class "DataControl". Its slots may be supplied as additional arguments.

control = "DataControl"

generate data as defined by the control object control.

Details

The control class "DataControl" is quite simple but general. For user-defined data generation, it often suffices to implement a function and use it as the distribution slot in the "DataControl" object. See "'>DataControl" for some requirements for such a function.

However, if more specialized data generation models are required, the framework can be extended by defining a control class "MyDataControl" extending "'>VirtualDataControl" and the corresponding method generate(control) with signature 'MyDataControl'. If, e.g., a specific distribution or mixture of distributions is frequently used in simulation experiments, a distinct control class may be more convenient for the user.

References

Alfons, A., Templ, M. and Filzmoser, P. (2010) An Object-Oriented Framework for Statistical Simulation: The R Package simFrame. Journal of Statistical Software, 37(3), 1--36. 10.18637/jss.v037.i03.

See Also

"'>DataControl", "'>VirtualDataControl"

Examples

Run this code
# NOT RUN {
# using a control object
dc <- DataControl(size = 10, distribution = rnorm,
    dots = list(mean = 0, sd = 2))
generate(dc)

# supply slots of control object as arguments
generate(size = 10, distribution = rnorm,
    dots = list(mean = 0, sd = 2))
# }

Run the code above in your browser using DataLab