univ: Generate Univariate Data

Description Usage Arguments Details Value Author(s) Examples

View source: R/univ.R

Description

Generates an n \times 1 univariate data vector or a list of n \times 1 univariate data vectors of length R. The default data generating function is the normal distribution

X \sim \mathcal{N} ≤ft( μ, σ^2 \right) . %(\#eq:dist-X-norm)

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
univ(
  n,
  rFUN = rnorm,
  ...,
  R = NULL,
  par = FALSE,
  ncores = NULL,
  mc = TRUE,
  lb = FALSE,
  cl_eval = FALSE,
  cl_export = FALSE,
  cl_expr,
  cl_vars,
  rbind = NULL
)

Arguments

n

Integer. Sample size.

rFUN

Function. Data generating function to generate univariate data.

...

Arguments to pass to rFUN.

R

Integer. Number of Monte Carlo replications. If R is not provided, the function produces a single random data set. If R is an integer greater than 1, (e.g., R = 10), the function produces multiple random data sets stored in each element of a list of length R. par and all succeeding arguments are only relevant when R > 1.

par

Logical. If TRUE, use multiple cores. If FALSE, use lapply().

ncores

Integer. Number of cores to use if par = TRUE. If unspecified, defaults to detectCores() - 1.

mc

Logical. If TRUE, use parallel::mclapply(). If FALSE, use parallel::parLapply() or parallel::parLapplyLB(). Ignored if par = FALSE.

lb

Logical. If TRUE use parallel::parLapplyLB(). If FALSE, use parallel::parLapply(). Ignored if par = FALSE and mc = TRUE.

cl_eval

Logical. Execute parallel::clusterEvalQ() using cl_expr. Ignored if mc = TRUE.

cl_export

Logical. Execute parallel::clusterExport() using cl_vars. Ignored if mc = TRUE.

cl_expr

Expression. Expression passed to parallel::clusterEvalQ() Ignored if mc = TRUE.

cl_vars

Character vector. Names of objects to pass to parallel::clusterExport() Ignored if mc = TRUE.

rbind

NULL or logical. If rbind = NULL, returns the list produced. If TRUE, uses rbind() to bind the rows of the list produced. If FALSE, uses cbind() to bind the columns of the list produced. Test that each element of the output list has the appropriate dimensions for binding before using this option.

Details

The univariate distribution and parameters used in the data generating process can be specified using rFUN and ....

Options for explicit parallelism are provided when R > 1 especially when R is large. See par and suceeding arguments.

Value

If R = NULL or R = 1, returns an n \times 1 univariate data vector generated using rFUN and parameters passed to .... If R is an integer greater than 1, (e.g., R = 10) returns a list of length R of n \times 1 univariate data vector generated using rFUN and parameters passed to ....

Author(s)

Ivan Jacob Agaloos Pesigan

Examples

1
2
3
4
x <- univ(n = 100, rFUN = rnorm, mean = 100, sd = sqrt(225))
str(x)
xstar <- univ(n = 100, rFUN = rnorm, mean = 100, sd = sqrt(225), R = 100)
str(xstar, list.len = 6)

jeksterslabds/jeksterslabRdata documentation built on July 24, 2020, 5:49 a.m.