View source: R/fake_data_simulation.R
simulate_diagnostic_test_data | R Documentation |
Simulate Diagnostic Test Data
simulate_diagnostic_test_data(
B = 100,
N = 500,
true_p = 0.2,
true_se = 0.9,
true_sp = 0.9,
keep_true_pars = FALSE
)
B |
Integer indicating number of simulated datasets. |
N |
Integer indicating sample size in each dataset. |
true_p |
Proportion indicating true prevalence in each dataset. |
true_se |
Proportion indicating true sensitivity in each dataset. |
true_sp |
Proportion indicating true specificity in each dataset. |
keep_true_pars |
Logical indicating whether to keep true parameter values in the output dataframe. |
Diagnostic test data is simulated according to the following
mechanism: for each of the B
simulations, d
diseased persons
are sampled from a binomial of size N
and parameter true_p
. Then,
tp
true positive outcomes are sampled from a binomial of size d
and parameter true_se
, and tn
true negative outcomes are
sampled from a binomial of size N-d
with parameter true_sp
. This
simulates B
diagnostic accuracy studies in which a number of
diseased and non-diseased persons are sampled from a population;
the expected proportion of diseased persons correctly detected as
such is the sensitivity, and the number of non-diseased persons
correctly detected as such is the specificity.
A Bx7 data frame with simulated data and provided parameters.
d <- simulate_diagnostic_test_data(B = 2,
N = 1000,
true_p = 0.2,
true_se = 0.9,
true_sp = 0.9)
head(d)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.