plot_post_frailty_est {TimeDepFrail}R Documentation

Plot the Posterior Frailty Estimates

Description

This function plots the posterior frailty estimates for each group in each time interval. Each group’s estimates are represented by a sequence of points connected by straight lines. The function can plot either the entire posterior frailty estimate or its time-independent and time-dependent components based on user-specified flags.

Usage

plot_post_frailty_est(
  result,
  data,
  flag_eps = FALSE,
  flag_alpha = FALSE,
  xlim = c(0, length(result$TimeDomain) - 1),
  ylim = c(0, 10),
  xlab = "Intervals",
  ylab = "Values",
  main_title = "Posterior frailty estimates",
  cex = 0.7,
  pch_type = rep(21, length(centre_codes)),
  color_bg = rep("black", length(centre_codes)),
  cex_legend = 0.7,
  pos_legend = "topright"
)

Arguments

result

S3 object of class 'AdPaik', returned by the method call 'AdPaikModel(...)'.

data

Dataset (dataframe) in which all variables of the formula object must be found and contained.

flag_eps

Logical flag indicating whether to plot only the time-dependent posterior frailty estimates. Default is FALSE.

flag_alpha

Logical flag indicating whether to plot only the time-independent posterior frailty estimates. Default is FALSE.

xlim

Numeric vector of length 2 specifying the x-axis limits. Default is based on the number of intervals.

ylim

Numeric vector of length 2 specifying the y-axis limits. Default is (0, 10).

xlab, ylab

String giving the x and y axis name. Default values are 'Intervals' and 'Values'.

main_title

Title of the plot. Default title is 'Posterior frailty estimates'.

cex

Dimension of the points used for plotting the estimates.

pch_type

Numerical vector of length equal to the number of clusters in the data, giving the symbol to be used for plotting the estimates. Default symbol (circle, 21) is the same for all clusters.

color_bg

Numerical vector of length equal to the number of clusters in the data, giving the color to be used for plotting the symbols for the estimates. Default ('black') is the same for all faculties. On the other hand, the same color is used throughout the intervals for the same faculty.

cex_legend

Dimension of the symbol in the legend. Default is 0.7.

pos_legend

Either a numeric vector providing the x and y coordinates for the legend or a string specifying the legend's position (e.g., 'bottomright', 'bottom', 'bottomleft', 'left', 'topleft', 'top', 'topright', 'right', 'center').

Details

Recalling the frailty structure as Z_{jk} = \alpha_{j} + \epsilon_{jk}, \forall j,k and the posterior frailty estimate as \hat{Z}_{jk} = \hat{\alpha}_{j}/\hat{\alpha}_{max} + \hat{\epsilon}_{jk}/\hat{\epsilon}_{max}, this function allows plotting either the entire posterior frailty estimate \hat{Z}_{jk} or its time-independent \frac{\hat{\alpha}_{j}}{\hat{\alpha}_{\text{max}}} or time-dependent \frac{\hat{\epsilon}_{jk}}{\hat{\epsilon}_{\text{max}}} components. The user can control which components to display using the flag_eps and flag_alpha parameters. Only one of these flags can be set to TRUE at a time.

Value

The plot of the posterior frailty estimates.

Examples

# Import data
data(data_dropout)

# Define the variables needed for the model execution
eps_paik <- 1e-10
categories_range_min <- c(-8, -2, eps_paik, eps_paik, eps_paik)
categories_range_max <- c(-eps_paik, 0.4, 1 - eps_paik, 1, 10)
time_axis <- c(1.0, 1.4, 1.8, 2.3, 3.1, 3.8, 4.3, 5.0, 5.5, 5.8, 6.0)
formula <- time_to_event ~ Gender + CFUP + cluster(group)

# Call the main model function


result <- AdPaikModel(formula, data_dropout, time_axis, categories_range_min, categories_range_max)

# Define variables for plotting the estimates
pch_type <- c(21, seq(21,25,1), seq(21,25,1), seq(21,25,1))
color_bg <- c("darkblue", rep("red", 5), rep("purple", 5), rep("green",5))

plot_post_frailty_est(result, data_dropout,
                      xlim = c(1, 11), ylim = c(0,3), 
                      pch_type = pch_type, color_bg = color_bg,
                      xlab = 'Time [intervals]', ylab = 'Posterior estimates',
                      pos_legend = 'bottomright')
                      

[Package TimeDepFrail version 0.0.0.9 Index]