View source: R/event_prediction.R
fit_tte_data | R Documentation |
This is a function to fit Weibull and log-normal curves to patient-level Survival data using maximum likelihood estimation.
By default it fits both, then picks the best fit based on the log-likelihood (and implicitly the AIC).
Alternatively, just one shape may be fitted, by changing the 'type' argument to either "Weibull" or "Lognormal".
This function is primarily used by event_prediction_data function, but also useful for general Survival function curve fitting.
One useful aspect of this is for fitting the 'inverse KM', where drop-outs are events, while events and 'time-outs' are censored.
This allows for finding a suitable parameterisation for the censoring curve.
Where patient-level data is available, this function will typically perform substantially better than fit_KM, with lower variability of point estimates (and more accurate quantification of it).
fit_tte_data(
data,
Time = "Time",
Event = "Event",
censoringOne = FALSE,
type = c("automatic", "Weibull", "Lognormal", "Exponential"),
init = NULL
)
data |
The dataframe object containing the patient-level survival data |
Time |
The column name for the times. Default is "Time" |
Event |
The column name for the events column (i.e. the binary variable denoting events vs censorings). Default is "Event" |
censoringOne |
Specify whether censoring is denoted in the Event column by a one (TRUE) or zero (FALSE). Default=FALSE (censorings denoted by 0, events by 1) |
type |
Type of event curve to fit. Default is "Automatic", fitting both Weibull and Log-normal curves. Alternatively accepts "Weibull" or "Lognormal" to force the type. |
init |
Vector of starting values for parameter values; useful if survreg experiences convergence issues. Default=NULL (no values specified) |
Returns a 3-item list providing information needed to define a Curve object:
"Item 1"The type of Curve object fitted.
"Item 2"A list of fitted parameters for the curve type.
"Item 3"A vector containing the covariance-matrix parameters for the curve type.
"Item 4"A data frame containing the goodness of fit metrics for each curve type.
James Bell
recruit <- PieceR(matrix(c(rep(1,12),10,15,25,30,45,60,55,50,65,60,55,30),ncol=2),1)
example_data <- simulate_trials(active_ecurve=Weibull(50,0.8),control_ecurve=Weibull(50,0.8),
rcurve=recruit, assess=10,iterations=1,seed=12345,detailed_output=TRUE)
fit_tte_data(data=example_data,Time="Time",Event="Censored",censoringOne=TRUE,type="automatic")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.