random_scdf: Single-case data generator

View source: R/random_scdf.R

random_scdfR Documentation

Single-case data generator

Description

The random_scdf function generates random single-case data frames for monte-carlo studies and demonstration purposes. design is used to set up a design matrix with all parameters needed for the random_scdf function.

Usage

random_scdf(design = NULL, round = NA, random_names = FALSE, seed = NULL, ...)

Arguments

design

A design matrix which is created by design and specifies all parameters. If design is NULL (default), the design parameters have to be specified via the ... argument. If a numeric value is provided instead of a design matrix, it is interpreted as the number of cases n.

round

Rounds the scores to the defined decimal. To round to the second decimal, set round = 2. Default is NA (no rounding).

random_names

Is FALSE by default. If set random_names = TRUE cases are assigned random first names. If set "neutral", "male" or "female" only gender neutral, male, or female names are chosen. The names are drawn from the 2,000 most popular names for newborns in 2012 in the U.S. (1,000 male and 1,000 female names).

seed

A seed number for the random generator. If NULL (default), no seed

...

arguments that are directly passed to the design function for a more concise coding.

Details

The generated data can be normally distributed, Poisson-distributed, or binomially distributed. The default is normally distributed data.

Value

A single-case data frame. See scdf to learn about this format.

Author(s)

Juergen Wibert

Examples


## Create random single-case data and inspect it
design <- design(
  n = 3, rtt = 0.75, slope = 0.1, extreme_prop = 0.1,
  missing_prop = 0.1
)
dat <- random_scdf(design, round = 1, random_names = TRUE, seed = 123)
describe(dat)

## And now have a look at poisson-distributed data
design <- design(
  n = 3, B_start = c(6, 10, 14), mt = c(12, 20, 22), start_value = 10,
  distribution = "poisson", level = -5, missing_prop = 0.1
)
dat <- random_scdf(design, seed = 1234)
pand(dat, decreasing = TRUE)

scan documentation built on April 1, 2026, 9:06 a.m.