get_bs_samples: Generates bootstrap samples

Description Usage Arguments Value Examples

View source: R/get_bs_samples.R

Description

Generates bootstrap samples

Usage

1
2
get_bs_samples(data, id, cohort, outcome, n.samples = 1000,
  scores = NULL, moderators = NULL)

Arguments

data

Dataset containing subject identifiers, names of cohorts, outcome, and each of the scores

id

name of variable with subject identifiers

cohort

name of variable containing cohorts (the stratification factor, can be a factor, character or numeric)

outcome

name of outcome variable (binomial)

n.samples

Number of bootstrap samples to be generated within each cohort (default 1000)

scores

A vector of variable names that are scores (or their predicted probabilities). The order the scores are here is used in all other functions.

moderators

A vector of variable names that are moderators, that is, covariates which could affect the differences in score performance. We save these variables here, to be aggregated later in aggregate_performance. They can then be entered as covariates in msc_direct, consistency, or any other models.

Value

A list with 3 elements:

bs.sample

A data.frame containing the stratified bootstrap samples, split by cohort

orig.sample

A data.frame containing the orignal data, split by cohort

scores

Unique names of the scores which are also in the dataset

mods

A vector of moderators which may be included in subsequent models

formulas

vector of formulas that can be used in any function which calculates performance measures (e.g. calibration_slope)

Examples

1
2
3
dat <- msc_sample_data()
set.seed(12345)
get_bs_samples(dat, id, study, outcome, scores = letters[1:3], moderators = "age")

srhaile/mscpredmodel documentation built on Sept. 13, 2019, 3:44 p.m.