Fit a Weibull competing risks model with shared gamma frailty between all transitions (0->1,0->2,...,0->k). Handles left-truncated and right-censored data. The model considers transitions from an initial state (0) to (k) competing absorbing states.

frailtyCmprsk(formulas, data, maxit = 300,
init.B, init.Theta, init.hazard.weib,
LIMparam = 1e-3, LIMlogl = 1e-3, LIMderiv = 1e-3,
x0, print.info = FALSE, print.result = TRUE,
partialH, blinding = TRUE)An object of class 'frailtyCmprsk' containing:
Vector of the estimated parameters. Order is: (scale(0->1), shape(0->1), scale(0->2), shape(0->2), ..., scale(0->k), shape(0->k),\(\hat {\theta}\) (if frailty), \(\hat{\beta}_1\), \(\hat{\beta}_2\),...,\(\hat{\beta}_k\)).
The matched function call.
Vector of estimated regression coefficients.
The marginal log-likelihood value at the final parameter estimates.
Gradient vector of the log-likelihood at the final parameter estimates.
The number of observations used in the fit.
Vector containing the number of observed events: count for 0->1, count for 0->2,..., count for 0->k, count for censoring.
Number of iterations.
Variance-covariance matrix for the parameters listed in b.
Total number of estimated parameters.
Total number of regression coefficients.
Vector of estimated Weibull baseline shape parameters (shape(0->1),shape(0->2),...,shape(0->k)).
Vector of estimated Weibull baseline scale parameters (scale(0->1),scale(0->2),...,scale(0->k)).
Convergence status code: 1=converged, 2=maximum iterations reached, 3=converged using partial Hessian, 4=the algorithm encountered a problem in the loglikelihood computation.
Logical. TRUE if a model with shared frailty (cluster(.)) was fitted.
Vector of p-values from Wald tests for the regression coefficients in coef.
Akaike Information Criterion, calculated as \(AIC=\frac{1}{n}(np - l(.))\), where np is the number of parameters and l is the log-likelihood.
List of numeric vectors, where each vector contains the time points used for calculating the baseline functions for each transition.
List of matrices, where each matrix contains baseline hazard estimates and 95% confidence intervals at the corresponding time points in x0, for each transition.
List of matrices, where each matrix contains baseline survival estimates and 95% confidence intervals at the corresponding time points in x0, for each transition.
List of matrices, where each matrix contains the estimated median baseline survival time and its 95% confidence interval for each transition.
List of numeric vectors, where each vector contains to the linear predictors for transition 0->l (\(l=1,...,k\)). For non-frailty models, each element is of the form \(\hat{\beta}_l^{t}X_l\). For frailty models, it includes the estimated log-frailty: \(\hat{\beta}_l^{t}X_l + \log(\hat{\omega}_i)\).
List of character vectors, where each vector contains the factor covariates included in the model for the corresponding transition.
List of numeric vectors, where each vector contains the chi-squared statistics from global Wald tests for factor variables for the corresponding transition.
List of integer vectors, where each vector contains the degrees of freedom for the global Wald tests for the corresponding transition.
List of numeric vectors, where each vector contains the p-values for the global Wald tests for the corresponding transition.
Binary vector of length k indicating whether any global factor tests were performed for each transition.
If Frailty is TRUE, the following components related to frailty are also included:
The number of unique groups specified by cluster(.).
The estimated variance (\(\hat{\theta}\)) of the Gamma frailty distribution.
The p-value from a Wald test for the null hypothesis \(H_0: \theta=0\).
The estimated variance of the frailty variance estimator: \(\hat{Var}(\hat{\theta})\).
Vector containing the empirical Bayes predictions of the frailty term for each group.
Vector containing the variances of the empirical Bayes frailty predictions.
Vector containing the standard errors of the empirical Bayes frailty predictions.
A list of formula objects. The first formula must include a
response on the left-hand side of a ~ operator. The response must be a
survival object as returned by the Surv function (e.g., survival::Surv).
The argument type = "mstate" must be specified within the
Surv function. The status indicator in the Surv object should be:
0 for right-censoring, 1 for the first competing event, 2 for the second, ..., and k for the
kth competing event.
Covariates for the transition from 0 to 1 are specified on the right-hand side (RHS) of the first formula.
The remaining elements of the list should be one-sided formulas (e.g., ~ var1 + var2),
used only to specify the covariates. The second formula corresponds to the transition 0 -> 2,
the third to 0 -> 3, and so on, up to the kth formula for transition 0 -> k.
Left-truncation is supported and should be specified using the three-argument
Surv(time1, time2, status) notation.
Shared frailty can be specified via cluster(group_variable) on the RHS of the first formula only.
It should not be included in the other formulas.
A data.frame containing the variables named in formulas.
Maximum number of iterations for the Marquardt optimization algorithm. Default is 300.
Optional. A vector of initial values for the regression coefficients.
It should contain the coefficients for each transition from 0->1, ..., up to 0->k
(i.e., \(\beta_1\), \(\beta_2\), ..., \(\beta_k\)), concatenated in order.
The total length must match the total number of covariates specified across all formulas.
If omitted, the regression coefficients are initialized from default values.
These defaults are obtained by fitting k independent Weibull proportional
hazards models (without frailty), one for each transition.
Optional. Initial value for the frailty variance \(\theta\).
Default is 0.1. This parameter is only used if cluster() is present
in formulas.
Optional. A vector of initial values for the Weibull baseline
hazard parameters. It must be of length 2 * k, with the values ordered as:
scale(0->1), shape(0->1), scale(0->2), shape(0->2), ..., scale(0->k), shape(0->k).
If omitted, the baseline hazard parameters are initialized from default values.
These defaults are obtained by fitting k independent Weibull proportional
hazards models (without frailty), one for each transition.
Convergence threshold for the parameters based on the maximum absolute difference between successive iterations (\(10^{-3}\) by default).
Convergence threshold for the log-likelihood based on the absolute difference between successive iterations (\(10^{-3}\) by default).
Convergence threshold based on the relative distance to the optimum (related to gradient and Hessian) (\(10^{-3}\) by default). See Details.
Optional. A list of numeric vectors, where each vector specifies the time points at which to compute the baseline hazard and survival functions for a given transition. The order must follow the transitions: 0->1, 0->2, ..., 0->k. If not provided, defaults to a list where each element is a sequence of 99 time points from 0 to the maximum observed time for the corresponding transition.
Logical. If TRUE, prints information at each iteration
of the optimization algorithm. Default is FALSE.
Logical. If TRUE, prints a formatted summary of the
results. Default is TRUE.
Optional. Integer vector specifying the indices of parameters to
exclude from the Hessian matrix when calculating the relative distance
convergence criterion (LIMderiv). This is only considered if the first
two criteria (LIMparam, LIMlogl) are met and the full Hessian
is problematic (e.g., not invertible). Default is NULL.
Logical. If TRUE, the algorithm attempts to continue even
if the log-likelihood calculation produces non-finite values (e.g., Inf,
NaN) at some iteration. Setting to FALSE may cause the algorithm
to stop earlier in such cases. Default is TRUE.
Let \(T\) be the time to event and \(L \in \{1,2,...,k\}\) the indicator of the cause of the event.
The cause-specific hazard rate for cause \(l \in \{1,2,...,k\}\) is: $$ \lambda_{l}(t) = \lim_{\Delta t \to 0^+} \frac{\mathbb{P}(t \leq T \leq t + \Delta t, L=l \mid T \geq t)}{\Delta t} $$
A proportional hazards model with a shared frailty term \(\omega_i\) is assumed for each transition within group \(i\). For the \(j^{th}\) subject (\(j=1,...,n_i\)) in the \(i^{th}\) group (\(i=1,...,G\)), the \(l^{th}\) (\(l=1,...,k\)) transition intensity is defined as follows:
$$ \lambda_{l}^{ij}(t |\omega_i,X_{l}^{ij}) = \lambda_{0l}(t) \omega_i \exp(\beta_l^{T} X_{l}^{ij}) $$ where \(\omega_i \sim\Gamma(\frac{1}{\theta},\frac{1}{\theta})\) with \(\bold{E}(\omega_i)=1\) and \(\bold{Var}(\omega_i)=\theta\).
\(\omega_i\) is the frailty term for the \(i^{th}\) group.
For subject-specific frailties, use cluster(id) where id is unique (\(n_i=1\)).
\(\beta_l\) (\(l=1,...,k\)) is the vector
of time fixed regression coefficients for the transition 0->l.
\(X_{l}^{ij}\) (\(l=1,...,k\)) is the vector
of time fixed covariates for the \(j^{th}\) subject in the \(i^{th}\) group for the
transition 0->l.
\(\lambda_{0l}(.)\) (\(l=1,...,k\)) is the
baseline hazard function for the transition 0->l.
The Weibull baseline hazard parameterization is: $$\lambda(t) = \frac{\gamma}{\lambda^\gamma} \cdot t^{\gamma - 1}$$ where \(\lambda\) is the scale parameter and \(\gamma\) the shape parameter
Marquardt, D. W. (1963). An algorithm for least-squares estimation of nonlinear parameters. SIAM Journal on Applied Mathematics, 11(2), 431-441.
Liquet, B., Timsit, J. F., & Rondeau, V. (2012). Investigating hospital heterogeneity with a multi-state frailty model: application to nosocomial pneumonia disease in intensive care units. BMC Medical Research Methodology, 12(1), 1-14.
# \donttest{
data(CPRSKbmtcrr)
##-- Weibull competing risks model with
## group frailty shared between transitions --##
ModCmprsk_Group <- frailtyCmprsk(
formulas = list(
Surv(observed_time, Status, type = "mstate") ~ cluster(group) + Sex,
~ Sex
),
data = CPRSKbmtcrr,
print.info = FALSE,
maxit = 100
)
##-- Weibull competing risks model with subject-specific
## frailty shared between transitions --##
ModCmprsk_Subject <- frailtyCmprsk(
formulas = list(
Surv(observed_time, Status, type = "mstate") ~ cluster(id) + Sex,
~ Sex
),
data = CPRSKbmtcrr,
print.info = FALSE,
maxit = 100
)
##--- Simple Weibull competing risks model with left truncation ---##
ModCmprsk_LeftTrunc <- frailtyCmprsk(
formulas = list(
Surv(Age, observed_time, Status, type = "mstate") ~ Source,
~ Sex
),
data = CPRSKbmtcrr,
print.info = FALSE
)
##--- Simple Weibull competing risks model with a factor and
## no covariates for the first competing event (left truncation) ---##
ModCmprsk_Factor_LeftTrunc <- frailtyCmprsk(
formulas = list(
Surv(Age, observed_time, Status, type = "mstate") ~ Source,
~ factor(Phase)
),
data = CPRSKbmtcrr,
print.info = FALSE
) # }
Run the code above in your browser using DataLab