plot.bayesCureModel {bayesCureRateModel} | R Documentation |
Plot method
Description
Plots and computes HDIs.
Usage
## S3 method for class 'bayesCureModel'
plot(x, burn = NULL, alpha = 0.05, gamma_mix = TRUE,
K_gamma = 5, plot_graphs = TRUE, bw = "nrd0", what = NULL, p_cured_output = NULL,
index_of_main_mode = NULL, draw_legend = TRUE,...)
Arguments
x |
An object of class |
burn |
Number of iterations to discard as burn-in period. |
alpha |
A value between 0 and 1 in order to compute the 1- |
gamma_mix |
Boolean. If TRUE, the density of the marginal posterior distribution of the |
K_gamma |
Used only when |
plot_graphs |
Boolean, if FALSE only HDIs are computed. |
bw |
bandwidth |
what |
Integer or a character string with possible values equal to |
p_cured_output |
Optional argument (list) which is required only when |
index_of_main_mode |
If NULL (default), all modes are plotted. Otherwise, it is a subset of the retained MCMC iterations in order to identify the main mode of the posterior distribution, as returned by the |
draw_legend |
Boolean. If TRUE (default), a legend is plotted in the case where |
... |
arguments passed by other methods. |
Value
The function plots graphic output on the plot device if plot_graphs = TRUE
. Furthermore, a list of 100(1-\alpha)\%
Highest Density Intervals per parameter is returned.
Author(s)
Panagiotis Papastamoulis
Examples
# simulate toy data just for cran-check purposes
set.seed(1)
n = 4
stat = rbinom(n, size = 1, prob = 0.5)
# simulate design matrix
# first column consists of 1s (const)
# and second and third column contain
# the values of two covariates
x <- cbind(1, matrix(rnorm(2*n), n, 2))
colnames(x) <- c('const', 'x1', 'x2')
y <- rexp(n)
fit1 <- cure_rate_MC3(y = y, X = x, Censoring_status = stat,
promotion_time = list(distribution = 'exponential'),
nChains = 2, nCores = 1,
mcmc_cycles = 3, sweep = 2)
# plot the marginal posterior distribution of the first parameter in returned mcmc output
plot(fit1, what = 1, burn = 0)
# using 'cured_prob'
#compute cured probability for two individuals with
# x1 = 0.2 and x2 = -1
# and
# x1 = -1 and x2 = 0
covariate_levels1 <- rbind(c(1,0.2,-1), c(1,-1,0))
summary1 <- summary(fit1, covariate_levels = covariate_levels1, burn = 0)
plot(fit1, what='cured_prob', p_cured_output = summary1$p_cured_output,
ylim = c(0,1))