% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/solvePiecewiseConstantExponentialDistribution.R
\name{solvePiecewiseConstantExponentialDistribution}
\alias{solvePiecewiseConstantExponentialDistribution}
\title{Compute Constant Rates of Piecewise Exponential Distribution}
\usage{
solvePiecewiseConstantExponentialDistribution(surv_prob, times)
}
\arguments{
\item{surv_prob}{numeric. A vector of survival probabilities at \code{times}.}

\item{times}{numeric. A vector of time points where event rates change.
\code{times} and \code{surv_prob} must be of equal length.}
}
\value{
a data frame of two columns
\describe{
\item{\code{end_time}}{End time for a constant event rate. The start time of
the first time window is 0. }
\item{piecewise_risk}{A constant event rate in the time window ending with
\code{end_time} on the same row. }
}
}
\description{
This function computes the rate parameters \code{lambda} in each of the time
windows. \code{lambda} are natural parameters of piecewise exponential
distribution, but in practice, users may define the distribution by
specifying the survival probabilities at time points where event rates
change.

This function returns a data frame, which can be used as input of the
argument \code{risk} of the data generator \code{PiecewiseConstantExponentialRNG}.
}
\examples{
solvePiecewiseConstantExponentialDistribution(
  surv_prob = c(.9, .75, .64, .42, .28),
  times = c(.4, 1.2, 4, 5.5, 9)
)

}
