| Title: | Mixture Cure Rate Models with Flexible Link Functions via the EM Algorithm |
|---|---|
| Description: | Fits mixture cure rate models by the Expectation-Maximization (EM) algorithm. The incidence component (the probability of being uncured) accepts the logit, probit, cauchit, power logit and reversed power logit link functions, and the latency component accepts the exponential, Rayleigh, Weibull, log-normal, log-logistic and inverse Gaussian distributions. The package provides parameter estimates with standard errors, simulation of data from the model, and diagnostic tools based on residuals and simulated envelopes. The methods build on Berkson and Gage (1952) <doi:10.2307/2281318>, Dempster, Laird and Rubin (1977) <doi:10.1111/j.2517-6161.1977.tb01600.x> and Bazán, Torres-Avilés, Suzuki and Louzada (2017) <doi:10.1002/asmb.2215>. |
| Authors: | Chaeyeon Yoo [aut], Dipak K. Dey [aut], Victor H. Lachos [aut], Jalmar M. F. Carrasco [aut, cre] |
| Maintainer: | Jalmar M. F. Carrasco <[email protected]> |
| License: | GPL-3 |
| Version: | 0.3.0 |
| Built: | 2026-10-09 13:25:30 UTC |
| Source: | https://github.com/carrascojalmar/emgcr |
A sample of 1,736 patients who have been diagnosed with liver cancer between 2012 and 2016, whose cancer grades are well identified. Available individual-level covariates include age at diagnosis, sex, race, grade of liver cancer, median household income, radiation indicator, and chemotherapy indicator. The grade of disease is categorized into four levels: well-differentiated (Grade I), moderately differentiated (Grade II), poorly differentiated (Grade III), and undifferentiated/anaplastic (Grade IV).
data(liver)data(liver)
A data frame with 1,736 observations and 10 variables:
Unique patient identifier
Survival time in months
Event indicator: death due to liver cancer = 1, censored = 0
Sex of patient: male = 1, female = 0
Scaled age of diagnosis
Scaled median household income of the subject
Race: white = 1, other = 0
Pathological grade of liver cancer (1 = I, 2 = II, 3 = III, 4 = IV)
Chemotherapy: yes = 1, no = 0
Radiation: yes = 1, no = 0
data(liver) head(liver)data(liver) head(liver)
Fits a mixture cure rate model by the Expectation-Maximization (EM) algorithm, with a flexible link function for the incidence (cure) component and a choice of survival distributions for the latency component.
MCRfit( formula, data, dist = "weibull", link = "logit", tau = 1, maxit = 1000, tol = 1e-05 )MCRfit( formula, data, dist = "weibull", link = "logit", tau = 1, maxit = 1000, tol = 1e-05 )
formula |
A two-part formula of the form |
data |
A data frame containing the variables in the model. |
dist |
A character string indicating the baseline distribution. Supported values are |
link |
A character string specifying the link function for the probability of being uncured. Options are |
tau |
A numeric value used when |
maxit |
Maximum number of iterations for the EM-like algorithm. Defaults to 1000. |
tol |
Convergence tolerance. Defaults to 1e-5. |
In the latency component, the covariates enter through the scale parameter
, as in an accelerated failure time model
(the same convention as survreg). A positive coefficient
therefore means longer survival times for uncured individuals. With shape
parameter , the survival functions of the uncured are:
exponential: ;
Rayleigh: ;
Weibull: ;
log-normal: ;
log-logistic: ;
inverse Gaussian: mean and shape .
An object of class "MCR", which is a list containing:
coefficients |
Estimated regression coefficients for the survival part. |
coefficients_cure |
Estimated coefficients for the incidence part, that is, for the probability of being uncured. |
scale |
Estimated shape parameter |
loglik |
Final log-likelihood value. |
n |
Number of observations used in the model. |
deleted |
Number of incomplete cases removed before fitting. |
ep |
Estimated standard errors. |
iter |
Number of EM iterations. |
convergence |
Logical; |
dist |
Distribution used. |
link |
Link function used. |
tau |
Tau parameter used (if applicable). |
require(EMGCR) data(liver) names(liver) liver$sex <- factor(liver$sex) liver$grade <- factor(liver$grade) liver$radio <- factor(liver$radio) liver$chemo <- factor(liver$chemo) str(liver) model <- MCRfit( survival::Surv(time, status) ~ age + sex + grade + radio + chemo | age + medh + grade + radio + chemo, dist = "loglogistic", link = "plogit", tau = 0.15, data = liver ) summary(model)require(EMGCR) data(liver) names(liver) liver$sex <- factor(liver$sex) liver$grade <- factor(liver$grade) liver$radio <- factor(liver$radio) liver$chemo <- factor(liver$chemo) str(liver) model <- MCRfit( survival::Surv(time, status) ~ age + sex + grade + radio + chemo | age + medh + grade + radio + chemo, dist = "loglogistic", link = "plogit", tau = 0.15, data = liver ) summary(model)
Plots the Kaplan-Meier estimate of the survival function together with the population survival function implied by one or more fitted mixture cure rate models.
## S3 method for class 'MCR' plot(...)## S3 method for class 'MCR' plot(...)
... |
One or more fitted MCR objects from |
For each model, the fitted population survival function is averaged over the observations,
where is the estimated probability of being uncured and
is the estimated survival function of the uncured.
The Kaplan-Meier curve (dashed) is computed from the data of the first model,
so all models should be fitted to the same data. Curves are coloured by
latency distribution.
A ggplot object.
Produces a Q-Q plot of residuals from a Mixture Cure Rate (MCR) model fitted via MCRfit. Optionally, a simulation envelope can be included for Cox-Snell residuals.
qqMCR( object, type = c("cox-snell", "quantile"), envelope = FALSE, nsim = 100, censor = NULL, ... )qqMCR( object, type = c("cox-snell", "quantile"), envelope = FALSE, nsim = 100, censor = NULL, ... )
object |
An object of class |
type |
Character. Type of residual to use in the QQ-plot. Options are |
envelope |
Logical. Whether to add a simulation envelope to the QQ-plot. Default is |
nsim |
Integer. Number of simulations used to construct the envelope. Default is |
censor |
Logical vector or NULL. Censoring indicator used when simulating data for the envelope. Required only when |
... |
Additional arguments (currently ignored). |
The function generates QQ-plots of either Cox-Snell or quantile residuals. When envelope = TRUE and type = "cox-snell", a simulation envelope is added using Monte Carlo replications.
A QQ-plot is produced as a side effect. Nothing is returned.
data(liver) liver$sex <- factor(liver$sex) liver$grade <- factor(liver$grade) liver$radio <- factor(liver$radio) liver$chemo <- factor(liver$chemo) fit <- MCRfit( survival::Surv(time, status) ~ age + sex + grade + radio + chemo | age + medh + grade + radio + chemo, dist = "loglogistic", link = "plogit", tau = 0.15, data = liver ) qqMCR(fit, type = "quantile", envelope = TRUE, nsim = 50, censor = liver$status)data(liver) liver$sex <- factor(liver$sex) liver$grade <- factor(liver$grade) liver$radio <- factor(liver$radio) liver$chemo <- factor(liver$chemo) fit <- MCRfit( survival::Surv(time, status) ~ age + sex + grade + radio + chemo | age + medh + grade + radio + chemo, dist = "loglogistic", link = "plogit", tau = 0.15, data = liver ) qqMCR(fit, type = "quantile", envelope = TRUE, nsim = 50, censor = liver$status)
This function computes Global Cox-Snell and randomized quantile residuals for objects of class MCR.
## S3 method for class 'MCR' residuals(object, type = c("cox-snell", "quantile"), ...)## S3 method for class 'MCR' residuals(object, type = c("cox-snell", "quantile"), ...)
object |
An object of class |
type |
Type of residual. |
... |
Additional arguments (not used). |
A numeric vector of residuals of class "MCRresiduals". Printing it shows
the first six residuals and a summary; use as.vector() to drop the class.
data(liver) liver$sex <- factor(liver$sex) liver$grade <- factor(liver$grade) liver$radio <- factor(liver$radio) liver$chemo <- factor(liver$chemo) model <- MCRfit( survival::Surv(time, status) ~ age + sex + grade + radio + chemo | age + medh + grade + radio + chemo, dist = "loglogistic", link = "plogit", tau = 0.15, data = liver ) residuals(model, type = "quantile")data(liver) liver$sex <- factor(liver$sex) liver$grade <- factor(liver$grade) liver$radio <- factor(liver$radio) liver$chemo <- factor(liver$chemo) model <- MCRfit( survival::Surv(time, status) ~ age + sex + grade + radio + chemo | age + medh + grade + radio + chemo, dist = "loglogistic", link = "plogit", tau = 0.15, data = liver ) residuals(model, type = "quantile")
Simulates survival data from a mixture cure rate model with covariates, a chosen link function for the incidence part and a chosen latency distribution. Censoring times are drawn from a uniform distribution on .
rMCM( n, x, w, censor, alpha, beta, eta, dist = "weibull", link = "logit", tau = 1 )rMCM( n, x, w, censor, alpha, beta, eta, dist = "weibull", link = "logit", tau = 1 )
n |
Integer. Number of observations to simulate. |
x |
Matrix or numeric. Covariate matrix for the latency component. The first column must be the intercept (a column of ones). |
w |
Matrix or numeric. Covariate matrix for the incidence part (the probability of being uncured). Include a column of ones if an intercept is wanted. |
censor |
Numeric. Maximum censoring time (uniformly distributed). |
alpha |
Numeric. Shape parameter |
beta |
Numeric vector. Coefficients for the latency part, which enter through the scale parameter |
eta |
Numeric vector. Coefficients for the incidence part. |
dist |
Character. Distribution for the latency part. Options: |
link |
Character. Link function for the probability of being uncured. Options: |
tau |
A numeric value used when |
A tibble with columns:
Observed (possibly censored) survival time.
Event indicator (1 = event, 0 = censored).
Columns of x without the intercept.
Columns of w.
It also has two attributes: "pCcensur", the percentage of cured
individuals, and "pUCcensur", the percentage of censored observations
among the uncured.
# Example: Simulating survival data using the inverse Gaussian distribution library(EMGCR) n <- 500 beta <- c(1, -1, -2) eta <- c(0.5, -0.5) alpha <- 1.5 p <- length(beta) q <- length(eta) set.seed(10) X <- matrix(rnorm(n*(p-1),0,1),n,p-1) X <- cbind(1,X) set.seed(20) W <- matrix(runif(n*q,-1,1),n,q) W <- scale(W) max_censoring <- 10 set.seed(1234) sim_data <- rMCM(n=n, x = X, w = W, censor = max_censoring, beta = beta, eta = eta, alpha = alpha, link = "logit", dist = "invgauss", tau = 1) names(sim_data) head(sim_data) attributes(sim_data) attr(sim_data, "pCcensur") attr(sim_data, "pUCcensur")# Example: Simulating survival data using the inverse Gaussian distribution library(EMGCR) n <- 500 beta <- c(1, -1, -2) eta <- c(0.5, -0.5) alpha <- 1.5 p <- length(beta) q <- length(eta) set.seed(10) X <- matrix(rnorm(n*(p-1),0,1),n,p-1) X <- cbind(1,X) set.seed(20) W <- matrix(runif(n*q,-1,1),n,q) W <- scale(W) max_censoring <- 10 set.seed(1234) sim_data <- rMCM(n=n, x = X, w = W, censor = max_censoring, beta = beta, eta = eta, alpha = alpha, link = "logit", dist = "invgauss", tau = 1) names(sim_data) head(sim_data) attributes(sim_data) attr(sim_data, "pCcensur") attr(sim_data, "pUCcensur")