Learn R Programming

paf (version 1.0)

plot.paf: Plot method for paf objects

Description

Plot the attributable fraction function obtained by the paf function.

Usage

"plot"(x, conf.int = TRUE, lty = 1, col = 1, ylim = NULL, xlab = "Time", ylab = "Attributable Fraction Function", ...)

Arguments

x
an object of class paf which is retured by the paf function.
conf.int
determines whether confidence intervals will be plotted. The default is TRUE.
lty
an integer specifying line type.
col
an integer specifying color type.
ylim
a vector specifying the lower and upper boundaries for y values.
xlab
label given to the x-axis with "Time" as default.
ylab
label given to the y-axis with "Attributable Fraction Function" as default.
...
other arguments allowed for the general plot function.

References

Chen L, Lin DY, Zeng D. (2010). Attributable fraction functions for censored event times. Biometrika 97, 713-726.

See Also

par, paf.

Examples

Run this code
# simulated data set from a Cox model
n = 1000
x1 = as.numeric(runif(n)>0.5)
x2 = x1 + rnorm(n)
t = exp(-x1 - 0.5 * x2) * rexp(n, rate = 0.1)
c = runif(n, 0, 3.4)
y = pmin(t, c)
delta = as.numeric(t<=c)
test = data.frame(time=y, status=delta, x1=x1, x2=x2)

# calculate the atrributable fraction function of x1 adjusting for x2
result=paf(Surv(time, status) ~ x1 + x2, data=test, cov=c('x1'))
# plot the attributable fraction function
plot(result)

Run the code above in your browser using DataLab