% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/geoms-clinical.R
\name{geom_hr}
\alias{geom_hr}
\title{Hazard ratio forest plot (Cox proportional hazards)}
\usage{
geom_hr(
  mapping = NULL,
  data = NULL,
  ref_level = NULL,
  color = NULL,
  linewidth = NULL
)
}
\arguments{
\item{mapping, data}{Standard layer overrides. Map \code{time}, \code{status}
(1/TRUE = event, 0/FALSE = censored), and the treatment arm to
\code{group} (or \code{color}, which doubles as \code{group}).}

\item{ref_level}{Reference level for the hazard ratio; \code{NULL} (default)
uses the first observed group.}

\item{color}{Marker and whisker color.}

\item{linewidth}{Whisker width.}
}
\value{
A \link{Layer} to add with \code{+}.
}
\description{
Fits a Cox proportional-hazards model from scratch (Newton-Raphson on
the Breslow partial likelihood; see \code{\link[=stat_coxph]{stat_coxph()}}) and plots the
resulting hazard ratio and Wald 95\% CI per group, down a category axis
with a no-effect reference line at HR = 1 — \code{\link[=geom_forest]{geom_forest()}} paired with
the Cox engine so the whole model-to-plot pipeline is one call.
}
\examples{
set.seed(1)
d <- data.frame(
  time = c(rexp(60, 0.08), rexp(60, 0.05)),
  status = rbinom(120, 1, 0.8),
  arm = rep(c("placebo", "treatment"), each = 60)
)
ggnext(d, aes(time = time, status = status, group = arm)) +
  geom_hr(ref_level = "placebo") +
  labs(title = "Hazard ratio (Cox model)", x = "Hazard ratio (95\% CI)", y = NULL)
}
