View source: R/solveMixtureExponentialDistribution.R
| solveMixtureExponentialDistribution | R Documentation |
This is a helper function to explore parameters for endpoint generator, likely in an enrichment design.
Assume that the overall population in an arm is a mixture of two exponential
distributions with medians median1 (m_1) and
median2 (m_2). Given the proportion of the first component
(p_1) and the overall median m, we have
p_1 (1 - e^{-\log(2)m/m_1}) + (1 - p_1) (1 - e^{-\log(2)m/m_2}) = 1/2
This function computes m_2 or m given p_1 and m_1.
These parameters can be used in custom random number generator to define
exponential distributed endpoints.
Note that the math formula above may not be displayed correctly on a
html page. You can read it with better format by running
?solveMixtureExponentialDistribution.
solveMixtureExponentialDistribution(
weight1,
median1,
median2 = NULL,
overall_median = NULL
)
weight1 |
numeric. The proportion of the first component. |
median1 |
numeric. Median of the first component. |
median2 |
numeric. Median of the second component. If |
overall_median |
numeric. Median of the overall population. If
|
a named vector of median2 or overall_median.
library(dplyr)
median2 <-
solveMixtureExponentialDistribution(
weight1 = .3,
median1 = 10,
overall_median = 8)
median2
n <- 1e6
ifelse(
runif(n) < .3,
rexp(n, rate=log(2)/10),
rexp(n, rate=log(2)/median2)) %>%
median() ## should be close to 8
overall_median <-
solveMixtureExponentialDistribution(
weight1 = .4,
median1 = 12,
median2 = 4)
overall_median
ifelse(
runif(n) < .4,
rexp(n, rate=log(2)/12),
rexp(n, rate=log(2)/4)) %>%
median() ## should be close to overall_median
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.