WBR_Alloc_Surv: Allocation Function of Weighted Balance Ratio Design for...

View source: R/CARA_function.R

WBR_Alloc_SurvR Documentation

Allocation Function of Weighted Balance Ratio Design for Survival Response

Description

Calculating the probability of assigning the upcoming patient to treatment A based on the patient's covariates and the previous patients' covariates and responses for Weighted Balance Ratio procedure for survival response.

Usage

WBR_Alloc_Surv(
  ptsb.X,
  ptsb.Z,
  ptsb.Y,
  ptsb.t,
  ptsb.E,
  ptnow.X,
  ptnow.Z,
  v = 2,
  weight
)

Arguments

ptsb.X

a vector of length n of the predictive covariates of previous patients. Must be binary.

ptsb.Z

a n x k of the prognostic covariates of previous patients. Must be binary.

ptsb.Y

a vector of length n of the responses of previous patients.

ptsb.t

a vector of length n of the treatment allocation of previous patients.

ptsb.E

a vector of length n with value 1 or 0 of the status of event and censoring.

ptnow.X

a binary value of the predictive covariate of the present patient.

ptnow.Z

a vector of length k of the binary prognostic covariate of the present patient.

v

a positive value that controls the randomness of allocation probability function.

weight

a vector of length 2+k. The weight of balance ratio in overall,margin and stratum levels.

Value

prob

Probability of assigning the upcoming patient to treatment A.

Examples

set.seed(123)

# Generate historical data for 400 patients
ptsb.X = sample(c(1, -1), 400, replace = TRUE)  # predictive covariate
ptsb.Z = cbind(
  sample(c(1, -1), 400, replace = TRUE),         # prognostic covariate 1
  sample(c(1, -1), 400, replace = TRUE)          # prognostic covariate 2
)
ptsb.Y = rexp(400, rate = 1)                    # observed time
ptsb.E = sample(c(1, 0), 400, replace = TRUE)   # event indicator (1=event, 0=censored)
ptsb.t = sample(c(1, 0), 400, replace = TRUE)   # treatment assignments

# Incoming patient covariates
ptnow.X = 1
ptnow.Z = c(1, -1)

# Calculate allocation probability using WBR for survival response
result = WBR_Alloc_Surv(
  ptsb.X = ptsb.X,
  ptsb.Z = ptsb.Z,
  ptsb.Y = ptsb.Y,
  ptsb.E = ptsb.E,
  ptsb.t = ptsb.t,
  ptnow.X = ptnow.X,
  ptnow.Z = ptnow.Z,
  weight = rep(0.25, 4)
)

# View probability of assigning to treatment A
result$prob

caradpt documentation built on Aug. 28, 2025, 9:09 a.m.