% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/make_strata.R
\name{make_strata}
\alias{make_strata}
\title{Create Strata from Multiple Variables}
\usage{
make_strata(data, vars, sep = " × ", min_n = 1, autobin = TRUE)
}
\arguments{
\item{data}{A data frame containing the variables to create strata from.}

\item{vars}{Character vector of variable names to use for creating strata.}

\item{sep}{Separator to use between variable values when creating stratum labels.
Default is " \\u00d7 " (a mathematical multiplication sign).}

\item{min_n}{Minimum number of observations required for a stratum to be included.
Strata with fewer observations will be coded as NA. Default is 1.}

\item{autobin}{Logical indicating whether to automatically bin numeric grouping variables
with more than 10 unique values into 3 categories (tertiles). Default is TRUE.}
}
\value{
A list with two elements:
  \item{data}{The original data frame with an added 'stratum' column. The
    strata_info is also attached as an attribute for use by fit_maihda()}
  \item{strata_info}{A data frame with information about each stratum including
    counts and the combination of variable values}
}
\description{
This function creates strata (intersectional categories) from multiple
categorical variables in a dataset.
}
\details{
If any of the specified variables has a missing value (NA) for a given observation,
that observation will be assigned to the NA stratum (stratum = NA), rather than
creating a stratum that includes the missing value.

The strata_info data frame is also attached as an attribute to the data, which
allows fit_maihda() to automatically capture stratum labels for use in plots
and summaries.
}
\examples{
# Create strata from gender and race variables
result <- make_strata(maihda_sim_data, vars = c("gender", "race"))
print(result$strata_info)

}
