liferegr: Parametric regression models for failure time data

View source: R/RcppExports.R

liferegrR Documentation

Parametric regression models for failure time data

Description

Obtains the parameter estimates from parametric regression models with uncensored, right censored, left censored, or interval censored data.

Usage

liferegr(
  data,
  rep = "rep",
  stratum = "stratum",
  time = "time",
  time2 = "time2",
  event = "event",
  covariates = "treat",
  weight = "weight",
  id = "id",
  dist = "weibull",
  robust = 0L
)

Arguments

data

The input data frame that contains the following variables:

  • rep: The replication for by-group processing.

  • stratum: The stratum.

  • time: The follow-up time for right censored data, or the left end of each interval for interval censored data.

  • time2: The right end of each interval for interval censored data.

  • event: The event indicator, normally 1=event, 0=no event.

  • covariates: The values of baseline covariates. This is the full-rank design matrix (excluding the intercept) for the regression model, assuming that factor variables have already been expanded into dummy variables. The intercept will be added automatically.

  • weight: The weight for each observation.

  • id: The optional subject ID to group the score residuals in computing the robust sandwich variance.

rep

The name of the replication variable in the input data.

stratum

The name of the stratum variable in the input data.

time

The name of the time variable or the left end of each interval for interval censored data in the input data.

time2

The name of the right end of each interval for interval censored data in the input data.

event

The name of the event variable in the input data for right censored data.

covariates

The vector of names of baseline covariates in the input data.

weight

The name of the weighting variable in the input data.

id

The name of the id variable in the input data.

dist

The assumed distribution for time to event. Options include "exponential", "weibull", "lognormal", and "loglogistic" to be modeled on the log-scale, and "normal" and "logistic" to be modeled on the original scale.

robust

Whether a robust sandwich variance estimate should be computed. The default is TRUE if there are fractional weights or there is at least 1 id with >1 event. In the presence of the id variable, the score residual will be aggregated for each id when computing the robust sandwich variance estimate.

Details

There are two ways to specify the model, one for right censored data through the time and event variables, and the other for interval censored data through the time and time2 variables. For the second form, we follow the convention used in SAS PROC LIFEREG:

  • If lower is not missing, upper is not missing, and lower is equal to upper, then there is no censoring and the event occurred at time lower.

  • If lower is not missing, upper is not missing, and lower < upper, then the event time is censored within the interval (lower, upper).

  • If lower is missing, but upper is not missing, then upper will be used as the left censoring value.

  • If lower is not missing, but upper is missing, then lower will be used as the right censoring value.

  • If lower is not missing, upper is not missing, but lower > upper, or if both lower and upper are missing, then the observation will not be used.

Value

A list with the following components:

  • sumstat: The data frame of summary statistics of model fit with the following variables:

    • rep: The replication.

    • n: The number of observations.

    • nevents: The number of events.

    • loglik0: The log-likelihood under null.

    • loglik1: The maximum log-likelihood.

    • scoretest: The score test statistic.

  • parest: The data frame of parameter estimates with the following variables:

    • rep: The replication.

    • param: The name of the covariate for the parameter estimate.

    • beta: The parameter estimate.

    • sebeta: The standard error of parameter estimate.

    • z: The Wald test statistic.

    • expbeta: The exponentiated parameter.

    • vbeta: The covariance matrix for parameter estimates.

Author(s)

Kaifeng Lu, kaifenglu@gmail.com

Examples


library(dplyr)

# right censored data
liferegr(data = rawdata %>% mutate(treat = 1*(treatmentGroup == 1)),
         rep = "iterationNumber", stratum = "stratum",
         time = "timeUnderObservation", event = "event",
         covariates = "treat", dist = "weibull")

# tobit regression for left censored data
liferegr(data = tobin %>% mutate(time = ifelse(durable>0, durable, NA)),
         time = "time", time2 = "durable",
         covariates = c("age", "quant"), dist = "normal")


lrstat documentation built on June 23, 2024, 5:06 p.m.