% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/coxstream.R
\name{coxstream}
\alias{coxstream}
\title{Fit a Cox proportional hazards model via streaming Newton-Raphson}
\usage{
coxstream(
  formula,
  data,
  init = NULL,
  max_iter = 25L,
  tol = 1e-09,
  verbose = FALSE
)
}
\arguments{
\item{formula}{A formula with a \code{survival::Surv()} response,
e.g. \code{Surv(time, event) ~ x1 + x2}.}

\item{data}{A data frame containing the variables in \code{formula}.}

\item{init}{Optional numeric vector of starting values for beta (length p).
Defaults to zero.}

\item{max_iter}{Maximum Newton-Raphson iterations. Default 25.}

\item{tol}{Convergence tolerance on the max absolute score element.
Default 1e-9.}

\item{verbose}{Currently unused; reserved for future per-iteration output.
Default \code{FALSE}.}
}
\value{
An object of class \code{"coxstream"} with components:
\item{coefficients}{Named numeric vector of fitted coefficients.}
\item{var}{Variance-covariance matrix (inverse of observed information).}
\item{loglik}{Log-likelihood at convergence.}
\item{n_iter}{Number of NR iterations taken.}
\item{n}{Number of rows.}
\item{formula}{The formula used.}
\item{call}{The matched call.}
}
\description{
Fits the Cox PH model using a single descending-time-order pass per
Newton-Raphson iteration. Peak RAM is O(p^2) regardless of n, making it
suitable for large datasets. Produces identical coefficients to
\code{survival::coxph()} with Efron tie correction.
}
\examples{
library(survival)
fit <- coxstream(Surv(time, status) ~ age + sex, data = lung)
coef(fit)

}
