set_cov {psborrow} | R Documentation |
Set up covariates
Description
This function saves the mean, variance and covariance among covariates. For technical details, see the vignette.
Usage
set_cov(n_cat, n_cont, mu_int, mu_ext, var, cov, prob_int, prob_ext)
Arguments
n_cat |
Number of binary variable. See details |
n_cont |
Number of continuous variable |
mu_int |
Mean of covariates in the internal trial. All the covariates are simulated from a
multivariate normal distribution. If left |
mu_ext |
Mean of covariates in the external trial. If left |
var |
Variance of covariates. If left |
cov |
Covariance between each pair of covariates. Covariance needs to be provided in
a certain order and users are encouraged to read the example provided in the vignette. If
left |
prob_int |
Probability of binary covariate equalling 1 in the internal trial. If left
|
prob_ext |
Probability of binary covariate equalling 1 in the external trial. If
left |
Details
Categorical variables are created by sampling a continuous variable from the multivariate
normal
distribution (thus respecting the correlation to other covariates specified by cov
)
and then applying a cut point derived from the prob_int
or prob_ext
quantile
of said distribution i.e. for a univariate variable it would be derived as:
binvar <- as.numeric(rnorm(n, mu, sqrt(var)) < qnorm(prob, mu, sqrt(var)))
Please note that this means that the value of mu_int
& mu_ext
has no impact on categorical
covariates and thus can be set to any value.
As an example of how this process works assume n_cat=3
and n_cont=2
. First 5 variables are
sampled from the multivariate normal distribution as specified by mu_int
/mu_ext
, var
&
cov
. Then, the first 3 of these variables are converted to binary based on the probabilities
specified by prob_int
and prob_ext
. This means that that the 2 continuous variables will
take their mean and sd from the last 2 entries in the vectors mu_int
/mu_ext
and var
.
Value
A .covClass
class containing covariate information