Learn R Programming

EMGCR (version 0.2.0)

rMCM: Generate Random Samples for Mixture Cure Rate (MCR) Model

Description

Simulates survival data from a mixture cure rate model with covariates and user-defined link and latency distributions. Censoring is applied randomly.

Usage

rMCM(
  n,
  x,
  w,
  censor,
  alpha,
  beta,
  eta,
  dist = "weibull",
  link = "logit",
  tau = 1
)

Value

A list with elements:

time

Observed (possibly censored) survival time.

status

Event indicator (1 = event, 0 = censored).

x

Covariate matrix for the latency component.

w

Covariate matrix for the cure component.

pCcensur

Percentage of cured individuals.

pUCcensur

Percentage of censored cases among the uncured.

Arguments

n

Integer. Number of observations to simulate.

x

Matrix or numeric. Covariate matrix for the latency component (must include intercept if needed).

w

Matrix or numeric. Covariate matrix for the cure component (no intercept assumed).

censor

Numeric. Maximum censoring time (uniformly distributed).

alpha

Numeric. Shape parameter for the survival distribution.

beta

Numeric vector. Coefficients for the latency part.

eta

Numeric vector. Coefficients for the cure part.

dist

Character. Distribution for the latency part. Options: "weibull", "lognormal", "loglogistic", "invgauss", "exponential", "rayleigh".

link

Character. Link function for cure component. Options: "logit", "probit","plogit" ,"rplogit", "cauchit".

tau

A numeric value used when link = "plogit" or "rplogit". Defaults to 1.

Examples

Run this code
# 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")

Run the code above in your browser using DataLab