plot.IMR: Plot IMR Analysis

Description Usage Arguments Details See Also Examples

View source: R/IMR-main.R

Description

A plotting method for IMR objects.

Usage

1
2
## S3 method for class 'IMR'
plot(x, y = NULL, which = seq_along(x$results), ncol = 2, ...)

Arguments

x

An IMR object.

y

NULL. Not used at the moment.

which

Which of the analyzed models to display.

ncol

Number of columns is plotting grid.

...

additional arguments to be passed to lower level functions.

Details

Multiple plots (selectable by which) are created. The type of plot depend on method of the inputted IMR object. At the moment the following plotting methods are avaible:

The BS method plotted: The normalized cumulative coefficients are plotted along with the fitted basis spline.

The rss method plotted: The normalized cumulative coefficients are plotted along with the invariant model and residuals.

See Also

See IMR for the construction of an IMR object.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
## Generate Data
n <- 1000
E <- sample(4L, n, replace = TRUE)
X <- data.frame(X1 = rnorm(n, 2 * E, 1),
                X2 = rnorm(n, 2 * (E == 1) + 5 * (E == 4), 1),
                X3 = rbinom(n, 1, 0.5))
Y <- rexp(n, exp(4 - 0.6 * X$X1 + 0.4 * X$X2))
C <- rexp(n, exp(0.5))
time <- pmin(Y, C)
status <- time == Y
# Note that X1 and X2 are true causal predictors

## Fit Models
m1 <- survival::coxph(survival::Surv(time, status) ~ X1, data = X)
m2 <- survival::coxph(survival::Surv(time, status) ~ X2, data = X)
m3 <- survival::coxph(survival::Surv(time, status) ~ X3, data = X)
m12 <- survival::coxph(survival::Surv(time, status) ~ X1 + X2, data = X)
m13 <- survival::coxph(survival::Surv(time, status) ~ X1 + X3, data = X)

## Ranking via Basis Splines
BS <- IMR(list(m1, m2, m3, m12, m13), method = "BS")
plot(BS, ncol = 3)
plot(BS, which = c(1,2,3), ncol = 3) # the 1 variable models

## Ranking via Residual Square Error
RSS <- IMR(list(m1, m2, m3, m12, m13), method = "rss")
plot(RSS, ncol = 3)

Laksafoss/ICPSurv documentation built on Feb. 26, 2020, 11:32 a.m.