rmed0non0u95: Draw random numbers with LOD median but non-zero upper 95th...

View source: R/rmed0non0u95.R

rmed0non0u95R Documentation

Draw random numbers with LOD median but non-zero upper 95th percentile

Description

This function draws N random numbers from a distribution that approximates a median that is equal to the limit of detection (LOD, value x.LOD) but has an upper 95th percentile (x.u95) that is above x.LOD. We make the assumption that values above x.u95 are uniformly distributed between x.u95 and x.u95 + (x.u95 - x.LOD)

Usage

rmed0non0u95(n, x.u95, x.min = 0, x.LOD = 0.005)

Arguments

n

Number of samples to draw

x.u95

The upper limit on the 95th confidence/credible intervale (this is the 97.5 percentile)

x.min

The minimum allowed value (defaults to 0)

x.LOD

The limit of detection (defaults to 0.005)

Value

A vector of N samples where the 50th and 97.5th quantiles approximate x.LOD and x.u95 respectively

Author(s)

John Wambaugh

References

\insertRef

breen2022simulatinghttk

Examples

Fup.95 <- 0.02
N <- 1000

set.seed(1235)
Fup.vec <- rmed0non0u95(n=N, x.u95=Fup.95)
quantile(Fup.vec,c(0.5,0.975))

quantile(rmed0non0u95(200,x.u95=0.05,x.min=10^-4,x.LOD=0.01),c(0.5,0.975))
hist(rmed0non0u95(1000,x.u95=0.05,x.min=10^-4,x.LOD=0.01))

quantile(rmed0non0u95(200,x.u95=0.005,x.min=10^-4,x.LOD=0.01),c(0.5,0.975))
hist(rmed0non0u95(1000,x.u95=0.005,x.min=10^-4,x.LOD=0.01))


httk documentation built on Sept. 11, 2024, 9:32 p.m.