simdesign {simdata} | R Documentation |
Design specification for simulating datasets
Description
Stores information necessary to simulate and visualize datasets based
on underlying distribution Z
.
Usage
simdesign(
generator,
transform_initial = base::identity,
n_var_final = -1,
types_final = NULL,
names_final = NULL,
prefix_final = "v",
process_final = list(),
name = "Simulation design",
check_and_infer = TRUE,
...
)
Arguments
generator |
Function which generates data from the underlying base distribution. It is
assumed it takes the number of simulated observations |
transform_initial |
Function which specifies the transformation of the underlying
dataset |
n_var_final |
Integer, number of columns in final datamatrix |
types_final |
Optional vector of length equal to |
names_final |
NULL or character vector with variable names for final dataset |
prefix_final |
NULL or prefix attached to variables in final dataset |
process_final |
List of lists specifying post-processing functions applied to final
datamatrix |
name |
Character, optional name of the simulation design. |
check_and_infer |
If TRUE, then the simulation design is tested by simulating 5 observations
using |
... |
Further arguments are directly stored in the list object to be passed to
|
Details
The simdesign
class should be used in the following workflow:
Specify a design template which will be used in subsequent data generating / visualization steps.
Sample / visualize datamatrix following template (possibly multiple times) using
simulate_data
.Use sampled datamatrix for simulation study.
For more details on generators and transformations, please see the
documentation of simulate_data
.
For details on post-processing, please see the documentation of
do_processing
.
Value
List object with class attribute "simdesign" (S3 class) containing the following entries (if no further information given, entries are directly saved from user input):
generator
name
transform_initial
n_var_final
types_final
names_final
process_final
entries for further information as passed by the user
Naming of variables
If check_and_infer
is set to TRUE, the following procedure determines
the names of the variables:
use
names_final
if specified and of correct lengthotherwise, use the names of
transform_initial
if present and of correct lengthotherwise, use
prefix_final
to prefix the variable number if not NULLotherwise, use names from dataset as generated by the
generator
function
Simulation Templates
This class is intended to be used as a template for simulation designs
which are based on specific underlying distributions. All such a template
needs to define is the generator
function and its construction and
pass it to this function along with the other arguments. See
simdesign_mvtnorm
for an example.
See Also
simdesign_mvtnorm
,
simulate_data
,
simulate_data_conditional
Examples
generator <- function(n) mvtnorm::rmvnorm(n, mean = 0)
sim_design <- simdesign(generator)
simulate_data(sim_design, 10, seed = 19)