sample_random_prop: Sample a proportion of patients (or other observational...

View source: R/sampling.R

sample_random_propR Documentation

Sample a proportion of patients (or other observational units) based on patient IDs

Description

Sample a proportion of patients (or other observational units) based on patient IDs

Usage

sample_random_prop(id, proportion)

Arguments

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

Result is TRUE with probability p and FALSE with probability 1-p. p is equal to
ceiling(length(id)*proportion)/length(id), which is equal to proportion when
length(id)*proportion is an integer, and slightly higher otherwise. 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.