View source: R/CARA_function.R
WBR_Alloc_Surv | R Documentation |
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.
WBR_Alloc_Surv(
ptsb.X,
ptsb.Z,
ptsb.Y,
ptsb.t,
ptsb.E,
ptnow.X,
ptnow.Z,
v = 2,
weight
)
ptsb.X |
a vector of length |
ptsb.Z |
a |
ptsb.Y |
a vector of length |
ptsb.t |
a vector of length |
ptsb.E |
a vector of length |
ptnow.X |
a binary value of the predictive covariate of the present patient. |
ptnow.Z |
a vector of length |
v |
a positive value that controls the randomness of allocation probability function. |
weight |
a vector of length |
prob |
Probability of assigning the upcoming patient to treatment A. |
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
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.