Skip to contents

Samples subjects from one of the app's virtual patient databases (NHANES, CDC or WHO growth data), or makes n subjects without covariates (db = "None"), as on the app's Variability page.

Usage

mvp_population(
  n = 20,
  db = c("None", "NHANES", "CDC", "WHO"),
  age = NULL,
  wt = c(0, 200),
  bmi = c(0, 70),
  prop_male = 0.5,
  seed = 1234,
  covariates = NULL,
  data = NULL,
  data_columns = NULL
)

Arguments

n

Number of subjects.

db

"None", "NHANES", "CDC" or "WHO". See nhanes.filtered, cdc.expand and who.expand.

age

Age range in years, c(lower, upper). Bounds are inclusive and compared in months (age * 12), as in the app. Defaults: 18 to 65 years for NHANES (as in the app), the whole database for CDC and WHO.

wt

Weight range in kg.

bmi

Body mass index range in kg/m^2.

prop_male

Proportion of males (SEX = 0), between 0 and 1.

seed

Random seed for the sampling. The random number state of the R session is left unchanged.

covariates

Extra covariates drawn from distributions, as the app's "Covariate Distributions" tab: a named list of mvp_covariate(), e.g. list(CRCL = mvp_covariate("normal", mean = 110, sd = 20)).

data, data_columns

Covariates sampled from a dataset's subjects, as the app's "Use dataset covariate distributions": a data frame with an ID column (one value per subject is used) and the columns to take. Sampled without replacement when the dataset has exactly n subjects, otherwise with replacement. They replace database columns of the same name.

Value

A data frame with one row per subject: ID (1 to n) and, from a database, SEX, AGEMO, AGE (years), WT (kg), HT (cm), BMI and BSA (m^2), plus any extra covariates. Columns named as model parameters replace those parameters in mvp_simulate() (e.g. WT, CRCL).

See also

Examples

pop <- mvp_population(100, db = "NHANES", age = c(6, 12), seed = 1)
summary(pop$WT)
#>    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
#>   18.20   25.00   32.40   38.29   45.15   98.70