Skip to content

FTime to event · Guide test 243

Peto–Peto test

Uses survival estimate weights to compare censored time to event distributions.

Runs in CodeSplashPython (calls R) example not runR example validated Corrected in edition 2

Do it in CodeSplash

In the app, set it up in Analyze with this method:

Do it in CodeSplash Run this test on your own data, in Python or R.

Bench

Change the design, drag the data, move α. The statistic, its reference distribution and the verdict follow.

Bench · Peto–Peto test

40
40
1.80

Group 1's median event time divided by group 2's; 1 means equal medians.

1.00

Lognormal σ; unequal spreads make the survival curves cross.

1.00
4.0

Censoring times are uniform on (0, follow-up); group 2's median event time is 1.

0.050

Your data

Simulated with known medians and spreads
G14022821G24017840S(t)

Kaplan–Meier curves; ticks mark censored follow-up. Rows under the axis: numbers still at risk. Shaded: the weight each event time gets, w(t) = S(t−), the pooled Kaplan–Meier.

If H₀ were true

χ² = 3.07
  1. The reference: how χ² varies across samples when H₀ is true.
  2. Your statistic, from the data above.
  3. The p-value: the area at least as extreme as yours (p = .080).
  4. The hatched rejection region at α = .050: statistics landing here reject H₀.

The formula

Uw=∑jwj(d1j−Y1jdjYj),Vw=∑jwj2Y1jY2jdj(Yj−dj)Yj2(Yj−1),χ2=Uw2VwU_w=\sum_jw_j\Big(d_{1j}-\frac{Y_{1j}d_j}{Y_j}\Big),\qquad V_w=\sum_jw_j^2\frac{Y_{1j}Y_{2j}d_j(Y_j-d_j)}{Y_j^2(Y_j-1)},\qquad \chi^2=\frac{U_w^2}{V_w}

With your numbers

O1=10.34, E1=14.28 (weighted),χ2=3.07,40 eventsO_1 = 10.34,\ E_1 = 14.28\ (\text{weighted}),\quad \chi^2 = 3.07,\quad 40\text{ events}
d1j, Y1jd_{1j},\ Y_{1j}
events and numbers at risk in group 1 at event time j
Y1jdj/YjY_{1j}d_j/Y_j
events expected in group 1 if the groups shared one hazard
wjw_j
Ŝ(t_j−), the pooled Kaplan–Meier just before the time (survdiff's rho = 1)

The verdict

χ²(1) = 3.07, p = .080

p > α = .050: compatible with H₀

Weights by estimated survival rather than numbers at risk, so it stresses early differences without depending as much on censoring as Gehan–Breslow. This is survdiff's ρ = 1 version. For survMisc's S1 version choose Peto–Prentice weights; Modified Peto–Peto is Andersen's variant.

Statistic
3.069
p-value
0.0798
Peto–Peto test on 40 + 40 subjects with 40 events: χ²(1) = 3.07, p = .080. The p-value is above α = .050, so the data are compatible with H0.

Peto–Peto test on 40 + 40 subjects with 40 events: χ²(1) = 3.07, p = .080. The p-value is above α = .050, so the data are compatible with H₀.

Question and hypotheses

H0: the groups have equal survival/event hazard functions over follow-up.

Assumptions

Independent subjects and independent/noninformative censoring within groups, conditional on the modeled design. Standard weights and variances presume the stated risk-set process. Proportional hazards is a power/interpretation condition for logrank, not necessary for validity under identical survival curves.

Formula

Uw=∑jwj(d1j−Y1jdj/Yj)Vw=∑jwj2Y1jY2jdj(Yj−dj)Yj2(Yj−1)Z=Uw/Vw\begin{gathered}U_w=\sum_jw_j(d_{1j}-Y_{1j}d_j/Y_j)\\[5pt] V_w=\sum_jw_j^2\frac{Y_{1j}Y_{2j}d_j(Y_j-d_j)}{Y_j^2(Y_j-1)}\\[5pt] Z=U_w/\sqrt{V_w}\end{gathered}

Parameters and notation

At event time tj, Ygj is group g at-risk count, dgj its event count; Yj,dj are pooled totals. For more than two groups use a score vector and its covariance, with χ²k−1. wj=S̃(tj−), a pooled Peto–Peto modified survival estimate, commonly updated by factors 1−dj/(Yj+1).

Structure of the method

Accumulate observed-minus-expected event scores with a pooled survival-based weight and its matched variance. Peto-related implementations use subtly different survival estimates or event-time conventions. The existing survival::survdiff(rho=1) call belongs to its documented Kaplan–Meier G-rho family and is identified as the Peto–Peto modification.

Estimated and nuisance parameters

Estimate the pooled survival/risk process and weighted covariance; no hazard-ratio parameter is fitted. A separate Peto modified estimate built from factors involving risk size plus one is used in other implementations. Its exact finite-sample weights should not be silently substituted for the software’s documented convention.

Settings and design choices

Choose the named variant, tie/event-time convention, strata, follow-up, and one/two-sided comparison. Record package/version when reproducing published numbers. A rho value in the G-rho family controls that family’s weight, while survMisc’s S1 designation identifies a different explicitly documented modified-survival construction.

Fitting and adaptation

Recalculate the entire pooled survival curve and covariance whenever the analysis sample changes. When matching a published Peto procedure, match its algorithm rather than merely its name. Adaptation concerns risk-set construction and calibrated weight conventions; there is no neural fitting or defensible post hoc search for the best rho without adjustment.

Sensitivity and robustness

Inspect unequal censoring, early/late event support, ties, and differences among implementation outputs. The method aims to improve aspects of generalized-Wilcoxon behavior, not make all censoring mechanisms ignorable. Present survival effects separately and state that the code’s G-rho convention is the implemented variant.

How to use and calibrate

Use asymptotic normal tails for Z, or χ²1 for Z². Report the weight rule, risk-set conventions and censoring assumptions.

Example application

Compare survival with an early-weighted procedure designed to reduce sensitivity to censoring-pattern differences.

Interpretation and pitfalls

Watch out

Peto–Peto modifications and risk-set conventions differ; identify the implementation rather than substituting another survival estimate without recalibration.

What changed in edition 2

  • New sections: structure of the method, estimated and nuisance parameters, settings and design choices, fitting and adaptation, sensitivity and robustness.
  • Rewritten in the review: parameters and notation.
  • Parameters and notationsearch.r-project.org

    Align the algorithm description with the preserved survival::survdiff example while distinguishing another Peto-named weighting implementation.

    Corrected text

    At event time t_j, Y_gj and d_gj are the group-specific risk and event counts, and Y_j,d_j their pooled totals. For several groups, use a score vector/covariance with the appropriate rank. Peto-related implementations must be named: survival::survdiff(rho=1), used in the example, is documented as the Kaplan–Meier G-rho weighting S(t)^1 and identified as the Peto–Peto modification of Gehan–Wilcoxon. The separately documented survMisc S1 weight uses a modified survival product with factors 1−d_j/(Y_j+1). These finite-sample conventions should not be silently substituted for one another.

Python and R

Right-censored survival, independent groups and noninformative censoring. rho=0 is log-rank; rho=1 is Peto–Peto, not ordinary Gehan–Breslow weighting.

Python · invokes R

Not run — Executed end to end through Rscript · needs Python standard library + Rscript; R packages: survival

# Python launcher for the complete R implementation below.
# Requires Rscript on PATH and the listed R packages.
import shutil
import subprocess
rscript = shutil.which("Rscript")
if rscript is None:
    raise RuntimeError("Install R and make Rscript available on PATH.")
r_code = r"""
set.seed(2026)
library(survival)
n<-120;g<-factor(rep(c("A","B"),each=60));event_time<-rexp(n,rate=ifelse(g=="A",.1,.14));censor_time<-rexp(n,.04);d<-data.frame(time=pmin(event_time,censor_time),status=as.integer(event_time<=censor_time),g=g)
print(survdiff(Surv(time,status)~g,data=d,rho=1))
"""
# No shell interpolation. A failed R execution raises an error in Python.
result = subprocess.run([rscript, "--vanilla", "-"], input=r_code,
                        text=True, capture_output=True)
print(result.stdout)
if result.stderr:
    print(result.stderr)
result.check_returncode()
R

Validated — Executed successfully in the validation environment · needs survival

set.seed(2026)
library(survival)
n<-120;g<-factor(rep(c("A","B"),each=60));event_time<-rexp(n,rate=ifelse(g=="A",.1,.14));censor_time<-rexp(n,.04);d<-data.frame(time=pmin(event_time,censor_time),status=as.integer(event_time<=censor_time),g=g)
print(survdiff(Surv(time,status)~g,data=d,rho=1))
Output
Call:
survdiff(formula = Surv(time, status) ~ g, data = d, rho = 1)

     N Observed Expected (O-E)^2/E (O-E)^2/V
g=A 60     24.5     28.1     0.465      1.47
g=B 60     26.0     22.4     0.585      1.47

 Chisq= 1.5  on 1 degrees of freedom, p= 0.2

Sources

Statistics guide v4 (historical):
Python: Executed end to end through Rscript · R: Executed successfully in the validation environment
Reference's record:
Edition 2 review: Python: skip · R: not executed (Rscript unavailable); why not run: Python: Python-to-R bridge; Rscript is unavailable. R code was not executed. Python: Not run in the reference's review: Python-to-R bridge; Rscript is unavailable. R code was not executed. R: Reviewed but not run: R wasn't available to the reference's authors.

From the CodeSplash statistics guide (v4), entry 243, updated from the reference's edition 2 (reviewed 14 November 2026) as STAT243.