[f2e496]: / R / eventPrediction_package.R

Download this file

99 lines (88 with data), 3.8 kB

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
##' Expected Progress of a Survival Study
##'
##' Calculate the required number of events for a two-arm survival
##' study, and the expected accumulation of events assuming exponential
##' or Weibull survival. Non-uniform accrual may be specified. It is also
##' possible to use real data for predicting the total number of events at a
##' future time point.
##'
##' @name eventPrediction-package
##' @aliases eventPrediction
##' @docType package
##' @title Expected Progress of a Survival Study Assuming Exponential/Weibull Survival
##' @author \email{daniel.dalevi@@astrazeneca.com}
NULL
##' Simulated data that was originally obtained by the exportData function available
##' in the package. The randomization dates have not been modelled properly and is only
##' evenly distributed in the study period.
##'
##' @name event.data
##' @docType data
##' @format A data.frame containing a row per patient with six columns:
##' subject patient identifier
##' has.event Logical indicating whether patient has had an event or not
##' event.date Date of event
##' last.date The date of the last visit
##' rand.date Date when patient was randomized.
##' eventType For subjects with an event, the type of event which occurred
NULL
##' The S4 show methods for EventPrediction package
##' @name show
##' @rdname show-methods
##' @param object The object to be shown
NULL
##' The S4 summary methods for EventPrediction package
##' @name summary
##' @rdname summary-methods
##' @param object The object for which a summary is desired
NULL
##' The predict methods for EventPrediction package
##'
##' @name predict
##' @docType methods
##' @rdname predict-methods
##' @param object The object for which the prediction is required
##' @param ... Additional objects
##' @param time.pred If \code{object} is a \code{FromDataResults} object then:
##' The Dates for which the number of events
##' are required at. This should be a vector of character strings,
##' e.g. c("2017-10-10","2018-04-27) or NULL.
##' If it is a \code{Study} object then this is a numeric vector of
##' dates (in months from the start of the trial) for which the number
##' of events are required at.
##' @param event.pred The target number of events for which the expect time
##' is to be predicted, should be a numeric vector
##' @return The predicted values. If \code{object} is \code{Study} the result will
##' be an \code{AnalysisResults} object.
##' If \code{object} is a \code{FromDataResults} object it will be
##' returned with \code{event.pred.data} and/or \code{time.pred.data} slots updated
##' @seealso \code{\link{FromDataResults-class}} \code{\link{AnalysisResults-class}}
##' @export
if(!isGeneric("predict")){
setGeneric("predict", function(object, ...) standardGeneric("predict"))
}
##' @importFrom graphics plot
NULL
##' The plot methods for EventPrediction package
##'
##' For \code{x} an \code{EventData} object, this method will plot
##' a cloglog survival curve of the data. If \code{x} is an \code{EventModel}
##' object, this method will plot a KM curve of the data overlaid with the
##' survival function from the model fit.
##'
##' @name plot
##' @docType methods
##' @rdname plot-methods
##' @param x Standard arguments to plot generic
##' @param y Standard arguments to plot generic
##' @param ... Additional arguments for the plot function
##' @param show.title Logical, if TRUE, will show title in plot.
##' @param xlab X axis label.
##' @param ylab Y axis label.
##' @param main Plot title
##' @param xlim X axis limits. If \code{x} is \code{FromDataResults} object then
##' c(2,10) will display from 2 to 10 months after the first
##' subject was recruited. Using c(0,-1) will show the entire graph
##' @param ylim The y-axis range for the plot
##' @export
setGeneric("plot", function(x, y, ...) standardGeneric("plot"))