stratifyByPs: Stratify persons by propensity score

View source: R/PsFunctions.R

stratifyByPsR Documentation

Stratify persons by propensity score

Description

Use the provided propensity scores to stratify persons. Additional stratification variables for stratifications can also be used.

Usage

stratifyByPs(
  population,
  numberOfStrata = 5,
  stratificationColumns = c(),
  baseSelection = "all"
)

Arguments

population

A data frame with the three columns described below

numberOfStrata

How many strata? The boundaries of the strata are automatically defined to contain equal numbers of target persons.

stratificationColumns

Names of one or more columns in the data data.frame on which subjects should also be stratified in addition to stratification on propensity score.

baseSelection

What is the base selection of subjects where the strata bounds are to be determined? Strata are defined as equally-sized strata inside this selection. Possible values are "all", "target", and "comparator".

Details

The data frame should have the following three columns:

  • rowId (numeric): A unique identifier for each row (e.g. the person ID).

  • treatment (integer): Column indicating whether the person is in the target (1) or comparator (0) group.

  • propensityScore (numeric): Propensity score.

Value

Returns a tibble with the same columns as the input data plus one extra column: stratumId.

Examples

rowId <- 1:200
treatment <- rep(0:1, each = 100)
propensityScore <- c(runif(100, min = 0, max = 1), runif(100, min = 0, max = 1))
data <- data.frame(rowId = rowId, treatment = treatment, propensityScore = propensityScore)
result <- stratifyByPs(data, 5)


OHDSI/CohortMethod documentation built on Oct. 9, 2024, 12:50 p.m.