drawSurv: Draw Kaplan-Meier Survival Plot with an object of class 'gam'

Description Usage Arguments Value Examples

View source: R/drawSurv.R

Description

Draw Kaplan-Meier Survival Plot with an object of class 'gam'

Usage

1
drawSurv(model, data, np = 100, timevar = "time", until = NULL, id = list())

Arguments

model

a fitted gam object as produced by gam()

data

A data frame or list containing the values of the model covariates at which predictions are required

np

Numeric Number of time intervals

timevar

character Name of variable containing time

until

Maximum value of time

id

Optional labels of preset values

Value

A ggplot

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
require(mgcv)
data(pbc,package="survival")
pbc$status1 <- as.numeric(pbc$status==2)
pbc$stage <- factor(pbc$stage)
model = gam(time ~ trt +sex + s(sqrt(protime))+s(platelet)+ s(age)+s(bili)+s(albumin),
   weights=status1, family=cox.ph, data=pbc, method="REML")
dfSex=averageData(pbc,list(sex=c("m","f")))
drawSurv(model,data=dfSex,id=list(sex=c("m","f")))
dfBili=averageData(pbc,list(bili=c(1,10)))
drawSurv(model,data=dfBili,id=list(bili=c(1,10)))

cardiomoon/ggGam documentation built on May 2, 2020, 9:58 a.m.