cBern {CorBin} | R Documentation |
The main function of our package, through which we can simulate correlated binary data under different settings.
cBern(n, p, rho, type, k = NULL)
n |
number of observations |
p |
the vector of marginal probabilities with dimension m |
rho |
For the first three types, rho is either a non-negative value indecating the shared correlation coefficient or and m-1 vector indicating the correlation coefficients between adjacent variables. For the general case, rho should be a list, the i-th element of which specifies the coefficients on the i-th minor diagnal. |
type |
including 4 types. type="exchange" type="DCP" type="1-dependent" type="General" |
k |
(for 'General' use only). The number of layers setting for k-dependent structure. k=m-1 for the general case. |
an n*p matrix of binary data
Jiang, W., Song, S., Hou, L. and Zhao, H. A set of efficient methods to generate high-dimensional binary data with specified correlation structures. The American Statistician. DOI:10.1080/00031305.2020.1816213
X <- cBern(10, rep(0.5,3), 0.5, type="exchange") X <- cBern(10, rep(0.5,3), c(0.2,0.2), type="DCP") X <- cBern(5, c(0.4,0.5,0.6), c(0.2,0.3), type="1-dependent") rho <- list() rho[[1]] <- c(0.2,0.3) rho[[2]] <- 0.1 X <- cBern(2, c(0.7,0.8,0.9),rho=rho,type="General", k=2)