% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/sim-pc-hazard.R
\name{sim_phreg}
\alias{sim_phreg}
\title{Simulation of Output from Cox Model}
\usage{
sim_phreg(
  cox,
  n,
  data = NULL,
  Z = NULL,
  rr = NULL,
  strata = NULL,
  entry = NULL,
  extend = TRUE,
  cens = NULL,
  rrc = NULL,
  ...
)
}
\arguments{
\item{cox}{Output from \code{coxph} or \code{phreg} model fitting.}

\item{n}{Number of simulations.}

\item{data}{Data frame to extract covariates for simulations (draws from observed covariates).}

\item{Z}{Design matrix instead of data.}

\item{rr}{Vector of relative risks for Cox model.}

\item{strata}{Vector of strata.}

\item{entry}{Delayed entry variable for simulation.}

\item{extend}{Extend possible stratified baselines to largest endpoint.}

\item{cens}{Censoring specification (matrix = cumulative hazard, scalar = rate).}

\item{rrc}{Relative risks for Cox-type censoring.}

\item{...}{Arguments for \code{rchaz} (e.g., entry-time).}
}
\value{
Data frame with simulated event times, status, and covariates.
}
\description{
Simulates data that looks like fit from a Cox model. Automatically censors data 
for the highest value of the event times by using cumulative hazard.
}
\examples{
data(sTRACE)
nsim <- 100
coxs <-  phreg(Surv(time,status==9)~strata(chf)+vf+wmi,data=sTRACE)
set.seed(100)
sim3 <- sim_phreg(coxs,nsim,data=sTRACE)
head(sim3)
cc <-   phreg(Surv(time,status)~strata(chf)+vf+wmi,data=sim3)
cbind(coxs$coef,cc$coef)
plot(coxs,col=1); plot(cc,add=TRUE,col=2)

Z <- sim3[,c("vf","chf","wmi")]
strata <- sim3[,c("chf")]
rr <- exp(as.matrix(Z[,-2]) \%*\% coef(coxs))
sim4 <- sim_phreg(coxs,nsim,data=NULL,rr=rr,strata=strata)
sim4 <- cbind(sim4,Z)
cc <-   phreg(Surv(time,status)~strata(chf)+vf+wmi,data=sim4)
cbind(coxs$coef,cc$coef)
plot(coxs,col=1); plot(cc,add=TRUE,col=2)

}
\author{
Thomas Scheike
}
\keyword{simulation}
\keyword{survival}
