# rmvbin: Multivariate Binary Random Variates In bindata: Generation of Artificial Binary Data

## Description

Creates correlated multivariate binary random variables by thresholding a normal distribution. The correlations of the components can be specified either as common probabilities, correlation matrix of the binary distribution, or covariance matrix of the normal distribution.

## Usage

 ```1 2 3 4``` ```rmvbin(n, margprob, commonprob=diag(margprob), bincorr=diag(length(margprob)), sigma=diag(length(margprob)), colnames=NULL, simulvals=NULL) ```

## Arguments

 `n` number of observations. `margprob` margin probabilities that the components are 1. `commonprob` matrix of probabilities that components `i` and `j` are simultaneously 1. `bincorr` matrix of binary correlations. `sigma` covariance matrix for the normal distribution. `colnames` vector of column names for the resulting observation matrix. `simulvals` result from `simul.commonprob`, a default data array is automatically loaded if this argument is omitted.

## Details

Only one of the arguments `commonprob`, `bincorr` and `sigma` may be specified. Default are uncorrelated components.

`n` samples from a multivariate normal distribution with mean and variance chosen in order to get the desired margin and common probabilities are sampled. Negative values are converted to 0, positive values to 1.

Friedrich Leisch

## References

Friedrich Leisch, Andreas Weingessel and Kurt Hornik (1998). On the generation of correlated artificial binary data. Working Paper Series, SFB “Adaptive Information Systems and Modelling in Economics and Management Science”, Vienna University of Economics.

`commonprob2sigma`, `check.commonprob`, `simul.commonprob`

## Examples

 ``` 1 2 3 4 5 6 7 8 9 10 11``` ```## uncorrelated columns: rmvbin(10, margprob=c(0.3,0.9)) ## correlated columns m <- cbind(c(1/2,1/5,1/6),c(1/5,1/2,1/6),c(1/6,1/6,1/2)) rmvbin(10,commonprob=m) ## same as the second example, but faster if the same probabilities are ## used repeatedly (commonprob2sigma rather slow) sigma <- commonprob2sigma(m) rmvbin(10,margprob=diag(m),sigma=sigma) ```

### Example output

```      [,1] [,2]
[1,]    0    1
[2,]    1    1
[3,]    0    0
[4,]    0    1
[5,]    0    1
[6,]    1    1
[7,]    0    1
[8,]    1    1
[9,]    0    1
[10,]    1    1
[,1] [,2] [,3]
[1,]    1    0    1
[2,]    0    0    1
[3,]    1    0    0
[4,]    1    1    0
[5,]    0    1    1
[6,]    1    0    1
[7,]    1    0    1
[8,]    0    0    1
[9,]    0    1    1
[10,]    0    1    1
[,1] [,2] [,3]
[1,]    1    0    1
[2,]    0    1    1
[3,]    1    0    0
[4,]    0    1    1
[5,]    0    1    1
[6,]    1    1    0
[7,]    1    0    0
[8,]    0    1    1
[9,]    1    0    0
[10,]    1    0    1
```

bindata documentation built on Jan. 29, 2021, 5:06 p.m.