Generates B number of parametric bootstrap samples from estimated parameters of original univariate sample data. data is referred to as the empirical distribution $$ \hat{ F }_{ \mathcal{ Distribution } } $$. The default distribution is $$ \mathcal{ N } \left( \hat{ \mu }, \hat{ \sigma }^2 \right) %(\#eq:boot-pb-norm) $$. The univariate distribution and parameters used in the data generating process can be specified using rFUN and ....

pbuniv(
  n,
  rFUN = rnorm,
  ...,
  B = 2000L,
  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.

B

Integer. Number of bootstrap samples.

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.

Value

Returns a list of length B of parametric bootstrap samples.

Details

For more details and examples see the following vignettes:

Notes: Intro to NB

Notes: Intro to PB

References

Efron, B., & Tibshirani, R. J. (1993). An introduction to the bootstrap. New York, N.Y: Chapman & Hall.

Wikipedia: Bootstrapping (statistics)

See also

Other bootstrap functions: nb(), pbmvn()

Examples

n <- 5 B <- 5 # normal distribution--------------------------------------------------------- mu <- 100 sigma2 <- 225 sigma <- sqrt(sigma2) x <- rnorm( n = n, mean = mu, sd = sigma ) muhatthetahat <- mean(x) Sigmahatthetahat <- sd(x) xstar <- pbuniv( n = n, rFUN = rnorm, B = B, mean = muhatthetahat, sd = Sigmahatthetahat ) str(xstar)
#> List of 5 #> $ : num [1:5] 91.4 95.4 100.8 94.6 104.4 #> $ : num [1:5] 105 95.6 98.3 94.8 94.6 #> $ : num [1:5] 86.4 92.5 102.1 110.4 109.5 #> $ : num [1:5] 94.5 95.1 105.7 95.6 99.6 #> $ : num [1:5] 99.1 98.1 107.3 106.7 98.3
# binomial distribution------------------------------------------------------- n_trials <- 1 p <- 0.50 x <- rbinom( n = n, size = n_trials, prob = p ) phat <- mean(x) / n_trials xstar <- pbuniv( n = n, rFUN = rbinom, B = B, size = n_trials, prob = phat ) str(xstar)
#> List of 5 #> $ : int [1:5] 0 0 0 1 0 #> $ : int [1:5] 1 0 1 0 1 #> $ : int [1:5] 0 0 1 1 0 #> $ : int [1:5] 0 0 0 1 1 #> $ : int [1:5] 0 1 0 0 0