getData {carat} | R Documentation |
Data Generation
Description
Generates continuous or binary outcomes given patients' covariates, the underlying model and the randomization procedure.
Usage
getData(n, cov_num, level_num, pr, type, beta,
mu1, mu2, sigma = 1, method = "HuHuCAR", ...)
Arguments
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 data-generating 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 data-generating function for |
... |
arguments to be passed to
|
Details
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
.
Value
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.
Examples
#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,5,4,3,2,1)
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]