Learn R Programming

simFrame (version 0.5.0)

generate: Generate data

Description

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

Usage

generate(control, ...)

## S3 method for class '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.

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 RPackage simFrame. Journal of Statistical Software, 37(3), 1--36. URL http://www.jstatsoft.org/v37/i03/.

See Also

"DataControl", "VirtualDataControl"

Examples

Run this code
require(mvtnorm)
mean <- rep(0, 2)
sigma <- matrix(c(1, 0.5, 0.5, 1), 2, 2)

# using a control object
dc <- DataControl(size = 10, distribution = rmvnorm, 
    dots = list(mean = mean, sigma = sigma))
generate(dc)

# supply slots of control object as arguments
generate(size = 10, distribution = rmvnorm, 
    dots = list(mean = mean, sigma = sigma))

Run the code above in your browser using DataLab