simulate_diagnostic_test_data: Simulate Diagnostic Test Data

View source: R/fake_data_simulation.R

simulate_diagnostic_test_dataR Documentation

Simulate Diagnostic Test Data

Description

Simulate Diagnostic Test Data

Usage

simulate_diagnostic_test_data(
  B = 100,
  N = 500,
  true_p = 0.2,
  true_se = 0.9,
  true_sp = 0.9,
  keep_true_pars = FALSE
)

Arguments

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.

Details

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.

Value

A Bx7 data frame with simulated data and provided parameters.

Examples

d <- simulate_diagnostic_test_data(B = 2,
                                   N = 1000,
                                   true_p = 0.2,
                                   true_se = 0.9,
                                   true_sp = 0.9)
head(d)

giulianonetto/bayesdca documentation built on Aug. 31, 2023, 11:07 a.m.