simulate_max: Simulate maximum concentrations

View source: R/simulation.R

simulate_maxR Documentation

Simulate maximum concentrations

Description

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

Usage

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

# 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 Nov. 3, 2024, 11:22 p.m.