intercorr_nb {SimCorrMix} | R Documentation |
Calculate Intermediate MVN Correlation for Negative Binomial Variables: Correlation Method 1
Description
This function calculates a k_nb x k_nb
intermediate matrix of correlations for the Negative Binomial variables by
extending the method of Yahav & Shmueli (2012, doi: 10.1002/asmb.901). The intermediate correlation between Z1 and Z2 (the
standard normal variables used to generate the Negative Binomial variables Y1 and Y2 via the inverse CDF method) is
calculated using a logarithmic transformation of the target correlation. First, the upper and lower Frechet-Hoeffding bounds
(mincor, maxcor) on \rho_{Y1, Y2}
are simulated. Then the intermediate correlation is found as follows:
\rho_{Z1, Z2} = \frac{1}{b} * log(\frac{\rho_{Y1, Y2} - c}{a}),
where a = -(maxcor * mincor)/(maxcor + mincor)
, b = log((maxcor + a)/a)
, and c = -a
.
The function adapts code from Amatya & Demirtas' (2016) package PoisNor-package
by:
1) allowing specifications for the number of random variates and the seed for reproducibility
2) providing the following checks: if Sigma_(Z1, Z2)
> 1, Sigma_(Z1, Z2)
is set to 1; if Sigma_(Z1, Z2)
< -1,
Sigma_(Z1, Z2)
is set to -1
3) simulating regular and zero-inflated Negative Binomial variables.
The function is used in intercorr
and corrvar
and would not ordinarily be called by the user.
Usage
intercorr_nb(rho_nb = NULL, size = NULL, mu = NULL, p_zinb = 0,
nrand = 100000, seed = 1234)
Arguments
rho_nb |
a |
size |
a vector of size parameters for the Negative Binomial variables (see |
mu |
a vector of mean parameters for the NB variables (*Note: either |
p_zinb |
a vector of probabilities of structural zeros (not including zeros from the NB distribution) for the zero-inflated NB variables
(see |
nrand |
the number of random numbers to generate in calculating the bound (default = 10000) |
seed |
the seed used in random number generation (default = 1234) |
Value
the k_nb x k_nb
intermediate correlation matrix for the Negative Binomial variables
References
Please see references for intercorr_pois
.
See Also
intercorr_pois
, intercorr_pois_nb
,
intercorr
, corrvar