Set up covariates
set_cov.Rd
This function saves the mean, variance and covariance among covariates. For technical details, see the vignette.
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
NULL
, it uses default value 0 for all covariates. If provided one value, this value is used for all covariates- mu_ext
Mean of covariates in the external trial. If left
NULL
, it uses the same mean asmu_int
- var
Variance of covariates. If left
NULL
, it uses default value 0 for all covariates. If provided one value, it uses this value for all covariates- 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
NULL
, it uses default value 0 for all covariates. If provided one value, it uses this value for every pair of covariates- prob_int
Probability of binary covariate equalling 1 in the internal trial. If left
NULL
, it uses default value 0.5 for all covariates. If provided one value, it uses this value for all covariates- prob_ext
Probability of binary covariate equalling 1 in the external trial. If left
NULL
, it uses the same probability asprob_int
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
.