samplebootmat: Draw Bootstrap Samples

View source: R/samplebootmat.R

samplebootmatR Documentation

Draw Bootstrap Samples

Description

samplebootmat returns nsim bootstrap samples of a set of indicator observations and reference values.

Usage

samplebootmat(
  ValueID = NULL,
  Value = NULL,
  RefobsID = NULL,
  DistID = NULL,
  mu = NULL,
  sig = NULL,
  ref.value.code = 0,
  Type.of.uncertainty = c("Observations"),
  nsim = 100
)

Arguments

ValueID

integer, length = nvalues, Indicator observation IDs and reference values IDs.

Value

double, length = nvalues, Expected values for indicator observations and reference values.

RefobsID

integer, length = nvalues, Identifies those elements in ValueID, Value, DistID, mu, sig that are reference values.

DistID

character, length = nvalues, distribution family, i.e. "Gamma", "LogNormal", "TruncNormal", "Weibull", "ZIExponential", "NegBinom", "Poisson", "ZIP" or "NoBoot" (copy obs).

mu

double, length = nvalues, parameter 1 of model distribution

sig

double, length = nvalues, parameter 2 of model distribution

ref.value.code

integer, length = 1, Code used in RefobsID to identify reference values.

Type.of.uncertainty

character, length = 1, Type of bootstrap sample. "All" (all elements in the sample are draws), "None" (all elements are copies), "Observations" (elements representing indicator observations are draws, while elements representing reference values are copies), "Referencevalues" (indicator observations are copies, reference values are draws).

nsim

double, length = 1, number of bootstrap samples (simulations)

Details

Bootstrap samples consist of either nsim random draws from a set of probability distributions given by DistID and the parameter vectors mu and sig, or nsim copies of the elements of Value, or a combination of draws and copies, depending on the parameter Type.of.uncertainty.

samplebootmat presumes that the set of probability distributions only includes the truncated normal-, lognormal-, weibull-, gamma-, zero-inflated exponential, poisson-, negative binomial-, and zero-inflated poisson distributions. The lower bound in the truncated normal distribution is always zero, while the upper bound is infinity.

The function does not handle missing values (NAs).

samplebootmat is a utility function adapted to the mathematical framework for calculating the nature index.

samplebootmat calls sampleobs which does the random draws.

Value

double matrix, dim = c(nvalues, nsim), nsim bootstrap sample as specified by RefobsID, Value, distrib, mu, and sig.

Author(s)

Bård Pedersen

See Also

sampleobs,

Examples

# Example data
aa <- 1:2 # ValueID
bb <- rep(1,2) # Value
cc <- c(0,1) # RefobsID
dd <- rep(c("LogNormal"), 2) # DistID
mu <- rep(0,2) # mu
sig <- rep(1,2)  # sig
samplebootmat(aa,bb,cc,dd,mu,sig)
samplebootmat(aa,bb,cc,dd,mu,sig,Type.of.uncertainty = "All")
samplebootmat(aa,bb,RefobsID = c(0,0),dd,mu,sig)
samplebootmat(aa,bb,cc,dd,mu,sig,ref.value.code = 1)
samplebootmat(aa,bb,cc,dd,mu,sig,ref.value.code = 2)


NINAnor/NIcalc documentation built on Oct. 26, 2023, 9:37 a.m.