simulate_max: Simulate maximum concentrations

Description Usage Arguments Value Examples

View source: R/simulation.R

Description

Simulates maximum metabolite concentrations using a mixture of 2 normal distributions of concentration logarithms.

Usage

1
simulate_max(n, par1, par2 = NULL, p = 0.5, con = NULL)

Arguments

n

Number of samples to draw.

par1

Parameters (mean, sd) in concentration units for first distribution. These values are converted to logarithms for sampling.

par2

Optional parameters (mean, sd) in concentration units for second distribution. These values are converted to logarithms for sampling.

p

Proportion of samples to draw using par1 vs. par2. Note, p is ignored if par2 is not specified.

con

Optional vector of lower and upper constraints on generated samples.

Value

A vector of concentration values.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
# Generating concentrations
out <- simulate_max(10000, c(7, 2), c(0.5, 2), 0.3)

# Formatting output on logarithmic scale
out <- log10(out)
labels <- c(0.1, 0.25, 0.5, 1, 2.5, 5, 10, 25, 50)
hist(out, 20, axes = FALSE, probability = TRUE,
     main = '', xlab = 'Maximum metabolite concentration')
axis(side = 2)
axis(at = log10(labels), labels = labels, side = 1)

ssokolen/metcourse documentation built on May 30, 2019, 8:43 a.m.