Description Usage Arguments Details Value Author(s) Examples
'rcounts.reg' is used to sample high-dimensional correlated count random variables with approximate prespecified Pearson correlation and exact margins.
1 2 3 |
N |
number of observations to be generated per margin (should be at least 500). |
margins |
Vector of margin tokens. Its length T is the dimension. See details. |
mu |
Matrix of dimension N x T of means for the Poisson, GP, ZIP, ZIGP and NB margins. |
phi |
Matrix of dimension N x T of dispersion parameters for the GP, and ZIGP margins. For Poisson, ZIP and NB margins, an 'NA' can be provided. |
omega |
Matrix of dimension N x T of zero-inflation parameters for the ZIP and ZIGP margins. For Poisson, GP and NB margins, an 'NA' can be provided. |
psi |
Matrix of dimension N x T of size parameters for the NB margins. For Poisson, GP, ZIP and ZIGP margins, an 'NA' can be provided. |
corstr |
Correlation structure. Can be 'ex' for exchangeable, 'AR1' for AR(1) and 'unstr' for unstructured. |
corpar |
Correlation parameter. Scalar correlation for 'ex' and 'AR1' and matrix of dimension TxT for 'unstr'. |
conv |
Convergence criterion |
The entries in 'margins' can be specified as 'Poi' for Poisson, 'GP' for generalized Poisson, 'ZIP' for zero-inflated Poisson, 'ZIGP' for zero-inflated generalized Poisson and 'NB' for negative-binomial.
NOTE: there is a tradeoff between too small N (decreasing accuracy of the resulting correlation) and too high N (dramatically increasing computation time).
The function will return a matrix of counts of dimension N x T.
Vinzenz Erhardt
1 2 3 4 5 6 7 8 9 10 11 12 | N <- 500
# bivariate example
margins <- c("ZIGP","GP")
mu <- matrix(runif(N*2,10,20),N,2)
phi <- matrix(runif(N*2,1,3),N,2)
omega <- matrix(c(runif(N,0,.3),rep(NA,N)),N,2)
corstr <- "ex"
corpar <- .5
Y <- rcounts.reg(N=N, margins=margins, mu=mu, phi=phi, omega=omega,
corstr=corstr, corpar=corpar)
cor(Y)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.