| Title: | Model Diagnostics for Accelerated Failure Time Models |
|---|---|
| Description: | A collection of model checking methods for semiparametric accelerated failure time (AFT) models under the rank-based approach. For the (computational) efficiency, Gehan's weight is used. It provides functions to verify whether the observed data fit the specific model assumptions such as a functional form of each covariate, a link function, and an omnibus test. The p-value offered in this package is based on the Kolmogorov-type supremum test and the variance of the proposed test statistics is estimated through the re-sampling method. Furthermore, a graphical technique to compare the shape of the observed residual to a number of the approximated realizations is provided. See the following references; A general model-checking procedure for semiparametric accelerated failure time models, Statistics and Computing, 34 (3), 117 <doi:10.1007/s11222-024-10431-7>; Diagnostics for semiparametric accelerated failure time models with R package 'afttest', Journal of Statistical Software, to appear, <doi:10.48550/arXiv.2511.09823>. |
| Authors: | Woojung Bae [aut, cre] (ORCID: <https://orcid.org/0000-0001-6760-9900>), Dongrak Choi [aut] (ORCID: <https://orcid.org/0000-0003-3280-3329>), Jun Yan [aut] (ORCID: <https://orcid.org/0000-0003-4401-7296>), Sangwook Kang [aut] (ORCID: <https://orcid.org/0000-0003-2658-481X>) |
| Maintainer: | Woojung Bae <matt.woojung@gmail.com> |
| License: | GPL (>= 3) |
| Version: | 4.6.2 |
| Built: | 2026-10-11 07:42:33 UTC |
| Source: | https://github.com/woojungbae/afttest |
Performs model-checking procedures for a semiparametric AFT model. This is a generic function with methods for formulas and fitted objects from the aftgee package.
afttest(object, ...)afttest(object, ...)
object |
A formula or a fitted model object (e.g., from |
... |
Other arguments passed to methods. See the documentation for
|
An object of class afttest or htest.
An object is a list containing at least the following components:
a vector of beta estimates based on estMethod
null hypothesis for each testType
estimated standard error of the observed process
observed process
approximated process
standardized observed process
standardized approximated processes
finite-resampling Monte Carlo p-value for the unstandardized test
finite-resampling Monte Carlo p-value for the standardized test
a data frame of observed failure time, right censoring indicator, covariates (scaled), time-transformed residual based on beta estimates
the number of sample paths
testType
eqType
estMethod
npathsave
For an omnibus test, the observed process and the realizations are composed of the n by n matrix where rows represent the t and columns represent the x in the time-transformed residual order. The observed process and the simulated processesfor checking a functional form and a link function are given by the n by 1 vectorwhich is a function of x in the time-transformed residual order.
library(survival) library(aftgee) library(afttest) datgen <- function(n = 100) { z1 <- rbinom(n, 1, 0.5) z2 <- rnorm(n) e <- rnorm(n) tt <- exp(2 + z1 + z2 + 0.5 * z2^2 + e) cen <- runif(n, 0, 100) data.frame(Time = pmin(tt, cen), status = 1 * (tt < cen), z1 = z1, z2 = z2, id = 1:n) } set.seed(1) simdata <- datgen(300) # -------------------------------------------------- # Method 1: Formula (Runs quickly for CRAN tests) # -------------------------------------------------- result_form <- afttest(Surv(Time, status) ~ z1 + z2, data = simdata, npath = 50, testType = "covForm", estMethod = "rr", eqType = "ns", covTested = "z2", npathsave = 50, linApprox = TRUE, seed = 1) print(result_form) plot(result_form, std = TRUE) # -------------------------------------------------- # Method 2: Fitted aftsrr object (Induced Smoothing) # -------------------------------------------------- fit_srr <- aftsrr(Surv(Time, status) ~ z1 + z2, data = simdata, eqType = "is", rankWeights = "gehan") result_srr <- afttest(fit_srr, data = simdata, npath = 100, testType = "covForm", covTested = "z2", npathsave = 50, linApprox = TRUE, seed = 1) summary(result_srr) plot(result_srr, std = FALSE) # -------------------------------------------------- # Method 3: Fitted aftgee object (Least Squares) # -------------------------------------------------- fit_gee <- aftgee(Surv(Time, status) ~ z1 + z2, data = simdata) result_gee <- afttest(fit_gee, data = simdata, npath = 100, testType = "covForm", covTested = "z2", npathsave = 50, linApprox = TRUE, seed = 1) print(result_gee) # -------------------------------------------------- # Method 4: Standard Resampling (linApprox = FALSE) # -------------------------------------------------- result_resamp <- afttest(Surv(Time, status) ~ z1 + z2, data = simdata, npath = 100, testType = "covForm", estMethod = "rr", eqType = "ns", covTested = "z2", npathsave = 50, linApprox = FALSE, seed = 1) summary(result_resamp)library(survival) library(aftgee) library(afttest) datgen <- function(n = 100) { z1 <- rbinom(n, 1, 0.5) z2 <- rnorm(n) e <- rnorm(n) tt <- exp(2 + z1 + z2 + 0.5 * z2^2 + e) cen <- runif(n, 0, 100) data.frame(Time = pmin(tt, cen), status = 1 * (tt < cen), z1 = z1, z2 = z2, id = 1:n) } set.seed(1) simdata <- datgen(300) # -------------------------------------------------- # Method 1: Formula (Runs quickly for CRAN tests) # -------------------------------------------------- result_form <- afttest(Surv(Time, status) ~ z1 + z2, data = simdata, npath = 50, testType = "covForm", estMethod = "rr", eqType = "ns", covTested = "z2", npathsave = 50, linApprox = TRUE, seed = 1) print(result_form) plot(result_form, std = TRUE) # -------------------------------------------------- # Method 2: Fitted aftsrr object (Induced Smoothing) # -------------------------------------------------- fit_srr <- aftsrr(Surv(Time, status) ~ z1 + z2, data = simdata, eqType = "is", rankWeights = "gehan") result_srr <- afttest(fit_srr, data = simdata, npath = 100, testType = "covForm", covTested = "z2", npathsave = 50, linApprox = TRUE, seed = 1) summary(result_srr) plot(result_srr, std = FALSE) # -------------------------------------------------- # Method 3: Fitted aftgee object (Least Squares) # -------------------------------------------------- fit_gee <- aftgee(Surv(Time, status) ~ z1 + z2, data = simdata) result_gee <- afttest(fit_gee, data = simdata, npath = 100, testType = "covForm", covTested = "z2", npathsave = 50, linApprox = TRUE, seed = 1) print(result_gee) # -------------------------------------------------- # Method 4: Standard Resampling (linApprox = FALSE) # -------------------------------------------------- result_resamp <- afttest(Surv(Time, status) ~ z1 + z2, data = simdata, npath = 100, testType = "covForm", estMethod = "rr", eqType = "ns", covTested = "z2", npathsave = 50, linApprox = FALSE, seed = 1) summary(result_resamp)
Model Diagnostics for Generalized Estimating Equation (aftgee) Objects
## S3 method for class 'aftgee' afttest( object, data, npath = 200, testType = "omnibus", eqType = "ls", covTested = 1, npathsave = 50, linApprox = TRUE, seed = NULL, ... )## S3 method for class 'aftgee' afttest( object, data, npath = 200, testType = "omnibus", eqType = "ls", covTested = 1, npathsave = 50, linApprox = TRUE, seed = NULL, ... )
object |
A fitted model object of class |
data |
An optional data frame in which to interpret the variables occurring in the formula. |
npath |
An integer value specifying the number of approximated processes. The default is given by 200. |
testType |
A character string specifying the type of the test. The following are permitted:
|
eqType |
The estimating-equation type used for the diagnostic
procedure. For a fitted |
covTested |
A single design-matrix column to test when |
npathsave |
An integer value specifying the number of simulated paths retained in the returned object. The default is 50. |
linApprox |
A logical value. If |
seed |
An optional integer specifying the random seed for reproducibility. |
... |
Other arguments passed to methods. |
Model Diagnostics for Smooth Rank Regression (aftsrr) Objects
## S3 method for class 'aftsrr' afttest( object, data, npath = 200, testType = "omnibus", eqType = NULL, covTested = 1, npathsave = 50, linApprox = TRUE, seed = NULL, ... )## S3 method for class 'aftsrr' afttest( object, data, npath = 200, testType = "omnibus", eqType = NULL, covTested = 1, npathsave = 50, linApprox = TRUE, seed = NULL, ... )
object |
A fitted model object of class |
data |
An optional data frame in which to interpret the variables occurring in the formula. |
npath |
An integer value specifying the number of approximated processes. The default is given by 200. |
testType |
A character string specifying the type of the test. The following are permitted:
|
eqType |
An optional character string specifying the type of the
estimating equation. For a fitted |
covTested |
A single design-matrix column to test when |
npathsave |
An integer value specifying the number of simulated paths retained in the returned object. The default is 50. |
linApprox |
A logical value. If |
seed |
An optional integer specifying the random seed for reproducibility. |
... |
Other arguments passed to methods. |
Model Diagnostics for AFT Models using Formulas
## S3 method for class 'formula' afttest( object, data, npath = 200, testType = "omnibus", estMethod = "rr", eqType = "ns", covTested = 1, npathsave = 50, linApprox = TRUE, seed = NULL, ... )## S3 method for class 'formula' afttest( object, data, npath = 200, testType = "omnibus", estMethod = "rr", eqType = "ns", covTested = 1, npathsave = 50, linApprox = TRUE, seed = NULL, ... )
object |
A formula expression, of the form |
data |
An optional data frame in which to interpret the variables occurring in the formula. |
npath |
An integer value specifying the number of approximated processes. The default is given by 200. |
testType |
A character string specifying the type of the test. The following are permitted:
|
estMethod |
A character string specifying the type of the estimator used. The readers are referred to the aftgee package for details. The following are permitted:
|
eqType |
A character string specifying the type of the estimating equation used to obtain the regression parameters. The readers are referred to the aftgee package for details. The following are permitted:
|
covTested |
A single design-matrix column to test when |
npathsave |
An integer value specifying the number of simulated paths retained in the returned object. The default is 50. Retaining paths can require substantial memory for omnibus tests. |
linApprox |
A logical value. If |
seed |
An optional integer specifying the random seed for reproducibility. |
... |
Other arguments passed to methods. |
Plotting Method for Semiparametric AFT Model Diagnostics
## S3 method for class 'afttest' plot(x, npath = 50, std = TRUE, quantile = NULL, ...)## S3 method for class 'afttest' plot(x, npath = 50, std = TRUE, quantile = NULL, ...)
x |
An object of class |
npath |
A numeric value specifying the number of approximated processes to plot. The default is set to 50. |
std |
A logical value specifying if the graph is based on
the standardized test statistics ( |
quantile |
A numeric vector specifying 5 quantiles within the range [0,1].
The default is set to |
... |
Other arguments passed to methods for future extension. |
plot.afttest returns a plot based on the testType:
an x of the omnibus test is the form of n by n matrix, some quantiles of x, which are used in weight, are plotted for graphs, i.e. 10%, 25%, 50%, 75%, and 90% are used by default.
an x of the link function test is the form of n by 1 matrix
an x of the functional form test is the form of n by 1 matrix
See the documentation of ggplot2 and gridExtra for details.
library(survival) library(aftgee) library(afttest) datgen <- function(n = 100) { z1 <- rbinom(n, 1, 0.5) z2 <- rnorm(n) e <- rnorm(n) tt <- exp(2 + z1 + z2 + 0.5 * z2^2 + e) cen <- runif(n, 0, 100) data.frame(Time = pmin(tt, cen), status = 1 * (tt < cen), z1 = z1, z2 = z2, id = 1:n) } set.seed(1) simdata <- datgen(300) # -------------------------------------------------- # Method 1: Formula (Runs quickly for CRAN tests) # -------------------------------------------------- result_form <- afttest(Surv(Time, status) ~ z1 + z2, data = simdata, npath = 50, testType = "covForm", estMethod = "rr", eqType = "ns", covTested = "z2", npathsave = 50, linApprox = TRUE, seed = 1) print(result_form) plot(result_form, std = TRUE) # -------------------------------------------------- # Method 2: Fitted aftsrr object (Induced Smoothing) # -------------------------------------------------- fit_srr <- aftsrr(Surv(Time, status) ~ z1 + z2, data = simdata, eqType = "is", rankWeights = "gehan") result_srr <- afttest(fit_srr, data = simdata, npath = 100, testType = "covForm", covTested = "z2", npathsave = 50, linApprox = TRUE, seed = 1) summary(result_srr) plot(result_srr, std = FALSE) # -------------------------------------------------- # Method 3: Fitted aftgee object (Least Squares) # -------------------------------------------------- fit_gee <- aftgee(Surv(Time, status) ~ z1 + z2, data = simdata) result_gee <- afttest(fit_gee, data = simdata, npath = 100, testType = "covForm", covTested = "z2", npathsave = 50, linApprox = TRUE, seed = 1) print(result_gee) # -------------------------------------------------- # Method 4: Standard Resampling (linApprox = FALSE) # -------------------------------------------------- result_resamp <- afttest(Surv(Time, status) ~ z1 + z2, data = simdata, npath = 100, testType = "covForm", estMethod = "rr", eqType = "ns", covTested = "z2", npathsave = 50, linApprox = FALSE, seed = 1) summary(result_resamp)library(survival) library(aftgee) library(afttest) datgen <- function(n = 100) { z1 <- rbinom(n, 1, 0.5) z2 <- rnorm(n) e <- rnorm(n) tt <- exp(2 + z1 + z2 + 0.5 * z2^2 + e) cen <- runif(n, 0, 100) data.frame(Time = pmin(tt, cen), status = 1 * (tt < cen), z1 = z1, z2 = z2, id = 1:n) } set.seed(1) simdata <- datgen(300) # -------------------------------------------------- # Method 1: Formula (Runs quickly for CRAN tests) # -------------------------------------------------- result_form <- afttest(Surv(Time, status) ~ z1 + z2, data = simdata, npath = 50, testType = "covForm", estMethod = "rr", eqType = "ns", covTested = "z2", npathsave = 50, linApprox = TRUE, seed = 1) print(result_form) plot(result_form, std = TRUE) # -------------------------------------------------- # Method 2: Fitted aftsrr object (Induced Smoothing) # -------------------------------------------------- fit_srr <- aftsrr(Surv(Time, status) ~ z1 + z2, data = simdata, eqType = "is", rankWeights = "gehan") result_srr <- afttest(fit_srr, data = simdata, npath = 100, testType = "covForm", covTested = "z2", npathsave = 50, linApprox = TRUE, seed = 1) summary(result_srr) plot(result_srr, std = FALSE) # -------------------------------------------------- # Method 3: Fitted aftgee object (Least Squares) # -------------------------------------------------- fit_gee <- aftgee(Surv(Time, status) ~ z1 + z2, data = simdata) result_gee <- afttest(fit_gee, data = simdata, npath = 100, testType = "covForm", covTested = "z2", npathsave = 50, linApprox = TRUE, seed = 1) print(result_gee) # -------------------------------------------------- # Method 4: Standard Resampling (linApprox = FALSE) # -------------------------------------------------- result_resamp <- afttest(Surv(Time, status) ~ z1 + z2, data = simdata, npath = 100, testType = "covForm", estMethod = "rr", eqType = "ns", covTested = "z2", npathsave = 50, linApprox = FALSE, seed = 1) summary(result_resamp)
Print Method for Semiparametric AFT Model Diagnostics
## S3 method for class 'afttest' print(x, ...)## S3 method for class 'afttest' print(x, ...)
x |
An object of class |
... |
Other arguments passed to methods. |
print.afttest returns a summary of an afttest fit.
library(survival) library(aftgee) library(afttest) datgen <- function(n = 100) { z1 <- rbinom(n, 1, 0.5) z2 <- rnorm(n) e <- rnorm(n) tt <- exp(2 + z1 + z2 + 0.5 * z2^2 + e) cen <- runif(n, 0, 100) data.frame(Time = pmin(tt, cen), status = 1 * (tt < cen), z1 = z1, z2 = z2, id = 1:n) } set.seed(1) simdata <- datgen(300) # -------------------------------------------------- # Method 1: Formula (Runs quickly for CRAN tests) # -------------------------------------------------- result_form <- afttest(Surv(Time, status) ~ z1 + z2, data = simdata, npath = 50, testType = "covForm", estMethod = "rr", eqType = "ns", covTested = "z2", npathsave = 50, linApprox = TRUE, seed = 1) print(result_form) plot(result_form, std = TRUE) # -------------------------------------------------- # Method 2: Fitted aftsrr object (Induced Smoothing) # -------------------------------------------------- fit_srr <- aftsrr(Surv(Time, status) ~ z1 + z2, data = simdata, eqType = "is", rankWeights = "gehan") result_srr <- afttest(fit_srr, data = simdata, npath = 100, testType = "covForm", covTested = "z2", npathsave = 50, linApprox = TRUE, seed = 1) summary(result_srr) plot(result_srr, std = FALSE) # -------------------------------------------------- # Method 3: Fitted aftgee object (Least Squares) # -------------------------------------------------- fit_gee <- aftgee(Surv(Time, status) ~ z1 + z2, data = simdata) result_gee <- afttest(fit_gee, data = simdata, npath = 100, testType = "covForm", covTested = "z2", npathsave = 50, linApprox = TRUE, seed = 1) print(result_gee) # -------------------------------------------------- # Method 4: Standard Resampling (linApprox = FALSE) # -------------------------------------------------- result_resamp <- afttest(Surv(Time, status) ~ z1 + z2, data = simdata, npath = 100, testType = "covForm", estMethod = "rr", eqType = "ns", covTested = "z2", npathsave = 50, linApprox = FALSE, seed = 1) summary(result_resamp)library(survival) library(aftgee) library(afttest) datgen <- function(n = 100) { z1 <- rbinom(n, 1, 0.5) z2 <- rnorm(n) e <- rnorm(n) tt <- exp(2 + z1 + z2 + 0.5 * z2^2 + e) cen <- runif(n, 0, 100) data.frame(Time = pmin(tt, cen), status = 1 * (tt < cen), z1 = z1, z2 = z2, id = 1:n) } set.seed(1) simdata <- datgen(300) # -------------------------------------------------- # Method 1: Formula (Runs quickly for CRAN tests) # -------------------------------------------------- result_form <- afttest(Surv(Time, status) ~ z1 + z2, data = simdata, npath = 50, testType = "covForm", estMethod = "rr", eqType = "ns", covTested = "z2", npathsave = 50, linApprox = TRUE, seed = 1) print(result_form) plot(result_form, std = TRUE) # -------------------------------------------------- # Method 2: Fitted aftsrr object (Induced Smoothing) # -------------------------------------------------- fit_srr <- aftsrr(Surv(Time, status) ~ z1 + z2, data = simdata, eqType = "is", rankWeights = "gehan") result_srr <- afttest(fit_srr, data = simdata, npath = 100, testType = "covForm", covTested = "z2", npathsave = 50, linApprox = TRUE, seed = 1) summary(result_srr) plot(result_srr, std = FALSE) # -------------------------------------------------- # Method 3: Fitted aftgee object (Least Squares) # -------------------------------------------------- fit_gee <- aftgee(Surv(Time, status) ~ z1 + z2, data = simdata) result_gee <- afttest(fit_gee, data = simdata, npath = 100, testType = "covForm", covTested = "z2", npathsave = 50, linApprox = TRUE, seed = 1) print(result_gee) # -------------------------------------------------- # Method 4: Standard Resampling (linApprox = FALSE) # -------------------------------------------------- result_resamp <- afttest(Surv(Time, status) ~ z1 + z2, data = simdata, npath = 100, testType = "covForm", estMethod = "rr", eqType = "ns", covTested = "z2", npathsave = 50, linApprox = FALSE, seed = 1) summary(result_resamp)
Summary Method for Semiparametric AFT Model Diagnostics
## S3 method for class 'afttest' summary(object, ...)## S3 method for class 'afttest' summary(object, ...)
object |
An object of class |
... |
Other arguments passed to methods. |
summary.afttest returns a detailed summary of an afttest fit.
library(survival) library(aftgee) library(afttest) datgen <- function(n = 100) { z1 <- rbinom(n, 1, 0.5) z2 <- rnorm(n) e <- rnorm(n) tt <- exp(2 + z1 + z2 + 0.5 * z2^2 + e) cen <- runif(n, 0, 100) data.frame(Time = pmin(tt, cen), status = 1 * (tt < cen), z1 = z1, z2 = z2, id = 1:n) } set.seed(1) simdata <- datgen(300) # -------------------------------------------------- # Method 1: Formula (Runs quickly for CRAN tests) # -------------------------------------------------- result_form <- afttest(Surv(Time, status) ~ z1 + z2, data = simdata, npath = 50, testType = "covForm", estMethod = "rr", eqType = "ns", covTested = "z2", npathsave = 50, linApprox = TRUE, seed = 1) print(result_form) plot(result_form, std = TRUE) # -------------------------------------------------- # Method 2: Fitted aftsrr object (Induced Smoothing) # -------------------------------------------------- fit_srr <- aftsrr(Surv(Time, status) ~ z1 + z2, data = simdata, eqType = "is", rankWeights = "gehan") result_srr <- afttest(fit_srr, data = simdata, npath = 100, testType = "covForm", covTested = "z2", npathsave = 50, linApprox = TRUE, seed = 1) summary(result_srr) plot(result_srr, std = FALSE) # -------------------------------------------------- # Method 3: Fitted aftgee object (Least Squares) # -------------------------------------------------- fit_gee <- aftgee(Surv(Time, status) ~ z1 + z2, data = simdata) result_gee <- afttest(fit_gee, data = simdata, npath = 100, testType = "covForm", covTested = "z2", npathsave = 50, linApprox = TRUE, seed = 1) print(result_gee) # -------------------------------------------------- # Method 4: Standard Resampling (linApprox = FALSE) # -------------------------------------------------- result_resamp <- afttest(Surv(Time, status) ~ z1 + z2, data = simdata, npath = 100, testType = "covForm", estMethod = "rr", eqType = "ns", covTested = "z2", npathsave = 50, linApprox = FALSE, seed = 1) summary(result_resamp)library(survival) library(aftgee) library(afttest) datgen <- function(n = 100) { z1 <- rbinom(n, 1, 0.5) z2 <- rnorm(n) e <- rnorm(n) tt <- exp(2 + z1 + z2 + 0.5 * z2^2 + e) cen <- runif(n, 0, 100) data.frame(Time = pmin(tt, cen), status = 1 * (tt < cen), z1 = z1, z2 = z2, id = 1:n) } set.seed(1) simdata <- datgen(300) # -------------------------------------------------- # Method 1: Formula (Runs quickly for CRAN tests) # -------------------------------------------------- result_form <- afttest(Surv(Time, status) ~ z1 + z2, data = simdata, npath = 50, testType = "covForm", estMethod = "rr", eqType = "ns", covTested = "z2", npathsave = 50, linApprox = TRUE, seed = 1) print(result_form) plot(result_form, std = TRUE) # -------------------------------------------------- # Method 2: Fitted aftsrr object (Induced Smoothing) # -------------------------------------------------- fit_srr <- aftsrr(Surv(Time, status) ~ z1 + z2, data = simdata, eqType = "is", rankWeights = "gehan") result_srr <- afttest(fit_srr, data = simdata, npath = 100, testType = "covForm", covTested = "z2", npathsave = 50, linApprox = TRUE, seed = 1) summary(result_srr) plot(result_srr, std = FALSE) # -------------------------------------------------- # Method 3: Fitted aftgee object (Least Squares) # -------------------------------------------------- fit_gee <- aftgee(Surv(Time, status) ~ z1 + z2, data = simdata) result_gee <- afttest(fit_gee, data = simdata, npath = 100, testType = "covForm", covTested = "z2", npathsave = 50, linApprox = TRUE, seed = 1) print(result_gee) # -------------------------------------------------- # Method 4: Standard Resampling (linApprox = FALSE) # -------------------------------------------------- result_resamp <- afttest(Surv(Time, status) ~ z1 + z2, data = simdata, npath = 100, testType = "covForm", estMethod = "rr", eqType = "ns", covTested = "z2", npathsave = 50, linApprox = FALSE, seed = 1) summary(result_resamp)