View source: R/CARA_function.R
WBR_Sim | R Documentation |
This function simulates a trial using Weighted Balance Ratio design for binary and continuous responses.
WBR_Sim(n, mu, beta, gamma, m0 = 40, pts.X, pts.Z, response, weight, v = 2)
n |
a positive integer. The sample size of the simulated data. |
mu |
a vector of length 2. The true parameters of treatment. |
beta |
a vector of length 2. The true parameters of predictive covariate and interaction with treatment. |
gamma |
a vector of length k. The true parameters of prognostic covariates. |
m0 |
a positive integer. The number of first 2m0 patients will be allocated equally to both treatments. |
pts.X |
a vector of length n. The vector of patients' binary predictive covariates. |
pts.Z |
a matrix of |
response |
the type of the response. Options are |
weight |
a vector of length |
v |
a positive value that controls the randomness of allocation probability function. |
method |
The name of procedure. |
sampleSize |
The sample size of the trial. |
assignment |
The randomization sequence. |
X1proportion |
Average allocation proportion for treatment A when predictive covariate equals the smaller value. |
X2proportion |
Average allocation proportion for treatment A when predictive covariate equals the larger value. |
proportion |
Average allocation proportion for treatment A. |
failureRate |
Proportion of treatment failures (if |
meanResponse |
Mean response value (if |
#'
rejectNull |
Logical. Indicates whether the treatment effect is statistically significant based on a Wald test. |
set.seed(123)
# Simulation settings
n = 400 # total number of patients
mu = c(0.8, 0.8) # treatment effects (muA, muB)
beta = c(0.8, -0.8) # predictive effect and interaction
gamma = c(0.8, 0.8) # prognostic covariate effects
weight = rep(0.25, 4) # weights for imbalance components
# Generate patient covariates
pts.X = sample(c(1, -1), n, replace = TRUE) # predictive covariate
pts.Z = cbind(
sample(c(1, -1), n, replace = TRUE), # prognostic Z1
sample(c(1, -1), n, replace = TRUE) # prognostic Z2
)
# Run simulation for continuous response
result = WBR_Sim(
n = n,
mu = mu,
beta = beta,
gamma = gamma,
pts.X = pts.X,
pts.Z = pts.Z,
response = "Cont",
weight = weight
)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.