Learn R Programming

afttest (version 4.5.1)

plot.afttest: plot.afttest

Description

plot.afttest

Usage

# S3 method for afttest
plot(x, npath = 50, std = TRUE, quantile = NULL, ...)

Value

plot.afttest returns a plot based on the testType:

omnibus

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. 0%, 10%, 25%, 40%, 50%, 60%, 75%, 90%, and 100% are used.

link

an x of the link function test is the form of n by 1 matrix

covform

an x of the functional form test is the form of n by 1 matrix

See the documentation of ggplot2 and gridExtra for details.

Arguments

x

is a afttest fit

npath

A numeric value specifies the number of approximated processes plotted. The default is set to be 100.

std

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).

...

for future extension

Examples

Run this code
## Simulate data from an AFT model
library(afttest)
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, data = simdata, npath = 200, 
                  testType = "link", estMethod = "rr", 
                  eqType = "ns", npathsave = 50)
# print(result)
# summary(result)
plot(result)

Run the code above in your browser using DataLab