% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/gg_brier.R
\name{gg_brier}
\alias{gg_brier}
\title{Brier score and CRPS for survival forests}
\usage{
gg_brier(object, ...)
}
\arguments{
\item{object}{A fitted \code{\link[randomForestSRC]{rfsrc}} survival
forest (\code{object$family == "surv"}).}

\item{...}{Currently unused; accepted for S3 dispatch compatibility.}
}
\value{
A \code{gg_brier} \code{data.frame} with columns
  \describe{
    \item{time}{event time grid (\code{object$time.interest}).}
    \item{brier}{overall Brier score at each time.}
    \item{bs.q25, bs.q50, bs.q75, bs.q100}{Brier score within each
      mortality-risk quartile (lowest to highest risk).}
    \item{bs.lower, bs.upper}{15th and 85th percentile of per-subject
      Brier contributions at each time. Used by
      \code{plot.gg_brier(by_quartile = TRUE)} to draw an envelope
      around the overall curve.}
    \item{crps}{running CRPS (overall) at each time, normalised by
      elapsed time.}
    \item{crps.q25, crps.q50, crps.q75, crps.q100}{running CRPS within
      each mortality-risk quartile.}
    \item{crps.lower, crps.upper}{running CRPS of the 15th / 85th
      per-subject Brier percentile, normalised by elapsed time.}
  }
  The integrated CRPS (a single scalar matching
  \code{get.brier.survival()$crps}) is attached as
  \code{attr(., "crps_integrated")}.
}
\description{
Extract the time-resolved Brier score and continuous ranked probability
score (CRPS) for a survival forest grown with \code{randomForestSRC}. The
Brier score is computed at each time on \code{object$time.interest}, both
overall and stratified by mortality-risk quartile. CRPS is the running
trapezoidal integral of the Brier score, normalised by elapsed time, and
is computed within each quartile and overall.
}
\details{
Wraps \code{\link[randomForestSRC]{get.brier.survival}} and
rebuilds the quartile decomposition + running CRPS from the returned
\code{brier.matx} and \code{mort} components, mirroring the computation
in the internal \code{plot.survival} function of \pkg{randomForestSRC}. The Brier score uses
inverse-probability-of-censoring weighting; the censoring distribution
is estimated either by Kaplan-Meier (\code{cens.model = "km"}, the
default) or by a separate censoring forest (\code{cens.model = "rfsrc"}).
}
\examples{
\dontrun{
data(pbc, package = "randomForestSRC")
rfsrc_pbc <- randomForestSRC::rfsrc(
  Surv(days, status) ~ ., data = pbc, nsplit = 10
)
gg_dta <- gg_brier(rfsrc_pbc)
plot(gg_dta)
plot(gg_dta, type = "crps")
plot(gg_dta, envelope = TRUE)   # overall line + 15-85\% envelope

# Multi-model comparison: stack gg_brier outputs and plot with ggplot2.
rf2 <- randomForestSRC::rfsrc(
  Surv(days, status) ~ ., data = pbc, nsplit = 10, mtry = 4
)
compare_dta <- dplyr::bind_rows(
  dplyr::mutate(gg_brier(rfsrc_pbc), model = "default"),
  dplyr::mutate(gg_brier(rf2),       model = "mtry=4")
)
ggplot2::ggplot(compare_dta,
  ggplot2::aes(x = time, y = brier, colour = model)) +
  ggplot2::geom_line()
}

}
\references{
Graf E., Schmoor C., Sauerbrei W., Schumacher M. (1999). Assessment and
comparison of prognostic classification schemes for survival data.
Statistics in Medicine, 18(17-18):2529-2545.

Gerds T.A., Schumacher M. (2006). Consistent estimation of the expected
Brier score in general survival models with right-censored event times.
Biometrical Journal, 48(6):1029-1040.
}
\seealso{
\code{\link{plot.gg_brier}},
  \code{\link[randomForestSRC]{get.brier.survival}},
  \code{\link{gg_error}}
}
