kmplotmlx: Kaplan Meier plot

Description Usage Arguments Details Value Examples

View source: R/kmplotmlx.R

Description

Plot empirical survival functions using the Kaplan Meier estimate.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
kmplotmlx(
  r,
  index = 1,
  level = NULL,
  time = NULL,
  cens = TRUE,
  plot = TRUE,
  color = "#e05969",
  group = NULL,
  facet = TRUE,
  labels = NULL
)

Arguments

r

a data frame with a column id, a column time, a column with values and possibly a column group.

index

an integer: index=k means that the survival function for the k-th event is displayed. Default is index=1.

level

a number between 0 and 1: confidence interval level.

time

a vector of time points where the survival function is evaluated.

cens

if TRUE right censoring times are diplayed.

plot

if TRUE the estimated survival function is displayed, if FALSE the values are returned

color

color to be used for the plots (default="#e05969")

group

variable to be used for defining groups (by default, group is used when it exists)

facet

makes subplots for different groups if TRUE

labels

vector of strings

Details

See http://simulx.webpopix.org/mlxr/kmplotmlx/ for more details.

Value

a ggplot object if plot=TRUE ; otherwise, a list with fields:

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
## Not run: 
tteModel1 <- inlineModel("
  [LONGITUDINAL]
  input = {beta,lambda}  
  EQUATION:
  h=(beta/lambda)*(t/lambda)^(beta-1)
  DEFINITION:
  e = {type=event, maxEventNumber=1, rightCensoringTime=70, hazard=h}
  ")

  p1   <- c(beta=2.5,lambda=50)
  e    <- list(name='e', time=0)
  res1 <- simulx(model=tteModel1, parameter=p1, output=e, group=list(size=100))
  pl1  <- kmplotmlx(res1$e,level=0.95)
  print(pl1)

  p2   <- c(beta=2,lambda=45)
  g1   <- list(size=50, parameter=p1)
  g2   <- list(size=100, parameter=p2)
  res2 <- simulx(model=tteModel1, output=e, group=list(g1,g2))
  pl2  <- kmplotmlx(res2$e)
  print(pl2)

## End(Not run)

mlxR documentation built on Jan. 19, 2021, 5:06 p.m.