View source: R/flexsurvrtrunc.R

flexsurvrtrunc | R Documentation |

This function estimates the distribution of the time between an initial and final event, in situations where individuals are only observed if they have experienced both events before a certain time, thus they are right-truncated at this time. The time of the initial event provides information about the time from initial to final event, given the truncated observation scheme, and initial events are assumed to occur with an exponential growth rate.

```
flexsurvrtrunc(
t,
tinit,
rtrunc,
tmax,
data = NULL,
method = "joint",
dist,
theta = NULL,
fixed.theta = TRUE,
inits = NULL,
fixedpars = NULL,
dfns = NULL,
integ.opts = NULL,
cl = 0.95,
optim_control = list()
)
```

`t` |
Vector of time differences between an initial and final event for a set of individuals. | |||||||||||||||||||||||||||||||||||||||||

`tinit` |
Absolute time of the initial event for each individual. | |||||||||||||||||||||||||||||||||||||||||

`rtrunc` |
Individual-specific right truncation points on the same scale as | |||||||||||||||||||||||||||||||||||||||||

`tmax` |
Maximum possible time between initial and final events that could have been observed. This is only used in | |||||||||||||||||||||||||||||||||||||||||

`data` |
Data frame containing | |||||||||||||||||||||||||||||||||||||||||

`method` |
If | |||||||||||||||||||||||||||||||||||||||||

`dist` |
Typically, one of the strings in the first column of the following table, identifying a built-in distribution. This table also identifies the location parameters, and whether covariates on these parameters represent a proportional hazards (PH) or accelerated failure time (AFT) model. In an accelerated failure time model, the covariate speeds up or slows down the passage of time. So if the coefficient (presented on the log scale) is log(2), then doubling the covariate value would give half the expected survival time.
Alternatively, Very flexible spline-based distributions can also be fitted with
The parameterisations of the built-in distributions used here are the same
as in their built-in distribution functions: A package vignette "Distributions reference" lists the survivor functions and covariate effect parameterisations used by each built-in distribution. For the Weibull, exponential and log-normal distributions,
The Weibull parameterisation is different from that in
Similarly in the exponential distribution, the rate, rather than the mean, is modelled on covariates. The object | |||||||||||||||||||||||||||||||||||||||||

`theta` |
Initial value (or fixed value) for the exponential growth rate | |||||||||||||||||||||||||||||||||||||||||

`fixed.theta` |
Should | |||||||||||||||||||||||||||||||||||||||||

`inits` |
Initial values for the parameters of the parametric survival distributon. If not supplied, a heuristic is used. as is done in | |||||||||||||||||||||||||||||||||||||||||

`fixedpars` |
Integer indices of the parameters of the survival distribution that should be fixed to their values supplied in | |||||||||||||||||||||||||||||||||||||||||

`dfns` |
An alternative way to define a custom survival distribution (see
section “Custom distributions” below). A list whose components may
include
If | |||||||||||||||||||||||||||||||||||||||||

`integ.opts` |
List of named arguments to pass to
| |||||||||||||||||||||||||||||||||||||||||

`cl` |
Width of symmetric confidence intervals for maximum likelihood estimates, by default 0.95. | |||||||||||||||||||||||||||||||||||||||||

`optim_control` |
List to supply as the |

Covariates are not currently supported.

Note that `flexsurvreg`

, with an `rtrunc`

argument, can fit models for a similar kind of data, but those models ignore the information provided by the time of the initial event.

A nonparametric estimator of survival under right-truncation is also provided in `survrtrunc`

. See Seaman et al. (2020) for a full comparison of the alternative models.

Seaman, S., Presanis, A. and Jackson, C. (2020) Estimating a Time-to-Event Distribution from Right-Truncated Data in an Epidemic: a Review of Methods

`flexsurvreg`

, `survrtrunc`

.

```
set.seed(1)
## simulate time to initial event
X <- rexp(1000, 0.2)
## simulate time between initial and final event
T <- rgamma(1000, 2, 10)
## right-truncate to keep only those with final event time
## before tmax
tmax <- 40
obs <- X + T < tmax
rtrunc <- tmax - X
dat <- data.frame(X, T, rtrunc)[obs,]
flexsurvrtrunc(t=T, rtrunc=rtrunc, tinit=X, tmax=40, data=dat,
dist="gamma", theta=0.2)
flexsurvrtrunc(t=T, rtrunc=rtrunc, tinit=X, tmax=40, data=dat,
dist="gamma", theta=0.2, fixed.theta=FALSE)
flexsurvrtrunc(t=T, rtrunc=rtrunc, tinit=X, tmax=40, data=dat,
dist="gamma", theta=0.2, inits=c(1, 8))
flexsurvrtrunc(t=T, rtrunc=rtrunc, tinit=X, tmax=40, data=dat,
dist="gamma", theta=0.2, method="final")
flexsurvrtrunc(t=T, rtrunc=rtrunc, tinit=X, tmax=40, data=dat,
dist="gamma", fixed.theta=TRUE)
flexsurvrtrunc(t=T, rtrunc=rtrunc, tinit=X, tmax=40, data=dat,
dist="weibull", fixed.theta=TRUE)
flexsurvrtrunc(t=T, rtrunc=rtrunc, tinit=X, tmax=40, data=dat,
dist="lnorm", fixed.theta=TRUE)
flexsurvrtrunc(t=T, rtrunc=rtrunc, tinit=X, tmax=40, data=dat,
dist="gengamma", fixed.theta=TRUE)
flexsurvrtrunc(t=T, rtrunc=rtrunc, tinit=X, tmax=40, data=dat,
dist="gompertz", fixed.theta=TRUE)
```

Embedding an R snippet on your website

Add the following code to your website.

For more information on customizing the embed code, read Embedding Snippets.