Title: | Parametric Time to Event Analysis |
---|---|
Description: | Performs maximum likelihood based estimation and inference on time to event data, possibly subject to non-informative right censoring. FitParaSurv() provides maximum likelihood estimates of model parameters and distributional characteristics, including the mean, median, variance, and restricted mean. CompParaSurv() compares the mean, median, and restricted mean survival experiences of two treatment groups. Candidate distributions include the exponential, gamma, generalized gamma, log-normal, and Weibull. |
Authors: | Zachary McCaw [aut, cre] |
Maintainer: | Zachary McCaw <[email protected]> |
License: | GPL-3 |
Version: | 0.3.0.1 |
Built: | 2024-11-16 03:19:00 UTC |
Source: | https://github.com/zrmacc/temporal |
Check whether treatment arm is properly formatted.
CheckArm(arm)
CheckArm(arm)
arm |
0/1, treatment arm. |
None.
Check whether the distribution selected is available.
CheckDist(dist)
CheckDist(dist)
dist |
String, distribution name. |
None.
Check whether the initialization is valid.
CheckInit(dist, init)
CheckInit(dist, init)
dist |
String, distribution name. |
init |
List of named parameters. |
None.
Function to ensure the status indicator is properly formatted
CheckStatus(status)
CheckStatus(status)
status |
0/1 status indicator. |
None.
Function to check the appropriate number of parameters are supplied for the
selected distribution. Used by GenData
.
CheckTheta(dist, theta)
CheckTheta(dist, theta)
dist |
String, distribution. |
theta |
Numeric, parameter vector. |
None.
Compares the means and medians of parametric survival distributions fit to two treatment arms. Available distributions include: exponential, gamma, generalized gamma, log-normal, and Weibull.
CompParaSurv( data, arm_name = "arm", dist1 = "weibull", dist0 = NULL, eps = 1e-06, init1 = NULL, init0 = NULL, maxit = 10, report = FALSE, reps = NULL, sig = 0.05, status_name = "status", tau = NULL, time_name = "time" )
CompParaSurv( data, arm_name = "arm", dist1 = "weibull", dist0 = NULL, eps = 1e-06, init1 = NULL, init0 = NULL, maxit = 10, report = FALSE, reps = NULL, sig = 0.05, status_name = "status", tau = NULL, time_name = "time" )
data |
Data.frame. |
arm_name |
Name of the column containing the treatment group, coded as 1 for treatment, 0 for reference. |
dist1 |
Distribution to fit for the target group. Selected from among: exp, gamma, gengamma, log-normal, and weibull. |
dist0 |
Distribution to fit for the reference group. Same choices as for the target group. If omitted, defaults to the distribution specified for the target group. |
eps |
Tolerance for Newton-Raphson iterations. |
init1 |
Initial parameter values for the target group. |
init0 |
Initial parameter values for the reference group. |
maxit |
Maximum number of Newton-Raphson iterations. |
report |
Report fitting progress? |
reps |
Number of permutation replicates, if requesting permutation p-values. |
sig |
Significance level, for constructing confidence intervals. |
status_name |
Name of the status indicator, 1 if observed, 0 if censored. |
tau |
Optional truncation times for calculating RMST. |
time_name |
Name of column containing the time to event. |
Status should be coded as 0 for censored and 1 for observed. Arm is coded as 0 for reference, 1 for target. Tau is an optional numeric vector of truncation times for calculating restricted mean survival time, which is the area under the survival curve up to the specified truncation point.
An object of class contrast
containing the following:
The fitted model for the target group.
The fitted model for the reference group.
Contrasts of means and medians.
Contrasts of the RMSTs, if 'tau' was specified.
set.seed(100) # Weibull and Weibull, different means and medians. n <- 1e3 # Generate data. df1 <- GenData(n = n, dist = "weibull", theta = c(1, 1), p = 0.2) df1$arm <- 1 df0 <- GenData(n = n, dist = "weibull", theta = c(1, 2), p = 0.2) df0$arm <- 0 data <- rbind(df1, df0) # Comparison. comp <- CompParaSurv(data, dist1 = "weibull") # Add RMST at time 1. comp <- CompParaSurv(data, dist1 = "weibull", tau = 1) # Calculate permutation p-values (slow). comp <- CompParaSurv(data, dist1 = "weibull", tau = 1, reps = 100)
set.seed(100) # Weibull and Weibull, different means and medians. n <- 1e3 # Generate data. df1 <- GenData(n = n, dist = "weibull", theta = c(1, 1), p = 0.2) df1$arm <- 1 df0 <- GenData(n = n, dist = "weibull", theta = c(1, 2), p = 0.2) df0$arm <- 0 data <- rbind(df1, df0) # Comparison. comp <- CompParaSurv(data, dist1 = "weibull") # Add RMST at time 1. comp <- CompParaSurv(data, dist1 = "weibull", tau = 1) # Calculate permutation p-values (slow). comp <- CompParaSurv(data, dist1 = "weibull", tau = 1, reps = 100)
Defines the object class returned by the comparison function.
Dist1
Distribution fit to the target group, string.
Dist0
Distribution fit to the reference group, string.
Model1
Fitted model for the target group, fit.
Model0
Fitted model for the reference group, fit.
Location
Contrasts of means and medians, data.frame.
RMST
Contrasts of RMSTs, data.frame.
Compare the means and medians of the fitted distributions for two treatment arms.
ContrastLocs(fit1, fit0, sig = 0.05)
ContrastLocs(fit1, fit0, sig = 0.05)
fit1 |
Fitted parametric survival distribution for arm 1. |
fit0 |
Fitted parametric survival distribution for arm 0. |
sig |
Significance level. |
Data.frame contrasting the difference and ratio of the mean and median at each time point.
Compare the restricted mean survival times of the fitted distributions for two treatment arms.
ContrastRMSTs(fit1, fit0, sig = 0.05)
ContrastRMSTs(fit1, fit0, sig = 0.05)
fit1 |
Fitted parametric survival distribution for arm 1. |
fit0 |
Fitted parametric survival distribution for arm 0. |
sig |
Significance level, for |
Data.frame contrasting the difference and ratio of RMSTs at each time point.
Function to select default parameter values for each distribution.
DefaultParam(dist)
DefaultParam(dist)
dist |
String, distribution name. |
Numeric parameter ist.
Distributions
DistProperName(dist)
DistProperName(dist)
dist |
Argument passed to FitParaSurv |
String.
Calculate CIs and p-value for the difference of estimates.
EstDiff(est1, se1, est0, se0, sig = 0.05)
EstDiff(est1, se1, est0, se0, sig = 0.05)
est1 |
Arm 1 estimate. |
se1 |
Arm 1 standard error. |
est0 |
Arm 0 estimate. |
se0 |
Arm 0 standard error. |
sig |
Significance level. |
Data.frame containing estimated difference, its standard error, lower and upper confidence bounds, and a p-value assessing the null hypothesis of no difference.
Calculate CIs and p-value for the ratio of estimates.
EstRatio(est1, se1, est0, se0, sig = 0.05)
EstRatio(est1, se1, est0, se0, sig = 0.05)
est1 |
Arm 1 estimate. |
se1 |
Arm 1 standard error. |
est0 |
Arm 0 estimate. |
se0 |
Arm 0 standard error. |
sig |
Significance level. |
Data.frame containing estimated ratio, its standard error, lower and upper confidence bounds, and a p-value assessing the null hypothesis that the ratio is unity.
Helper function for permutation inference.
ExtractObsEst(fit1, fit0)
ExtractObsEst(fit1, fit0)
fit1 |
Fitted parametric survival distribution for arm 1. |
fit0 |
Fitted parametric survival distribution for arm 0. |
Numeric vector.
Defines the object class returned by fitting functions.
Distribution
Fitted distribution, string.
Parameters
Parameters, data.frame.
Information
Information components, matrix.
Outcome
Properties of the fitted distribution, data.frame.
RMST
Estimated restricted mean survival times, data.frame
S
Fitted survival function, function.
Estimates parameters for exponential event times subject to non-informative
right censoring. The exponential distribution is parameterized in terms
of the rate :
FitExp( data, sig = 0.05, status_name = "status", tau = NULL, time_name = "time" )
FitExp( data, sig = 0.05, status_name = "status", tau = NULL, time_name = "time" )
data |
Data.frame. |
sig |
Significance level, for CIs. |
status_name |
Name of the status indicator, 1 if observed, 0 if censored. |
tau |
Optional truncation times for calculating RMSTs. |
time_name |
Name of column containing the time to event. |
An object of class fit
containing the following:
The estimated model parameters.
The observed information matrix.
The fitted mean, median, and variance of the time to event distribution.
The estimated RMSTs, if tau was specified.
# Generate exponential event time data with 20% censoring. data <- GenData(n = 1e3, dist = "exp", theta = c(2), p = 0.2) # Estimate parameters. fit <- FitParaSurv(data, dist = "exp")
# Generate exponential event time data with 20% censoring. data <- GenData(n = 1e3, dist = "exp", theta = c(2), p = 0.2) # Estimate parameters. fit <- FitParaSurv(data, dist = "exp")
Estimates parameters for gamma event times subject to non-informative
right censoring. The gamma distribution is parameterized in terms
of the shape and rate
:
FitGamma( data, eps = 1e-06, init = list(), maxit = 10, report = FALSE, sig = 0.05, status_name = "status", tau = NULL, time_name = "time" )
FitGamma( data, eps = 1e-06, init = list(), maxit = 10, report = FALSE, sig = 0.05, status_name = "status", tau = NULL, time_name = "time" )
data |
Data.frame. |
eps |
Tolerance for Newton-Raphson iterations. |
init |
List with initial values for the 'shape' |
maxit |
Maximum number of NR iterations. |
report |
Report fitting progress? |
sig |
Significance level, for CIs. |
status_name |
Name of the status indicator, 1 if observed, 0 if censored. |
tau |
Optional truncation times for calculating RMSTs. |
time_name |
Name of column containing the time to event. |
An object of class fit
containing the following:
The estimated shape and rate
.
The observed information matrix.
The fitted mean, median, and variance.
The estimated RMSTs, if tau was specified.
# Generate Gamma data with 20% censoring. data <- GenData(n = 1e3, dist = "gamma", theta = c(2, 2), p = 0.2) # Estimate parameters. fit <- FitParaSurv(data, dist = "gamma")
# Generate Gamma data with 20% censoring. data <- GenData(n = 1e3, dist = "gamma", theta = c(2, 2), p = 0.2) # Estimate parameters. fit <- FitParaSurv(data, dist = "gamma")
Paramter estimation for gamma event times without censoring.
FitGammaComplete(data, eps = 1e-06)
FitGammaComplete(data, eps = 1e-06)
data |
Data.frame. |
eps |
Tolerance for Newton-Raphson iterations. |
Numeric vector containing the estimated shape and rate parameters.
Estimates parameters for generalized gamma event times subject to non-informative
right censoring. The gamma distribution is parameterized in terms
of the shape parameters , and the rate
:
FitGenGamma( data, beta_lower = 0.1, beta_upper = 10, eps = 1e-06, init = list(), maxit = 10, report = FALSE, sig = 0.05, status_name = "status", tau = NULL, time_name = "time" )
FitGenGamma( data, beta_lower = 0.1, beta_upper = 10, eps = 1e-06, init = list(), maxit = 10, report = FALSE, sig = 0.05, status_name = "status", tau = NULL, time_name = "time" )
data |
Data.frame. |
beta_lower |
If dist="gen-gamma", lower limit on possible values for beta. |
beta_upper |
If dist="gen-gamma", upper limit on possible values for beta. |
eps |
Tolerance for Newton-Raphson iterations. |
init |
List with initial values for the shape 'alpha', 'beta' and rate 'lambda' parameters. |
maxit |
Maximum number of NR iterations. |
report |
Report fitting progress? |
sig |
Significance level, for CIs. |
status_name |
Name of the status indicator, 1 if observed, 0 if censored. |
tau |
Optional truncation times for calculating RMSTs. |
time_name |
Name of column containing the time to event. |
An object of class fit
containing the following:
The estimated shape and rate
parameters.
The observed information matrix.
The fitted mean, median, and variance.
The estimated RMSTs, if tau was specified.
set.seed(103) # Generate generalized gamma data with 20% censoring. data <- GenData(n = 1e4, dist = "gen-gamma", theta = c(2, 2, 2), p = 0.2) # Estimate parameters. fit <- FitParaSurv(data, dist = "gen-gamma", report = TRUE)
set.seed(103) # Generate generalized gamma data with 20% censoring. data <- GenData(n = 1e4, dist = "gen-gamma", theta = c(2, 2, 2), p = 0.2) # Estimate parameters. fit <- FitParaSurv(data, dist = "gen-gamma", report = TRUE)
Paramter estimation for generalized gamma event times without censoring.
FitGenGammaComplete(data, beta_lower = 0.1, beta_upper = 10)
FitGenGammaComplete(data, beta_lower = 0.1, beta_upper = 10)
data |
Data.frame. |
beta_lower |
Lower limit on possible values for beta. |
beta_upper |
Upper limit on possible values for beta. |
Numeric vector containing the estimated shape and rate parameters.
Estimates parameters for log-normal event times subject to non-informative
right censoring. The log-normal distribution is parameterized in terms
of the location and scale
:
FitLogNormal( data, eps = 1e-06, init = list(), maxit = 10, report = FALSE, sig = 0.05, status_name = "status", tau = NULL, time_name = "time" )
FitLogNormal( data, eps = 1e-06, init = list(), maxit = 10, report = FALSE, sig = 0.05, status_name = "status", tau = NULL, time_name = "time" )
data |
Data.frame. |
eps |
Tolerance for Newton-Raphson iterations. |
init |
List with initial values for the location ('loc') |
maxit |
Maximum number of NR iterations. |
report |
Report fitting progress? |
sig |
Significance level, for CIs. |
status_name |
Name of the status indicator, 1 if observed, 0 if censored. |
tau |
Optional truncation times for calculating RMSTs. |
time_name |
Name of column containing the time to event. |
An object of class fit
containing the following:
The estimated location and scale
.
The observed information matrix.
The fitted mean, median, and variance.
The estimated RMSTs, if tau was specified.
# Generate log-normal data with 20% censoring. data <- GenData(n = 1e3, dist = "log-normal", theta = c(0, 2), p = 0.2) # Estimate parameters. fit <- FitParaSurv(data, dist = "log-normal")
# Generate log-normal data with 20% censoring. data <- GenData(n = 1e3, dist = "log-normal", theta = c(0, 2), p = 0.2) # Estimate parameters. fit <- FitParaSurv(data, dist = "log-normal")
Log-Normal Parameter Estimation without Censoring
FitLogNormComplete(data)
FitLogNormComplete(data)
data |
Data.frame. |
Numeric vector containing the estimate location and scale parameters.
Estimates parametric survival distributions using event times subject to non-informative right censoring. Available distributions include: exponential, gamma, generalized gamma, log-normal, and Weibull.
FitParaSurv( data, beta_lower = 0.1, beta_upper = 10, dist = "weibull", eps = 1e-06, init = NULL, maxit = 10, report = FALSE, sig = 0.05, status_name = "status", tau = NULL, time_name = "time" )
FitParaSurv( data, beta_lower = 0.1, beta_upper = 10, dist = "weibull", eps = 1e-06, init = NULL, maxit = 10, report = FALSE, sig = 0.05, status_name = "status", tau = NULL, time_name = "time" )
data |
Data.frame containing the time to event and status. |
beta_lower |
If dist="gen-gamma", lower limit on possible values for beta. |
beta_upper |
If dist="gen-gamma", upper limit on possible values for beta. |
dist |
String, distribution to fit, selected from among: exp, gamma, gen-gamma log-normal, and weibull. |
eps |
Tolerance for Newton-Raphson iterations. |
init |
List of initial parameters. See individual distributions for the expected parameters. |
maxit |
Maximum number of NR iterations. |
report |
Report fitting progress? |
sig |
Significance level, for CIs. |
status_name |
Name of the status indicator, 1 if observed, 0 if censored. |
tau |
Optional truncation time for calculating RMSTs. |
time_name |
Name of column containing the time to event. |
An object of class fit
containing the following:
The estimated shape and rate parameters.
The observed information matrix.
The fitted mean, median, and variance.
The estimated RMSTs, if tau was specified.
Between group comparison of survival experience CompParaSurv
Exponential distribution FitExp
Gamma distribution FitGamma
Generalized gamma distribution FitGenGamma
Log-normal distribution FitLogNormal
Weibull distribution FitWeibull
# Generate Gamma data with 20% censoring. data <- GenData(n = 1e3, dist = "gamma", theta = c(2, 2), p = 0.2) # Fit gamma distribution. fit <- FitParaSurv(data, dist = "gamma") # Generate Weibull data with 10% censoring. data <- GenData(n = 1e3, dist = "weibull", theta = c(2, 2), p = 0.1) # Fit weibull distribution, calculate RMST at tau=0.5. fit <- FitParaSurv(data, dist = "weibull", tau = 0.5)
# Generate Gamma data with 20% censoring. data <- GenData(n = 1e3, dist = "gamma", theta = c(2, 2), p = 0.2) # Fit gamma distribution. fit <- FitParaSurv(data, dist = "gamma") # Generate Weibull data with 10% censoring. data <- GenData(n = 1e3, dist = "weibull", theta = c(2, 2), p = 0.1) # Fit weibull distribution, calculate RMST at tau=0.5. fit <- FitParaSurv(data, dist = "weibull", tau = 0.5)
Estimates parameters for Weibull event times subject to non-informative
right censoring. The Weibull distribution is parameterized in terms
of the shape and rate
:
FitWeibull( data, init = list(), sig = 0.05, status_name = "status", tau = NULL, time_name = "time" )
FitWeibull( data, init = list(), sig = 0.05, status_name = "status", tau = NULL, time_name = "time" )
data |
Data.frame. |
init |
List containing the initial value for the shape, |
sig |
Significance level, for CIs. |
status_name |
Name of the status indicator, 1 if observed, 0 if censored. |
tau |
Optional truncation times for calculating RMSTs. |
time_name |
Name of column containing the time to event. |
An object of class fit
containing the following:
The estimated shape and rate
.
The observed information matrix.
The fitted mean, median, and variance.
The estimated RMSTs, if tau was specified.
# Generate Weibull data with 20% censoring. data <- GenData(n = 1e3, dist = "weibull", theta = c(2, 2), p = 0.2) # Estimate parameters. fit <- FitParaSurv(data, dist = "weibull")
# Generate Weibull data with 20% censoring. data <- GenData(n = 1e3, dist = "weibull", theta = c(2, 2), p = 0.2) # Estimate parameters. fit <- FitParaSurv(data, dist = "weibull")
Observed information for gamme event times without censoring.
GammaInfo(data, shape, rate)
GammaInfo(data, shape, rate)
data |
Data.frame. |
shape |
Shape parameter |
rate |
Rate parameter |
Numeric information matrix.
Profile score equation for gamma event times without censoring.
GammaScore(data, shape)
GammaScore(data, shape)
data |
Data.frame. |
shape |
Shape parameter. |
Numeric score.
Generates data from survival distributions as parameterized in this package, with optional non-informative random right censoring.
GenData(n, dist = "exp", theta = NULL, p = 0)
GenData(n, dist = "exp", theta = NULL, p = 0)
n |
Integer sample size. |
dist |
String, distribution name selected from among: "exp","gamma","gen-gamma","log-normal","weibull". |
theta |
Numeric parameter vector. Elements will vary according to the distribution. |
p |
Expected censoring proportion. |
The parameter vector theta should contain the following elements, in order, depending on the distribution:
Rate .
Shape , rate
.
Shape 1 , shape 2
, rate
.
Locaion , scale
.
Shape , rate
.
Data.frame including the observation times and status.
# Gamma event times with shape 2 and rate 2. # Expected censoring proportion of 20%. data <- GenData(n = 1e3, dist = "gamma", theta = c(2, 2), p = 0.20) # Generalized gamma event times with shapes (2,3) and rate 1. # Expected censoring proportion of 15%. data <- GenData(n = 1e3, dist = "gen-gamma", theta = c(2, 3, 1), p = 0.15) # Log-normal event times with location 0 and rate 1. # Expected censoring proportion of 10%. data <- GenData(n = 1e3, dist = "log-normal", theta = c(0, 1), p = 0.10) # Weibull event times with shape 2 and rate 2. # Expected censoring proportion of 5%. data <- GenData(n = 1e3, dist = "weibull", theta = c(2, 2), p = 0.05)
# Gamma event times with shape 2 and rate 2. # Expected censoring proportion of 20%. data <- GenData(n = 1e3, dist = "gamma", theta = c(2, 2), p = 0.20) # Generalized gamma event times with shapes (2,3) and rate 1. # Expected censoring proportion of 15%. data <- GenData(n = 1e3, dist = "gen-gamma", theta = c(2, 3, 1), p = 0.15) # Log-normal event times with location 0 and rate 1. # Expected censoring proportion of 10%. data <- GenData(n = 1e3, dist = "log-normal", theta = c(0, 1), p = 0.10) # Weibull event times with shape 2 and rate 2. # Expected censoring proportion of 5%. data <- GenData(n = 1e3, dist = "weibull", theta = c(2, 2), p = 0.05)
Observed information for the generalized gamma log likelihood in the absence of censoring.
GenGammaObsInfo(data, alpha, beta, lambda)
GenGammaObsInfo(data, alpha, beta, lambda)
data |
Data.frame. |
alpha |
First shape parameter. |
beta |
Second shape parameter. |
lambda |
Rate parameter. |
Numeric observed information matrix.
Profile log likelihood of the generalized gamma distribution as a function
of the second shape parameter .
GenGammaProfileLogLik(data, beta)
GenGammaProfileLogLik(data, beta)
data |
Data.frame. |
beta |
Second shape parameter. |
Numeric profile log likelihood.
Profile MLE of the generalized gamma rate given the shape parameters.
GenGammaRate(data, alpha, beta)
GenGammaRate(data, alpha, beta)
data |
Data.frame. |
alpha |
First shape parameter. |
beta |
Second shape parameter. |
Numeric MLE of the rate .
Score equation for the generalized gamma log likelihood in the absence of censoring.
GenGammaScore(data, alpha, beta, lambda)
GenGammaScore(data, alpha, beta, lambda)
data |
Data.frame. |
alpha |
First shape parameter. |
beta |
Second shape parameter. |
lambda |
Rate parameter. |
Numeric score vector.
Profile MLE of the first shape parameter of the generalized gamma
given the second shape parameter
.
GenGammaShape(data, beta)
GenGammaShape(data, beta)
data |
Data.frame. |
beta |
Second shape parameter. |
Numeric MLE of the rate .
Observed information for log-normal event times without censoring.
LogNormInfo(data, loc, scale, log_scale = FALSE)
LogNormInfo(data, loc, scale, log_scale = FALSE)
data |
Data.frame. |
loc |
Location parameter. |
scale |
Scale parameter. |
log_scale |
Is the scale parameter logged? |
Numeric score.
Score equation for log-normal event times without censoring.
LogNormScore(data, loc, scale)
LogNormScore(data, loc, scale)
data |
Data.frame. |
loc |
Location parameter. |
scale |
Scale parameter. |
Numeric score.
Newton Raphson Estimation
NewtonRaphson(init, obj, eps = 1e-06, maxit = 10, report = FALSE)
NewtonRaphson(init, obj, eps = 1e-06, maxit = 10, report = FALSE)
init |
Initial value. |
obj |
Objective function. |
eps |
Tolerance for Newton-Raphson iterations. |
maxit |
Maximum number of NR iterations. |
report |
Report fitting progress? |
Numeric parameter estimate.
Newton Raphson Update Iteration
NRUpdate(obj, state)
NRUpdate(obj, state)
obj |
Objective function. |
state |
List containing the parameter vector 'theta'. |
List containing the updated parameter vector 'theta' and the objective increment 'delta'.
Calculates the RMST as the area under a fitted parametric survival distribution.
ParaRMST(fit, tau, sig = 0.05)
ParaRMST(fit, tau, sig = 0.05)
fit |
Fitted parametric survival distribution. |
tau |
Numeric vector of truncation times. |
sig |
Significance level, for CIs. |
Data.frame containing the estimated RMST at each truncation time.
# Generate Weibull data with 20% censoring. data <- GenData(n = 1e3, dist = "weibull", theta = c(2, 0.5), p = 0.2) # Fit Weibull distribution. fit <- FitParaSurv(data, dist = "weibull") # Calculate RMSTs. rmst <- ParaRMST(fit = fit, tau = c(0.5, 1.0, 1.5, 2.0)) # Generate gamma data with 10% censoring. data <- GenData(n = 1e3, dist = "gamma", theta = c(2, 2), p = 0.10) # Fit gamma distribution. fit <- FitParaSurv(data, dist = "gamma") # Calculate RMSTs. rmst <- ParaRMST(fit = fit, tau = c(0.5, 1.0, 1.5, 2.0))
# Generate Weibull data with 20% censoring. data <- GenData(n = 1e3, dist = "weibull", theta = c(2, 0.5), p = 0.2) # Fit Weibull distribution. fit <- FitParaSurv(data, dist = "weibull") # Calculate RMSTs. rmst <- ParaRMST(fit = fit, tau = c(0.5, 1.0, 1.5, 2.0)) # Generate gamma data with 10% censoring. data <- GenData(n = 1e3, dist = "gamma", theta = c(2, 2), p = 0.10) # Fit gamma distribution. fit <- FitParaSurv(data, dist = "gamma") # Calculate RMSTs. rmst <- ParaRMST(fit = fit, tau = c(0.5, 1.0, 1.5, 2.0))
Calculates permutation p-values for location and RMST estimates.
PermP(df1, df0, fit0, fit1, eps, init1, init0, maxit, reps, tau)
PermP(df1, df0, fit0, fit1, eps, init1, init0, maxit, reps, tau)
df1 |
Target data.frame containing time and status. |
df0 |
Reference data.frame containing time and status. |
fit0 |
Fitted parametric survival distribution for arm 0. |
fit1 |
Fitted parametric survival distribution for arm 1. |
eps |
Tolerance for Newton-Raphson iterations. |
init1 |
Initial parameter values for the target group. |
init0 |
Initial parameter values for the reference group. |
maxit |
Maximum number of Newton-Raphson iterations. |
reps |
Number of permutation replicates. |
tau |
Optional truncation times for calculating RMST. |
Numeric vector of permutation p-values.
Print method for an object of class contrast
.
## S3 method for class 'contrast' print(x, ...)
## S3 method for class 'contrast' print(x, ...)
x |
A |
... |
Unused. |
Print method for objects of class fit
.
## S3 method for class 'fit' print(x, ...)
## S3 method for class 'fit' print(x, ...)
x |
An object of class |
... |
Unused. |
Quadratic Form
QF(x, A)
QF(x, A)
x |
Numeric vector. |
A |
Numeric matrix. |
Numeric scalar.
Quantile function for the Weibull distribution. See FitWeibull
for the parameterization.
qWeibull(p, a = 1, l = 1)
qWeibull(p, a = 1, l = 1)
p |
Probability. |
a |
Shape. |
l |
Rate. |
Scalar quantile.
Generates gamma event times with shape parameter and rate
parameter
. See
FitGamma
for the parameterization. If
a censoring proportion is provided, the event times are subject to
non-informative random right censoring.
rGamma(n, a = 1, l = 1, p = 0)
rGamma(n, a = 1, l = 1, p = 0)
n |
Sample size. |
a |
Shape. |
l |
Rate. |
p |
Expected censoring proportion. |
Data.frame including the observation times and status.
Generates generalized gamma event times with shape parameters
, and rate parameter
. See
FitGenGamma
for the parameterization. If a censoring
proportion is provided, the event times are subject to
non-informative random right censoring.
rGenGamma(n, a = 1, b = 1, l = 1, p = 0)
rGenGamma(n, a = 1, b = 1, l = 1, p = 0)
n |
Sample size. |
a |
First shape parameter, |
b |
Second shape parameter, |
l |
Rate. |
p |
Expected censoring proportion. |
Data.frame including the observation times and status indicators.
Generates log-normal event times with location parameter and scale
parameter
. See
FitLogNormal
for the
parameterization. If a censoring proportion is provided, the event
times are subject to non-informative random right censoring.
rLogNormal(n, m = 0, s = 1, p = 0)
rLogNormal(n, m = 0, s = 1, p = 0)
n |
Sample size. |
m |
Location. |
s |
Scale. |
p |
Expected censoring proportion. |
Data.frame including the observation time and status.
Round Data Frames
RoundDF(df, digits = 3)
RoundDF(df, digits = 3)
df |
Data.frame. |
digits |
Integer. |
Data.frame.
Generates Weibull event times with shape parameter and rate
parameter
. See
FitWeibull
for the parameterization. If
a censoring proportion is provided, the deviates are subject to
non-informative random right censoring.
rWeibull(n, a = 1, l = 1, p = 0)
rWeibull(n, a = 1, l = 1, p = 0)
n |
Sample size. |
a |
Shape. |
l |
Rate. |
p |
Expected censoring proportion. |
Data.frame including the observation time and status.
Show Method for a Contrast of Survival Distributions.
## S4 method for signature 'contrast' show(object)
## S4 method for signature 'contrast' show(object)
object |
An object of class |
Show Method for Fitted Survival Distributions
## S4 method for signature 'fit' show(object)
## S4 method for signature 'fit' show(object)
object |
An object of class |
Constructs the survival function for a parameter distribution.
SurvFunc(dist, theta)
SurvFunc(dist, theta)
dist |
String, distribution name. |
theta |
Numeric parameter vector. |
The parameter vector theta should contain the following elements, in order, according to the distribution:
Rate .
Shape , rate
.
Shape 1 , shape 2
, rate
.
Locaion , scale
.
Shape , rate
.
Survival function.
# Survival function for the generalized gamma. surv <- SurvFunc(dist = "gen-gamma", theta = c(2, 2, 2)) # Evaluation. surv(1.0)
# Survival function for the generalized gamma. surv <- SurvFunc(dist = "gen-gamma", theta = c(2, 2, 2)) # Evaluation. surv(1.0)
Evaluates the log-likelihood for a parametric survival distribution.
SurvLogLik( data, dist, theta, log_scale = FALSE, status_name = "status", time_name = "time" )
SurvLogLik( data, dist, theta, log_scale = FALSE, status_name = "status", time_name = "time" )
data |
Data.frame |
dist |
Distribution, from among: "exp","gamma","gen-gamma","log-normal","weibull". |
theta |
Parameters, which will vary according to the distribution. |
log_scale |
Are strictly positive parameters on log-scale? |
status_name |
Status indicator, coded as 1 if an event was observed, 0 if censored. |
time_name |
Name of column containing the time to event. |
The parameter vector theta should contain the following elements, in order, depending on the distribution:
Rate .
Shape , rate
.
Shape 1 , shape 2
, rate
.
Location , scale
.
Shape , rate
.
Scalar value of the log likelihood.
# Generate gamma event time data with 10% censoring. data <- GenData(n = 1e3, dist = "gamma", theta = c(2, 2), p = 0.1) # Evaluate log likelihood. ll <- SurvLogLik(data, dist = "gamma", theta = c(2, 2)) # Generate Weibull event time data with 20% censoring. data <- GenData(n = 1e3, dist = "weibull", theta = c(2, 2), p = 0.2) # Evaluate log likelihood. ll <- SurvLogLik(data, dist = "weibull", theta = c(2, 2))
# Generate gamma event time data with 10% censoring. data <- GenData(n = 1e3, dist = "gamma", theta = c(2, 2), p = 0.1) # Evaluate log likelihood. ll <- SurvLogLik(data, dist = "gamma", theta = c(2, 2)) # Generate Weibull event time data with 20% censoring. data <- GenData(n = 1e3, dist = "weibull", theta = c(2, 2), p = 0.2) # Evaluate log likelihood. ll <- SurvLogLik(data, dist = "weibull", theta = c(2, 2))
Information matrix for the Weibull shape and rate parameters.
WeiInfo(data, shape, rate)
WeiInfo(data, shape, rate)
data |
Data.frame. |
shape |
Shape parameter, alpha. |
rate |
Rate parameter, lambda. |
Numeric information matrix.
Weibull Initialization.
WeiInit(data, init)
WeiInit(data, init)
data |
Data.frame. |
init |
Initialization list. |
Numeric initial value for shape.
Profile MLE of the Weibull rate as a function of the shape.
WeiRate(data, shape)
WeiRate(data, shape)
data |
Data.frame. |
shape |
Shape parameter. |
Numeric rate.
Profile score equation for the Weibull shape parameter.
WeiScore(data, shape)
WeiScore(data, shape)
data |
Data.frame. |
shape |
Shape parameter. |
Numeric score.