liferegr: Parametric Regression Models for Failure Time Data

View source: R/wrappers.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 = "",
  stratum = "",
  time = "time",
  time2 = "",
  event = "event",
  covariates = "",
  weight = "",
  offset = "",
  id = "",
  dist = "weibull",
  robust = FALSE,
  plci = FALSE,
  alpha = 0.05
)

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, 1=event, 0=no event.

  • covariates: The values of baseline covariates.

  • weight: The weight for each observation.

  • offset: The offset for each observation.

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

rep

The name(s) of the replication variable(s) in the input data.

stratum

The name(s) of the stratum variable(s) 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 weight variable in the input data.

offset

The name of the offset 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. In the presence of the id variable, the score residuals will be aggregated for each id when computing the robust sandwich variance estimate.

plci

Whether to obtain profile likelihood confidence interval.

alpha

The two-sided significance level.

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 (lower) and time2 (upper) 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:

    • n: The number of observations.

    • nevents: The number of events.

    • loglik0: The log-likelihood under null.

    • loglik1: The maximum log-likelihood.

    • niter: The number of Newton-Raphson iterations.

    • dist: The assumed distribution.

    • p: The number of parameters, including the intercept, regression coefficients associated with the covariates, and the log scale parameters for the strata.

    • nvar: The number of regression coefficients associated with the covariates (excluding the intercept).

    • robust: Whether the robust sandwich variance estimate is requested.

    • rep: The replication.

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

    • 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 for the parameter.

    • expbeta: The exponentiated parameter estimate.

    • vbeta: The covariance matrix for parameter estimates.

    • lower: The lower limit of confidence interval.

    • upper: The upper limit of confidence interval.

    • p: The p-value from the chi-square test.

    • method: The method to compute the confidence interval and p-value.

    • sebeta_naive: The naive standard error of parameter estimate if robust variance is requested.

    • vbeta_naive: The naive covariance matrix for parameter estimates if robust variance is requested.

    • rep: The replication.

  • p: The number of parameters.

  • nvar: The number of columns of the design matrix excluding the intercept.

  • param: The parameter names.

  • beta: The parameter estimate.

  • vbeta: The covariance matrix for parameter estimates.

  • vbeta_naive: The naive covariance matrix for parameter estimates.

  • terms: The terms object.

  • xlevels: A record of the levels of the factors used in fitting.

  • data: The input data.

  • rep: The name(s) of the replication variable(s).

  • stratum: The name(s) of the stratum variable(s).

  • time: The name of the time variable.

  • time2: The name of the time2 variable.

  • event: The name of the event variable.

  • covariates: The names of baseline covariates.

  • weight: The name of the weight variable.

  • offset: The name of the offset variable.

  • id: The name of the id variable.

  • dist: The assumed distribution for time to event.

  • robust: Whether a robust sandwich variance estimate should be computed.

  • plci: Whether to obtain profile likelihood confidence interval.

  • alpha: The two-sided significance level.

Author(s)

Kaifeng Lu, kaifenglu@gmail.com

References

John D. Kalbfleisch and Ross L. Prentice. The Statistical Analysis of Failure Time Data. Wiley: New York, 1980.

Examples


library(dplyr)

# right censored data
(fit1 <- 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
(fit2 <- liferegr(
  data = tobin %>% mutate(time = ifelse(durable>0, durable, NA)),
  time = "time", time2 = "durable",
  covariates = c("age", "quant"), dist = "normal"))


lrstat documentation built on Oct. 18, 2024, 9:06 a.m.