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. |
Authors: | Woojung Bae [aut, cre] , Dongrak Choi [aut] , Jun Yan [aut] , Sangwook Kang [aut] |
Maintainer: | Woojung Bae <[email protected]> |
License: | GPL (>= 3) |
Version: | 4.3.3 |
Built: | 2024-11-02 04:43:00 UTC |
Source: | https://github.com/woojungbae/afttest |
afttest
afttest( formula, data, path = 200, testType = "omni", eqType = "mns", optimType = "DFSANE", form = 1, pathsave = 50 )
afttest( formula, data, path = 200, testType = "omni", eqType = "mns", optimType = "DFSANE", form = 1, pathsave = 50 )
formula |
A formula expression, of the form |
data |
An optional data frame in which to interpret the variables occurring in the formula. |
path |
An integer value specifies 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 |
A character string specifying the type of the estimating equation used to obtain the regression parameters. The readers are refered to the aftgee package for details. The following are permitted:
|
optimType |
A character string specifying the type of the optimization method. The following are permitted:
|
form |
A character string specifying the covariate which will be tested.
The argument form is necessary only if |
pathsave |
An integer value specifies he number of paths saved among all the paths. The default is given by 50. Note that it requires a lot of memory if save all sampled paths (N by N matrix for each path andso path*N*N elements) |
afttest
returns an object of class afttest
.
An object of class afttest
is a list containing at least the following components:
a vector of beta estimates based on aftsrr
estimated standard error of the observed process
observed process
approximated process
standardized observed process
standardized approximated processes
obtained by the unstandardized test
obtained by 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
eqType
testType
optimType
For an omnibus test, the observed process and the realizations are composed of the n by n matrix that rows represent the t and columns represent the x in the time-transformed residual order.The observed process and the simulated processes for checking a functional form and a link function are given by the n by 1 vector which is a function of x in the time-transformed residual order.
## Simulate data from an AFT model library(afttest) library(survival) datgen <- function(n = 100) { z1 <- rbinom(n, 1, 0.5) z2 <- rnorm(n) e <- rnorm(n) tt <- exp(2 + z1 + z2 + 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(0) simdata <- datgen(n = 20) result <- afttest(Surv(Time, status) ~ z1 + z2, optimType = "DFSANE", data = simdata, testType="link", eqType="mns") summary(result) # afttestplot(result)
## Simulate data from an AFT model library(afttest) library(survival) datgen <- function(n = 100) { z1 <- rbinom(n, 1, 0.5) z2 <- rnorm(n) e <- rnorm(n) tt <- exp(2 + z1 + z2 + 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(0) simdata <- datgen(n = 20) result <- afttest(Surv(Time, status) ~ z1 + z2, optimType = "DFSANE", data = simdata, testType="link", eqType="mns") summary(result) # afttestplot(result)
afttestplot
afttestplot(object, path = 50, stdType = "std", quantile = NULL)
afttestplot(object, path = 50, stdType = "std", quantile = NULL)
object |
is a |
path |
A numeric value specifies the number of approximated processes plotted The default is set to be 100. |
stdType |
A character string specifying if the graph is based on the unstandardized test statistics or standardized test statistics The default is set to be "std". |
quantile |
A numeric vector specifies 5 of five quantiles within the range [0,1]. The default is set to be c(0.1,0.25,0.5,0.75,0.9). |
afttestplot
returns a plot based on the testType
:
an object 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. 0%, 10%, 25%, 40%, 50%, 60%, 75%, 90%, and 100% are used.
an object of the link function test is the form of n by 1 matrix
an object of the functional form test is the form of n by 1 matrix
See the documentation of ggplot2 and gridExtra for details.\
## Simulate data from an AFT model library(afttest) library(survival) datgen <- function(n = 100) { z1 <- rbinom(n, 1, 0.5) z2 <- rnorm(n) e <- rnorm(n) tt <- exp(2 + z1 + z2 + 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(0) simdata <- datgen(n = 20) result <- afttest(Surv(Time, status) ~ z1 + z2, optimType = "DFSANE", data = simdata, testType="link", eqType="mns") # summary(result) afttestplot(result)
## Simulate data from an AFT model library(afttest) library(survival) datgen <- function(n = 100) { z1 <- rbinom(n, 1, 0.5) z2 <- rnorm(n) e <- rnorm(n) tt <- exp(2 + z1 + z2 + 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(0) simdata <- datgen(n = 20) result <- afttest(Surv(Time, status) ~ z1 + z2, optimType = "DFSANE", data = simdata, testType="link", eqType="mns") # summary(result) afttestplot(result)
print.afttest
## S3 method for class 'afttest' print(x, ...)
## S3 method for class 'afttest' print(x, ...)
x |
is a |
... |
other options. |
print.afttest
returns a summary of a afttest
fit:
## Simulate data from an AFT model library(afttest) library(survival) datgen <- function(n = 100) { z1 <- rbinom(n, 1, 0.5) z2 <- rnorm(n) e <- rnorm(n) tt <- exp(2 + z1 + z2 + 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(0) simdata <- datgen(n = 20) result <- afttest(Surv(Time, status) ~ z1 + z2, optimType = "DFSANE", data = simdata, testType="link", eqType="mns") summary(result) # afttestplot(result)
## Simulate data from an AFT model library(afttest) library(survival) datgen <- function(n = 100) { z1 <- rbinom(n, 1, 0.5) z2 <- rnorm(n) e <- rnorm(n) tt <- exp(2 + z1 + z2 + 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(0) simdata <- datgen(n = 20) result <- afttest(Surv(Time, status) ~ z1 + z2, optimType = "DFSANE", data = simdata, testType="link", eqType="mns") summary(result) # afttestplot(result)
summary.afttest
## S3 method for class 'afttest' summary(object, ...)
## S3 method for class 'afttest' summary(object, ...)
object |
is a |
... |
other options. |
summary.afttest
returns a summary of a afttest
fit:
## Simulate data from an AFT model library(afttest) library(survival) datgen <- function(n = 100) { z1 <- rbinom(n, 1, 0.5) z2 <- rnorm(n) e <- rnorm(n) tt <- exp(2 + z1 + z2 + 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(0) simdata <- datgen(n = 20) result <- afttest(Surv(Time, status) ~ z1 + z2, optimType = "DFSANE", data = simdata, testType="link", eqType="mns") summary(result) # afttestplot(result)
## Simulate data from an AFT model library(afttest) library(survival) datgen <- function(n = 100) { z1 <- rbinom(n, 1, 0.5) z2 <- rnorm(n) e <- rnorm(n) tt <- exp(2 + z1 + z2 + 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(0) simdata <- datgen(n = 20) result <- afttest(Surv(Time, status) ~ z1 + z2, optimType = "DFSANE", data = simdata, testType="link", eqType="mns") summary(result) # afttestplot(result)