plot.expertsurv: Plot survival curves for the models fitted using 'fit.models'

View source: R/plot.expertsurv.R

plot.expertsurvR Documentation

Plot survival curves for the models fitted using fit.models

Description

Plots the results of model fit.

Usage

## S3 method for class 'expertsurv'
plot(...)

Arguments

...

Must include at least one result object saved as the call to the fit.models function. Nay include other optional parameters. These include whether the KM curve should be added add.km and whether the user specifies a profile of covariates (in the list newdata). Other possibilities are additional (mainly graphical) options. These are: xlab = a string with the label for the x-axis (default = "time") ylab = a string with the label for the y-axis (default = "Survival") lab.profile = a (vector of) string(s) indicating the labels associated with the strata defining the different survival curves to plot. Default to the value used by the Kaplan Meier estimate given in fit.models. newdata = a list (of lists) providing the values for the relevant covariates If NULL, then will use the mean values for the covariates if at least one is a continuous variable, or the combination of the categorical covariates. xlim = a vector determining the limits for the x-axis colors = a vector of characters defining the colours in which to plot the different survival curves lab.profile = a vector of characters defining the names of the models fitted add.km = TRUE (whether to also add the Kaplan Meier estimates of the data) annotate = FALSE (whether to also add text to highlight the observed vs extrapolated data) legend.position = a vector of proportions to place the legend. Default to 'c(.75,.9)', which means 75% across the x-axis and 90% across the y-axis legend.title = suitable instructions to format the title of the legend; defaults to 'element_text(size=15,face="bold")' but there may be other arguments that can be added (using 'ggplot' facilities) legend.text = suitable instructions to format the text of the legend; defaults to 'element_text(colour="black", size=14, face="plain")' but there may be other arguments that can be added (using 'ggplot' facilities)

Value

A ggplot2 object of the survival curves.

Author(s)

Gianluca Baio

References

\insertRef

Baio.2020expertsurv

See Also

fit.models, write.surv

Examples

require("dplyr")
param_expert_example1 <- list()
param_expert_example1[[1]] <- data.frame(dist = c("norm","t"),
                                         wi = c(0.5,0.5), # Ensure Weights sum to 1
                                         param1 = c(0.1,0.12),
                                         param2 = c(0.15,0.5),
                                         param3 = c(NA,3))

timepoint_expert <- 14
data2 <- data %>% rename(status = censored) %>% mutate(time2 = ifelse(time > 10, 10, time),
                                                       status2 = ifelse(time> 10, 0, status))
example1_mle <- fit.models.expert(formula=Surv(time2,status2)~1,data=data2,
                                  distr=c("wph", "exp"),
                                  method="mle",
                                  pool_type = "log pool",
                                 opinion_type = "survival",
                                  times_expert = timepoint_expert,
                                  param_expert = param_expert_example1)

#Warning! 50 iterations is far too few, however, it has been done so that the 
#example can be run for CRAN
example1_bayes <- fit.models.expert(formula=Surv(time2,status2)~1,data=data2,
                                    distr=c("wph", "exp"),
                                    method="hmc",
                                    iter = 50,
                                    pool_type = "log pool",
                                    opinion_type = "survival",
                                    times_expert = timepoint_expert,
                                    param_expert = param_expert_example1)

plot(MLE=example1_mle,Bayesian=example1_bayes, add.km = TRUE, t = 0:30)


expertsurv documentation built on Oct. 5, 2023, 5:09 p.m.