Learn R Programming

afttest (version 4.5.2.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
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)

# linApprox = TRUE
result = afttest(object = Surv(Time, status) ~ z1 + z2, data = simdata,
                 npath = 100, testType = "covForm", estMethod = "rr",
                 eqType = "ns", covTested = "z2", npathsave = 50,
                 linApprox = TRUE, seed = 1)
result$p_value
result$p_std_value
print(result)
summary(result)
plot(result, std = FALSE)
plot(result, std = TRUE)

# result = afttest(object = Surv(Time, status) ~ z1 + z2, data = simdata,
#                  npath = 100, testType = "covForm", estMethod = "rr",
#                  eqType = "is", covTested = "z2", npathsave = 50,
#                  linApprox = TRUE, seed = 1)
# result$p_value
# result$p_std_value
# print(result)
# summary(result)
# plot(result, std = FALSE)
# plot(result, std = TRUE)
#
# result = afttest(object = Surv(Time, status) ~ z1 + z2, data = simdata,
#                  npath = 100, testType = "covForm", estMethod = "ls",
#                  eqType = "ls", covTested = "z2", npathsave = 50,
#                  linApprox = TRUE, seed = 1)
# result$p_value
# result$p_std_value
# print(result)
# summary(result)
# plot(result, std = FALSE)
# plot(result, std = TRUE)
#
# # linApprox = FALSE
# result = afttest(object = Surv(Time, status) ~ z1 + z2, data = simdata,
#                  npath = 100, testType = "covForm", estMethod = "rr",
#                  eqType = "ns", covTested = "z2", npathsave = 50,
#                  linApprox = FALSE, seed = 1)
# result$p_value
# result$p_std_value
# print(result)
# summary(result)
# plot(result, std = FALSE)
# plot(result, std = TRUE)
#
# result = afttest(object = Surv(Time, status) ~ z1 + z2, data = simdata,
#                  npath = 100, testType = "covForm", estMethod = "rr",
#                  eqType = "is", covTested = "z2", npathsave = 50,
#                  linApprox = FALSE, seed = 1)
# result$p_value
# result$p_std_value
# print(result)
# summary(result)
# plot(result, std = FALSE)
# plot(result, std = TRUE)
#
# result = afttest(object = Surv(Time, status) ~ z1 + z2, data = simdata,
#                  npath = 100, testType = "covForm", estMethod = "ls",
#                  eqType = "ls", covTested = "z2", npathsave = 50,
#                  linApprox = FALSE, seed = 1)
# result$p_value
# result$p_std_value
# print(result)
# summary(result)
# plot(result, std = FALSE)
# plot(result, std = TRUE)

Run the code above in your browser using DataLab