plot_ep: Plot event prediction output

Description Usage Arguments Value Author(s) Examples

View source: R/plotting.R

Description

This function plots the output from event_prediction().
By default, produces a plot of predicted events over time, with confidence intervals if available.
Alternatively, produces a plot with the fitting CI over time with same percentage as prediction interval.
By default, both conditional and unconditional trajectories are plotted (if conditional event prediction is available).
Options are available to customise inclusion.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
plot_ep(
  data,
  trajectory = c("both", "conditional", "unconditional"),
  which_PI = c("both", "conditional", "unconditional", "none"),
  prediction_fitting = c("prediction", "fitting"),
  observed = NULL,
  target = NULL,
  max_time = NULL,
  max_E = NULL,
  legend_position = c("top_left", "bottom_right"),
  no_legend = FALSE,
  ...
)

Arguments

data

Full output list from event_prediction().

trajectory

String, choice of "both","conditional","unconditional", for which trajectory to plot. (Default="both")

which_PI

String, choice of "both","conditional","unconditional","none", for which PIs to plot. (Default="both")

prediction_fitting

String, choice of "prediction" or "fitting" (Default = "prediction"). Determines the nature of the intervals; PIs are relevant for prediction of the observation of future trajectories (sample level), whereas fitting CIs concern the interval for the mean trajectory itself (population level).

observed

Optional trajectory of observed event numbers. If vector specified, will plot values at integer times starting from 1. If 2-column matrix specified, will take x-values from column 1 and y-values from column 2. (Default=NULL; not plotted).

target

Optional target number of events to plot. (Default=NULL; not plotted)

max_time

Optional maximum time to plot up to if you do not want to plot full trajectory. (Default=NULL; maximum time determined by input data)

max_E

Optional maximum number of events to plot up to. (Default=NULL; maximum event number is the number of patients)

legend_position

String with any of "top_left", or "bottom_right", corresponding to legend position in power plot. (Default="top_left").

no_legend

Boolean to turn off legend. Default is FALSE; legend shown.

...

Additional graphical parameters.

Value

Returns NULL

Author(s)

James Bell

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
recruit <- PieceR(matrix(c(rep(1,12),10,15,25,30,45,60,55,50,65,60,55,30),ncol=2),1)
trial_long <- simulate_trials(active_ecurve=Weibull(50,0.8),control_ecurve=Weibull(50,0.8),
rcurve=recruit,fix_events=200, iterations=1,seed=12345,detailed_output=TRUE)
trial_short <- set_assess_time(data=trial_long,time=10,detailed_output = FALSE)

maxtime <- max(ceiling(trial_long[,"Assess"]))
events <- rep(NA,maxtime)
for (i in 1:maxtime){events[i] <- sum(1-set_assess_time(trial_long,i)[,"Censored"])}

predictions <- event_prediction(data=trial_short, Event="Censored", censoringOne=TRUE, 
type="Weibull", rcurve=recruit, max_time=60, cond_Events=49, cond_NatRisk=451, 
cond_Time=10, units="Months")

plot_ep(predictions,trajectory="conditional",which_PI="conditional",max_time=40,observed=events,
target=200,max_E=200)

plot_ep(predictions,trajectory="unconditional",which_PI="unconditional",max_time=40,
observed=events,target=200,max_E=200)

plot_ep(predictions,trajectory="conditional",which_PI="none",observed=events[1:10],max_time=20,
max_E=150)

gestate documentation built on Feb. 20, 2020, 5:08 p.m.