getData {carat}  R Documentation 
Generates continuous or binary outcomes given patients' covariates, the underlying model and the randomization procedure.
getData(n, cov_num, level_num, pr, type, beta,
mu1, mu2, sigma = 1, method = "HuHuCAR", ...)
n 
the number of patients. 
cov_num 
the number of covariates. 
level_num 
a vector of level numbers for each covariate. Hence the length of 
pr 
a vector of probabilities. Under the assumption of independence between covariates, 
type 
a datagenerating method. Optional input: 
beta 
a vector of coefficients of covariates. The length of 
mu1,mu2 
main effects of treatment 
sigma 
the error variance for the linear model. The default is 1. This should be a positive value and is only used when 
method 
the randomization procedure to be used for generating randomization sequences. This package provides datagenerating function for 
... 
arguments to be passed to

To generate continuous outcomes, we use the linear model:
y_i = \mu_j+x_i^T\beta+\epsilon_i,
to generate binary outcomes, we use the logit link function:
P(y_i=1) = \frac{exp\{\mu_j+x_i^T\beta \}}{1+exp \{\mu_j+x_i^T\beta }
,
where j
indicates patient i
belongs to treatment j
.
getData
returns a size cov_num+2 \times n
dataframe. The first cov_num
rows represent patients' profile. The next row consists of patients' assignments and the final row consists of generated outcomes.
#Parameters' Setting
set.seed(100)
n = 1000
cov_num = 5
level_num = c(2,2,2,2,2)
beta = c(1,4,3,2,5)
mu1 = 0
mu2 = 0
sigma = 1
type = "linear"
p = 0.85
omega = c(0.1, 0.1, rep(0.8 / 5, times = 5))
pr = rep(0.5,10)
#Data Generation
dataH = getData(n, cov_num,level_num, pr, type, beta,
mu1, mu2, sigma, "HuHuCAR", omega, p)
dataH[1:(cov_num+2),1:5]