sample_nonoutcomes_prop: Sample patients (or other observational units) based on...

View source: R/sampling.R

sample_nonoutcomes_propR Documentation

Sample patients (or other observational units) based on patient IDs, depending on occurrence of an event or not

Description

Sample patients (or other observational units) based on patient IDs, depending on occurrence of an event or not

Usage

sample_nonoutcomes_prop(had_outcome, id, proportion)

Arguments

had_outcome

A logical indicating if the patient has experienced the outcome or not

id

An integer patient identifier with the following properties:

  • consistent between cohort extracts

  • unique

  • completely randomly assigned (no correlation with practice ID, age, registration date, etc etc) which should be true as it based on hash of true IDs

  • strictly greater than zero

proportion

The proportion of patients (amongst all those who did not experience the event) to be sampled

Details

If had_outcome is TRUE then result is always TRUE. If had_outcome is FALSE, then result is TRUE with probability proportion and FALSE with probability 1 - proportion. Patients are selected in ascending order of patient ID until the sampling proportion is met.

Value

A logical vector indicating whether the patient has been sampled or not


wjchulme/osutils documentation built on Dec. 20, 2024, 9:56 a.m.