View source: R/plot.CopulaCenR.R
| plot.CopulaCenR | R Documentation |
Plotting for CopulaCenR fits from ic_spTran_copula, rc_spCox_copula,
ic_par_copula and rc_par_copula.
## S3 method for class 'CopulaCenR'
plot(
x,
y,
class = "joint",
newdata,
evalPoints = 50,
evalTimes1 = NULL,
evalTimes2 = NULL,
plot_margin = 1,
cond_time = NULL,
cond_margin = 2,
type = "l",
xlab = "years",
ylab = "survival probability",
cex.main = 1.4,
cex.lab = 1.4,
cex.axis = 1.4,
legend = TRUE,
...
)
x |
an object of |
y |
new data frame with colname names |
class |
one of "joint", "conditional" or "marginal" |
newdata |
new data frame (ignored if |
evalPoints |
number of time points to be evaluated in both margins; default is 50 |
evalTimes1 |
a vector of times for margin 1 to be evaluated; default is NULL; will override evalPoints if non-NULL |
evalTimes2 |
a vector of times for margin 2 to be evaluated |
plot_margin |
for |
cond_time |
for |
cond_margin |
for |
type |
type of plot with default |
xlab |
a title for the x axis. |
ylab |
a title for the x axis. |
cex.main |
cex for main. |
cex.lab |
cex for lab. |
cex.axis |
cex for axis. |
legend |
whether to show legend with default |
... |
further arguments |
y must be a data frame with columns id (subject id),
ind (1,2 for two margins) and covariates.
The argument class determines the plot:
"joint" for joint survival probabilities,
"conditional" for conditional probabilities and
"marginal" for marginal probabilities.
The function evaluates on a series of time points
(given by evalPoints or evalTimes;
evalTimes will override evalPoints).
By default, the time points are automatically
selected by specifying the number of points (evalPoints = 50).
Users can also provide the specific time points through evalTimes1 and
evalTimes2 for the two margins, respectively.
When class = "conditional", only evalTimes1 is needed
and the evaluation times are actually evalTimes1 plus cond_time.
If class = "conditional", one needs to specify the margin
that has the event (by cond_margin)
and time when the event has occurred (by cond_time).
For example, if cond_margin = 2 and cond_time = 5,
then the function produces the conditional survival probability
(after time 5) in margin 1 given that margin 2 has got an event by time 5.
This measurement is useful for predicting the second event
given the first event has occurred. See the example for details.
If class = "marginal", one needs to specify which margin to plot
through the argument plot_margin. See the example for details.
a 3D joint survival distribution plot if class = "joint";
a 2D survival distribution plot if class = "marginal" or "conditional".
data(AREDS)
# fit a Copula2-Sieve model
copula2_sp <- ic_spTran_copula(data = AREDS, copula = "Copula2",
l = 0, u = 15, m = 3, r = 3,
var_list = c("ENROLLAGE","rs2284665","SevScaleBL"))
newdata = data.frame(id = rep(1, each=2), ind = rep(c(1,2),1),
SevScaleBL = rep(3,2), ENROLLAGE = rep(60,2),
rs2284665 = c(0,0))
# Plot joint survival probabilities
plot(x = copula2_sp, class = "joint", newdata = newdata)
# Plot conditional survival probabilities
plot(x = copula2_sp, class = "conditional", newdata = newdata,
cond_margin = 2, cond_time = 5, ylim = c(0.25,1),
ylab = "Conditional Survival Probability")
# Plot marginal survival probabilities
plot(x = copula2_sp, class = "marginal", newdata = newdata,
plot_margin = 1, ylim = c(0.6,1),
ylab = "Marginal Survival Probability")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.