Learn R Programming

survMisc (version 0.4.6)

plotTerm: Plot individual terms of a Generalized Additive gam or Cox Proportional Hazards coxph Model

Description

Plot individual terms of a Generalized Additive gam or Cox Proportional Hazards coxph Model

Usage

plotTerm(x, term = 1, se = TRUE, p = 0.95, rug = TRUE, const = 0,
  col = 1, xlab = NULL, data, ...)

Arguments

x
The result of a Generalized Additive Model (gam) or a Cox proportional hazards model (coxph)
term
The term to be plotted. An integer, based on the position of the term on the right-hand side of the model formula e.g. the first term is 1.
se
If se=TRUE (the default), also plot confidence intervals based on the standard errors
p
P-value used to plot the confidence intervals from standard errors. Based on the normal distribution
rug
Add rug (1-dimensional plot) to x-axis. See ?graphics::rug
const
Value for constant term. If const=TRUE, add the overall mean for the decomposition as returned by gamTerms
col
Color of line(s) on plot. If se=TRUE, use a vector of 3 colors: the first is the main line, the second is lower the CI, the third is the upper CI.
data
A data.frame in which to evaluate the model. If missing, eval(x$call$data) is used.
xlab
Label for x-axis.
...
Additional arguments; passed to graphics::matplot (with standard errors) or graphics::plot (without).

Value

  • A plot (base graphics) of the term in question. If se=TRUE, this is done using graphics::matplot otherwise graphics::plot.default is used.

See Also

gamTerms, mpip

Examples

Run this code
fit1 <- coxph(Surv(time, status) ~ sex + pspline(age), data=lung)
plotTerm(fit1, term=2, rug=FALSE, ylab="Log-hazard",
         col=c("blue", "red", "red"))
### smoothing splines
data(mpip)
c1 <- coxph(Surv(futime, status) ~
            pspline(lved) + factor(nyha) + rales + pspline(ef),
            data=mpip)
plotTerm(c1, 4, ylab="Log-hazard", xlab="Ejection fraction (%)",
         main="Log-hazard by ejection fraction \n Line fitted by penalized smoothing splines")

Run the code above in your browser using DataLab