This function saves the mean, variance and covariance among covariates. For technical details, see the vignette.
set_cov(n_cat, n_cont, mu_int, mu_ext, var, cov, prob_int, prob_ext)A .covClass class containing covariate information
Number of binary variable. See details
Number of continuous variable
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
Mean of covariates in the external trial. If left NULL, it uses the same
mean as mu_int
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
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
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
Probability of binary covariate equalling 1 in the external trial. If
left NULL, it uses the same probability as prob_int
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.