19  Stratified Analysis

To interpret a measure of association as a causal effect, there must be no confounding or selection bias. We have discussed how stratification can help us control bias in causal inference. Suppose that we have a variable \(C\) with \(k\) different levels such that stratification on \(C\) is sufficient to prevent confounding and selection bias. Also suppose that we have chosen a measure of association appropriate for the scientific or public health question we are trying to answer. The next steps are:

  1. Decide whether there is effect modification. To test whether there is effect measure modification (which is often referred to as testing homogeneity), it is often necessary to calculate a pooled measure of association.

  2. If there is effect modification, report stratum-specific measures of association or standardize to a distribution of \(C\). In a case-control study, we may only be able to estimate the conditional odds ratios (which might estimate risk ratios or incidence rate ratios). In a cohort study, we can calculate stratum-specific risks and standardized measures of association.

  3. If there is no effect modification, report the pooled measure of association. If the measure is collapsible (or nearly collapsible), this will approximate the population-level measure of association.

Unless we standardize, this approach estimates conditional measures of the association between \(X\) and \(D\) given \(C\). If conditioning on \(C\) controls confounding and selection bias, then these conditional measures of association can be interpreted in terms of conditional causal effects. We will assume that each stratum has the stratum-specific 2x2 table shown in Table 19.1 and that we ignore tables with \(n_i = 0\).

Table 19.1: Stratum-specific 2x2 table
\(D = 1\) \(D = 0\) Total
\(X = 1\) \(a_i\) \(b_i\) \(r_{1i}\)
\(X = 0\) \(c_i\) \(d_i\) \(r_{0i}\)
Total \(k_{1i}\) \(k_{0i}\) \(n_i\)

19.1 Pooled measures of association

Estimators of a common measure of association have two goals that are not always compatible. First, minimize variance. Second, try to perform well in sparse strata. If you stratify by several variables, you will often end up with the data spread across many 2x2 tables that can have small numbers of individuals, including cells with zero individuals. Cells with zero individuals are often called zero cells, and data with a large number of cells with small numbers of individuals are called sparse data. There are three general methods of estimating common measures of association conditional on a set of covariates \(C\):

  • Woolf estimators (Woolf 1955): These minimize variance but rely on having large samples in each stratum.

  • Mantel-Haenszel estimators (Mantel and Haenszel 1959): These come close to minimizing variance but perform much better with sparse strata.

  • Regression models: These can handle continuous covariates as well as categorical covariates. They have low variance and are almost (but not always) as tolerant of sparse strata as Mantel-Haenszel estimators. The regression models that can be used for this purpose include generalized linear models (GLMs), conditional logistic regression, and regression models from survival analysis. Because of their flexibility and performance, regression models are the most widely used of these methods.

The Woolf and Mantel-Haenszel estimators are weighted averages of the stratum-specific measures of association: \[ \frac{\sum_{i = 1}^m w_i \hat{M}_i}{\sum_{i = 1}^k w_i}. \tag{19.1}\] where \(\hat{M}_i\) is the estimated stratum-specific measure of association, \(w_i\) is the weight given to stratum \(i\), and \(m\) is the number of strata. This weighted average is different from the weighted average that we use in standardization because it is an average of the stratum-specific measures of association rather than an average of stratum-specific risks (which are then compared using a measure of association).

19.1.1 Woolf estimators

The variance of the weighted average in Equation 19.1 is minimized by letting \[ w_i = \frac{1}{\Var(\hat{M}_i)}. \] These are the weights used by Woolf estimators (Woolf 1955). For ratio measures, Woolf estimators are calculated on the log scale and then transformed back to the odds ratio, risk ratio, or incidence rate ratio scale. For the odds ratio, the Woolf estimator is \[ \ln \hat{\OR}_W = \frac{\sum_{i = 1}^m w_i \ln \hat{\OR}_i}{\sum_{i = 1}^k w_i} \] where \[ w_i = \bigg(\frac{1}{a_i} + \frac{1}{b_i} + \frac{1}{c_i} + \frac{1}{d_i}\bigg)^{-1}. \] If there is any stratum with a zero cell, this estimator is undefined. One correction that is sometimes used is to add \(0.5\) to all cells before calculating the stratum-specific log odds ratios and variances (Jewell 2003), which is a small-sample correction for the log odds ratio.

19.1.2 Mantel-Haenszel estimators

Mantel-Haenszel estimators, which are sometimes called Cochran-Mantel-Haenszel estimators (Cochran 1954; Mantel and Haenszel 1959), use weights that approximate inverse variance weights under the null hypothesis but do not blow up in sparse strata. Variance calculation for Mantel-Haenszel estimators can be complicated (Robins 1986).

Odds ratio

From Table 19.1, the odds ratio in stratum \(i\) is \[ \hat{\OR}_i = \frac{a_i d_i}{b_i c_i} \] The Mantel-Haenszel odds ratio is \[ \hat{\OR}_\text{MH} = \frac{\sum_{i = 1}^m a_i d_i / n_i}{\sum_{i = 1}^k b_i c_i / n_i}, \] which we get from Equation 19.1 using \[ w_i = \frac{b_i c_i}{n_i}. \] These weights can be seen in the denominator of \(\hat{\OR}_\text{MH}\). Strata with \(b_i c_i = 0\) will be ignored, but the estimator is defined whenever at least one stratum has \(b_i c_i \neq 0\). Because they can be used for case-control studies, the Mantel-Haenszel odds ratio is the most widely used of all Mantel-Haenszel pooled measures of association.

The Mantel-Haenzsel weights for the odds ratio approximate inverse-variance weights under the null hypothesis that the common stratum-specific \(\OR = 1\). If \(\hat{OR}_i = 1\), then \(a_i d_i = b_i c_i\). We can rearrange \(\Var\bigl(\ln \hat{\OR}_i\bigr)\) from Equation 9.11 to get \[ \frac{1}{a_i} + \frac{1}{b_i} + \frac{1}{c_i} + \frac{1}{d_i} = \frac{a_i + d_i}{a_i d_i} + \frac{b_i + c_i}{b_i c_i} = \frac{a_i + b_i + c_i + d_i}{b_i c_i} = \frac{n}{b_i c_i}. \] Using the delta method, we get \[ \Var\bigl(\hat{\OR}_i\bigr) = \Var\Bigl(e^{\ln \hat{\OR}_i}\Bigr) \approx \Bigl(e^{\ln \hat{\OR}_i}\Bigr)^2 \Var(\ln \hat{\OR}_i) = \Var(\ln \hat{\OR}_i). \tag{19.2}\] when \(\hat{\OR}_i \approx 1\) in stratum \(i\). Therefore, the inverse variance weight of \(\hat{\OR}_i\) under the null hypothesis is approximately \(b_i c_i / n_i\).

Risk ratio

From Table 19.1, the risk ratio in stratum \(i\) is \[ \hat{\RR}_i = \frac{a_i / r_{1i}}{c_i / r_{0i}} = \frac{a_i r_{0i}}{c_i r_{1i}}. \] The Mantel-Haenszel risk ratio is \[ \hat{\RR}_\text{MH} = \frac{\sum_{i = 1}^m a_i r_{0i} / n_i}{\sum_{i = 1}^k c_i r_{1i} / n_i} \] which we get from Equation 19.1 using the weights \[ w_i = \frac{c_i r_{1i}}{n_i} \] that can be seen in the denominator. Strata with \(c_i r_{1i} = 0\) will be ignored, but the estimator is defined whenever at least one stratum has \(c_i r_{1i} \neq 0\).

The Mantel-Haenszel weights for the risk ratio can be derived by assuming both the null hypothesis that \(\RR_i = 1\) in each stratum \(i\) and that the risk of disease is small in each stratum. If \(\hat{\RR}_i = 1\), then \(a_i r_{0i} = C_i r_{1i}\). We can rearrange \(\Var\bigl(\ln \hat{\RR}_i\bigr)\) from Equation 9.6 to get \[ \frac{1}{a_i} - \frac{1}{r_{1i}} + \frac{1}{c_i} - \frac{1}{r_{0i}} = \frac{r_{0i} - a_i}{a_i r_{1i}} + \frac{r_{1i} - c_i}{c_i r_{1i}} = \frac{n_i - k_{1i}}{c_i r_{0i}} \approx \frac{n_i}{c_i r_{0i}} \] where the final approximation comes from the fact that \(k_{1i} \ll n_i\) if the disease is rare in each stratum. By replacing \(\hat{\OR}_i\) with \(\hat{\RR}_i\) in Equation 19.2, we get \[ \Var\bigl(\hat{\RR}_i\bigr) \approx \Var\bigl(\ln \hat{\RR}_i\bigr) \] when \(\hat{\RR}_i \approx 1\) in stratum \(i\). Therefore, the inverse variance weight of \(\hat{\RR}_i\) for a rare disease under the null hypothesis is approximately \(b_i c_i / n_i\).

Incidence rate ratio

In stratum \(i\), let \(T_{1i}\) be the total exposed person-time, \(T_{0i}\) be the total unexposed person-time, and \(T_i = T_{0i} + T_{1i}\) be the total person-time. The incidence ratio ratio in stratum \(i\) is \[ \hat{\IRR}_i = \frac{a_i / T_{1i}}{c_i / T_{0i}} = \frac{a_i T_{0i}}{c_i T_{1i}}. \] The Mantel-Haenszel risk ratio is \[ \hat{\IRR}_\text{MH} = \frac{\sum_{i = 1}^k a_i T_{0i} / T_i}{\sum_{i = 1}^k c_i T_{1i} / T_i} \] which we get from Equation 19.1 using the weights \[ w_i = \frac{c_i T_{1i}}{T_i} \] that can be seen in the denominator. Strata with \(c_i T_{1i} = 0\) will be ignored, but the estimator is defined whenever at least one stratum has \(c_i T_{1i} \neq 0\).

The Mantel-Haenszel weights for the risk ratio can be derived by assuming both the null hypothesis that \(\IRR_i = 1\) in each stratum \(i\). It does not require any rare-disease assumption. If \(\hat{\IRR}_i = 1\), then \(a_i T_{0i} = c_i T_{1i}\) so \[ \frac{1}{a_i} = \frac{T_{0i}}{c_i T_{1i}}. \] We can rearrange \(\Var\bigl(\ln \hat{\RR}_i\bigr)\) from Equation 9.16 to get \[ \frac{1}{a_i} + \frac{1}{c_i} = \frac{T_{0i}}{c_i T_{1i}} + \frac{1}{c_i} = \frac{T_{0i} + T_{1i}}{c_i T_{1i}} = \frac{T_i}{c_i T_{1i}} \] By replacing \(\hat{\OR}_i\) with \(\hat{\IRR}_i\) in Equation 19.2, we get \[ \Var\bigl(\hat{\IRR}_i\bigr) \approx \Var\bigl(\ln \hat{\IRR}_i\bigr) \] when \(\hat{\IRR}_i \approx 1\) in stratum \(i\). Therefore, the inverse variance weight of \(\hat{\IRR}_i\) under the null hypothesis is approximately \(c_i T_{1i} / T_i\).

19.2 Testing homogeneity

Tests of homogeneity typically have low power and require large samples within each stratum. With that caveat, the basic idea is to see whether assuming a constant measure of association is a reasonable approximation. A test of homogeneity can be done using a Wald \(\chi^2\) test or by testing interaction terms in a regression model.

19.2.1 Wald \(\chi^2\) tests

Suppose we have \(k\) strata, let \(M_i\) be the stratum-specific measure of association, and \(M\) be an estimate of a common measure of association. A Wald test of homogeneity uses the test statistic \[ \sum_{i = i}^m \frac{(\hat{M}_i - \hat{M})^2}{\Var(\hat{M}_i)}, \] which has a \(\chi^2_{k - 1}\) distribution under the null hypothesis that all \(M_i = M\).

For ratio measures such as the risk ratio or odds ratio, \(M_i\) and \(M\) should be the logarithm of the ratio. For the Mantel-Haenszel odds ratio, the Wald \(\chi^2\) statistic is \[ \chi^2_\text{MH} = \sum_{i = 1}^m \frac{(\ln \hat{\OR}_i - \ln \hat{\OR}_\text{MH})^2}{\Var(\ln \hat{\OR}_i)}, \] where \[ \Var\bigl(\ln \hat{\OR}_i \bigr) = \frac{1}{a_i} + \frac{1}{b_i} + \frac{1}{c_i} + \frac{1}{d_i}. \] Under the null hypothesis that \(M_i = M\) in each stratum \(i\), the test statistic \(\chi^2_\text{MH}\) has a \(\chi^2_{k - 1}\) distribution. It is important not to confuse this test of homogeneity with the test of the null hypothesis that the Mantel-Haenszel odds ratio equals one.

19.2.2 Interaction terms

As explained in Section 18.3.2, it is possible to test for homogeneity of an odds ratio, risk ratio, or incidence rate ratio by fitting an appropriate generalized linear model (GLM) or a model from survival analysis (accelerated failure time or Cox regression) with an interaction term. When \(C\) is a covariate that has \(k\) levels, the model would include \(k - 1\) terms via indicator variables (sometimes called dummy variables), orthogonal polynomials, or splines. To test interaction with \(C\), we would include interactions between \(X\) and all of the terms that encode \(C\). These interaction terms can be tested simultaneously using Wald, score, or likelihood ratio tests. Each of these tests produces a statistic that has a \(\chi^2_{k - 1}\) distribution under the null hypothesis that \(M_i = M\) in each stratum \(i\).

19.2.3 Testing the null hypothesis

If there is no effect measure modification, pooled estimators of a measure of association can be used to test the null hypothesis of no conditional association between exposure and disease within strata of \(C\). For the Woolf and Mantel-Haenzsel estimators, the test statistic is \[ \frac{(M - M_\text{null})^2}{\Var(M)}, \] which has a \(\chi^2_1\) distribution under \(H_0\). For the risk difference, \(M_\text{null} = 0\). For ratio measures, the test is done on the log scale so \(M_\text{null} = 0\).

19.3 Regression models

A stratified regression model can achieve something similar to the Woolf and Mantel-Haenszel statistics. However, the strata in a regression model are not completely independent as they are in pooled estimators. In a regression model, the strata share information about the association between treatment or exposure \(X\) and disease \(D\). When the model does not accurately capture the conditional association between \(X\) and \(D\) given \(C\), there can be residual confounding or selection bias. Another advantage of stratified regression models is that they can include predictors in addition to \(C\) and \(X\).

To test homogeneity in a regression model stratified by \(C\), we can include interaction terms between \(X\) and \(C\).

If there is no effect measure modification, we can test the null hypothesis of no conditional association between \(X\) and \(D\) given \(C\) using a Wald, score, or likelihood ratio test of the coefficient on \(X\).

19.3.1 Conditional logistic regression

The conditional logistic regression model that is used to analyze nested case-control studies (see Section 11.3) can also be used to estimate a common odds ratio from case-control data stratified on any confounder or set of confounders \(C\). Let \(\odds(p_{si})\) be the odds of disease for person \(i\) in stratum (i.e., case-control set) \(s\). Then the conditional logistic regression model assumes \[ \ln \odds\bigl(\Pr(D = 1 \given{} C = c, X = x)\bigr) = \beta_{0c} + \beta x, \] where \(\beta_{0c}\) is a statum-specific intercept the stratum with \(C = c\) and \(X\) is the exposure or treatment. The odds ratio associated with a one-unit increase in \(X\) within each stratum of \(C\) is \(e^\beta\).

Consider a matched set with one case and \(k\) controls who all have \(C = c\), and let \(p_j\) the risk of disease in person \(j\). Then the probability that there is one failure and no other failures is \[ \sum_{i = 1}^{k + 1} \bigg(p_i \prod_{j \neq i} (1 - p_j) \bigg) = \sum_{i = 1}^{k + 1} \frac{p_i}{1 - p_i} \prod_{j = 1}^{k + 1} (1 - p_j) = \sum_{i = 1}^{k + 1} \odds(p_i) \prod_{j = 1}^{k + 1} (1 - p_j). \] Without loss of generality, we can number the group members to that \(i = 1\) is the case. The conditional probability that \(i = 1\) is the case given that there is one failure in the group is \[ \begin{aligned} \frac{\odds(p_1) \prod_{j = 1}^k (1 - p_j)}{\sum_{i = 1}^k \odds(p_i) \prod_{j = 1}^{k + 1} (1 - p_j)} &= \frac{\odds(p_1)}{\sum_{i = 1}^{k + 1} \odds(p_i)} \\ &= \frac{e^{\beta_{0c} + \beta x_1}}{\sum_{i = 1}^{k + 1} e^{\beta_{0c} + \beta_1 x_i}} = \frac{e^{\beta x_1}}{\sum_{i = 1}^{k + 1} e^{\beta x_i}}. \end{aligned} \tag{19.3}\] The stratum-specific intercept \(\beta_{0c}\) cancels out.

The likelihood for \(\beta\) is the product of the stratum-specific conditional probabilities in Equation 19.3: \[ L(\beta) = \prod_{i = 1}^m \frac{e^{\beta x_i}}{\sum_{j \in R^*_i} e^{\beta x_j}} \] where \(R^*_i\) is the set containing the case and their matched controls. Maximum likelihood estimation yields consistent and asymptotically normal point and interval estimates for \(\beta_\true\). This is identical to the Cox partial likelihood from a nested case-control study, except the risk sets are replaced by matched case-control sets and the hazard ratio is replaced by a log odds. Exactly the same regression software can be used to fit both models—only the interpretation of the results is different. This model can be extended to include multiple predictors, including polynomials, splines, categorical variables, and interactions.

19.3.2 Stratified AFT models

In a stratified accelerated failure time (AFT) model, all strata of \(C\) have the same underlying failure time distribution (e.g., Weibull, or log-logistic). However, each stratum of \(C\) is allowed to have its own baseline rate parameter \(\lambda_{0c}\) and shape parameter \(\gamma_c\). The other coefficients in the model are interpreted as before. In particular, \(e^{-\beta}\) is the common rate ratio associated with a one-unit increase in \(X\) within strata of \(C\). These models can be used to estimate a common rate ratio from stratified data.

strat-aft.R
## Stratified accelerated failure time (AFT) models

# load R packages
library(survival)

# unstratified log-logistic AFT model
rat_unstrat <- survreg(Surv(time, status) ~ rx + sex,
                       data = rats, dist = "loglogistic")

# stratified log-logistic AFT model for rats data
# The strata() command only allows for different shape parameters.
# To get a truly stratified model, you need to include sex as a predictor.
rat_strat <- survreg(Surv(time, status) ~ rx + sex + strata(sex),
                     data = rats, dist = "loglogistic")
summary(rat_strat)
exp(-coef(rat_strat))
exp(-confint(rat_strat))

# baseline rates for female rats and male rats
lambda_f <- exp(-coef(rat_strat)["(Intercept)"])
lambda_m <- lambda_f * exp(-coef(rat_strat)["sexm"])

# estimated logistic rate ratio (same for males and females)
rr <- exp(-coef(rat_strat)["rx"])
exp(-confint(rat_strat)["rx", ])

# estimated shape parameters
1 / rat_strat$scale
shape_f <- 1 / rat_strat$scale["f"]
shape_m <- 1 / rat_strat$scale["m"]

# estimated odds ratios (constant in a log-logistic AFT model)
or_f <- rr^shape_f
or_m <- rr^shape_m


# residual confounding example
# simulate censored Weibull with different shapes but constant rate ratio
n <- 10000
fail0f <- rweibull(3 * n, shape = .5, scale = 1)
fail1f <- rweibull(n, shape = .5, scale = 1 / 2)
fail0m <- rweibull(n, shape = 2, scale = 1)
fail1m <- rweibull(3 * n, shape = 2, scale = 1 / 2)

fail <- c(fail0f, fail1f, fail0m, fail1m)
cens <- 2
time <- pmin(fail, cens)
event <- ifelse(cens < fail, 0, 1)
x <- rep(c(0, 0, 0, 1, 0, 1, 1, 1), each = n)
male <- rep(c(0, 1), each = 4 * n)
wdat <- data.frame(time = time, event = event, x = x, male = male)

# Weibull AFT model that does not include sex
crude <- survreg(Surv(time, event) ~ x, data = wdat)
exp(-coef(crude)["x"])
exp(-confint(crude)["x", ])

# unstratified Weibull AFT model that includes sex as a covariate
unstrat <- survreg(Surv(time, event) ~ x + male, data = wdat)
exp(-coef(unstrat)["x"])
exp(-confint(unstrat)["x", ])

# stratified Weibull AFT model that stratified by sex
strat <- survreg(Surv(time, event) ~ x + male + strata(male),
                 data = wdat)
exp(-coef(strat)["x"])
exp(-confint(strat)["x", ])

# Weibull AFT model that allows different shape parameters only
strat2 <- survreg(Surv(time, event) ~ x + strata(male),
                 data = wdat)

# stratified Cox model (stratified Weibull AFT model is special case)
cox <- coxph(Surv(time, event) ~ x + x:male + strata(male), data = wdat)

19.3.3 Stratified Cox model

The Cox model assumes that the hazard of failure at time \(t\) is \[ h(t, \beta, x) = e^{\beta_1 x_1 + \ldots + \beta_k x_k} h_0(t), \] where \(X_1, \ldots, X_k\) are covariates and \(h_0(t)\) is the baseline hazard function. A stratified Cox model allows different groups to have different baseline hazard functions. Specifically, \[ h(t, \beta, x, c) = e^{\beta x} h_{0c}(t) \] in the stratum with \(C = c\). Although the baseline hazard functions are stratum-specific, a stratified Cox model assumes that all strata have the same coefficient vector \(\beta\).

In stratum \(C = c\), let \(m_c\) be the number of distinct failure times, let \(t_{1c}, \ldots t_{m_c c}\) denote the distinct failure times, let \(R_c(t_{ic})\) denote the risk set in stratum \(C = c\) at time \(t_{ic}\), and let \(x_{ic}\) denote the covariate value(s) of the person in stratum \(C = c\) who fails at time \(t_{ic}\). Then the partial likelihood for a stratified model with \(K\) strata and no tied failure times is \[ L(\beta) = \prod_c \prod_{i = 1}^{m_c} \frac{e^\beta x_{ic}\big)}{\sum_{j \in R_{ic}} e^{\beta x_j}} \] where the product is over all strata defined by \(C\). The product over the failure times in stratum \(C = c\) is just the Cox partial likelihood within the stratum. The different strata share only the coefficients \(\beta\).

Stratification is a useful extension of the standard Cox model, but it comes at a price. When there is actually a single baseline hazard function, the stratified model is less efficient than an unstratified model. You cannot test the effect of the stratification variable(s), and you cannot compare the model to an unstratified model using a likelihood ratio test or Akaike Information Criterion.

Stratified log-rank test

The log-rank test can also be stratified. The observed and expected number of failures and the variances separately in each stratum and then combine them into a single \(\chi^2\) statistic. In this case, the null hypothesis is that the survival functions of the exposed and unexposed are the same within each stratum. Just like the log-rank test is the score test from a Cox proportional hazards model with a single binary covariate \(X\) and no ties, the stratified log-rank test is the score test for a stratified Cox model with a single binary covariate and no ties within strata.

Let \(O_c\) be the observed number of failures among the exposed in stratum \(C = c\), and let \(E_c\) and \(V_c\) be the expectation and variance of the number of failures among the exposed in stratum \(c\) under the null hypothesis. Within each stratum, these are calculated in exactly the same way as in the log-rank test. The sum of the differences between the observed and expected number of failures among the exposed over all strata is
\[ U = \sum_c (O_c - E_c). \] and its estimated variance is \[ V = \sum_c V_c. \] The stratified log-rank chi-squared statistic is \[ \chi^2_\text{log-rank} = \frac{U^2}{V}, \] which has a \(\chi^2_1\) distribution under the null hypothesis that the exposed and unexposed have the same stratum-specific survival functions.

strat-cox.R
## Stratified Cox model

# load R packages
library(survival)

# unstratified Cox model and Nelson-Aalen estimator
unstrat <- coxph(Surv(time, status) ~ rx + sex, data = rats)
summary(unstrat)
unstrat_na <- survfit(unstrat, stype =  2, ctype = 2, conf.type = "log-log",
                      newdata = data.frame(rx = 0, sex = c("f", "m")))

# stratified Cox model and Nelson-Aalen estimator
strat <- coxph(Surv(time, status) ~ rx + strata(sex), data = rats)
summary(strat)
strat_na <- survfit(strat, stype = 2, ctype = 2, conf.type = "log-log",
                    newdata = data.frame(rx = 0))

# plot of stratified and unstratified cumulative hazard estimates
plot(unstrat_na, fun = "cumhaz", lty = "dashed",
     xlab = "Weeks since treatment", ylab = "Cumulative hazard")
grid()
lines(strat_na, fun = "cumhaz", conf.int = FALSE)
legend("topleft", bg = "white", lty = c("solid", "dashed"),
       legend = c("Stratified model", "Unstratified model"))

# unstratified and stratified log-rank tests
survdiff(Surv(time, status) ~ rx + sex, data = rats)
survdiff(Surv(time, status) ~ rx + strata(sex), data = rats)