% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/PsFunctions.R
\name{stratifyByPs}
\alias{stratifyByPs}
\title{Stratify persons by propensity score}
\usage{
stratifyByPs(
  population,
  stratifyByPsArgs = createStratifyByPsArgs(),
  cohortMethodData = NULL
)
}
\arguments{
\item{population}{A data frame with the three columns described below}

\item{stratifyByPsArgs}{An object of type \code{StratifyByPsArgs} as created by the
\code{createStratifyByPsArgs()} function.}

\item{cohortMethodData}{An object of type \link{CohortMethodData} as generated using
\code{\link[=getDbCohortMethodData]{getDbCohortMethodData()}}. Needed when additionally matching on
covariate IDs.}
}
\value{
Returns a tibble with the same columns as the input data plus one extra column: stratumId.
}
\description{
Use the provided propensity scores to stratify persons. Additional
stratification variables for stratifications can also be used.
}
\details{
The data frame should have the following three columns:
\itemize{
\item rowId (numeric): A unique identifier for each row (e.g. the person ID).
\item treatment (integer): Column indicating whether the person is in the target (1) or comparator (0) group.
\item propensityScore (numeric): Propensity score.
}
}
\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, createStratifyByPsArgs(numberOfStrata = 5))

}
