# maxcount_support: Calculate Maximum Support Value for Count Variables:... In SimCorrMix: Simulation of Correlated Data with Multiple Variable Types Including Continuous and Count Mixture Distributions

## Description

This function calculates the maximum support value for count variables by extending the method of Barbiero & Ferrari (2015, doi: 10.1002/asmb.2072) to include regular and zero-inflated Poisson and Negative Binomial variables. In order for count variables to be treated as ordinal in the calculation of the intermediate MVN correlation matrix, their infinite support must be truncated (made finite). This is done by setting the total cumulative probability equal to 1 - a small user-specified value (`pois_eps` or `nb_eps`). The maximum support value equals the inverse CDF applied to this result. The truncation values may differ for each variable. The function is used in `intercorr2` and `corrvar2` and would not ordinarily be called by the user.

## Usage

 ```1 2 3``` ```maxcount_support(k_pois = 0, k_nb = 0, lam = NULL, p_zip = 0, size = NULL, prob = NULL, mu = NULL, p_zinb = 0, pois_eps = NULL, nb_eps = NULL) ```

## Arguments

 `k_pois` the number of Poisson variables `k_nb` the number of Negative Binomial variables `lam` a vector of lambda (mean > 0) constants for the regular and zero-inflated Poisson variables (see `stats::dpois`); the order should be 1st regular Poisson variables, 2nd zero-inflated Poisson variables `p_zip` a vector of probabilities of structural zeros (not including zeros from the Poisson distribution) for the zero-inflated Poisson variables (see `VGAM::dzipois`); if `p_zip` = 0, Y_{pois} has a regular Poisson distribution; if `p_zip` is in (0, 1), Y_{pois} has a zero-inflated Poisson distribution; if `p_zip` is in `(-(exp(lam) - 1)^(-1), 0)`, Y_{pois} has a zero-deflated Poisson distribution and `p_zip` is not a probability; if `p_zip = -(exp(lam) - 1)^(-1)`, Y_{pois} has a positive-Poisson distribution (see `VGAM::dpospois`); if `length(p_zip) < length(lam)`, the missing values are set to 0 (and ordered 1st) `size` a vector of size parameters for the Negative Binomial variables (see `stats::dnbinom`); the order should be 1st regular NB variables, 2nd zero-inflated NB variables `prob` a vector of success probability parameters for the NB variables; order the same as in `size` `mu` a vector of mean parameters for the NB variables (*Note: either `prob` or `mu` should be supplied for all Negative Binomial variables, not a mixture; default = NULL); order the same as in `size`; for zero-inflated NB this refers to the mean of the NB distribution (see `VGAM::dzinegbin`) `p_zinb` a vector of probabilities of structural zeros (not including zeros from the NB distribution) for the zero-inflated NB variables (see `VGAM::dzinegbin`); if `p_zinb` = 0, Y_{nb} has a regular NB distribution; if `p_zinb` is in `(-prob^size/(1 - prob^size),` `0)`, Y_{nb} has a zero-deflated NB distribution and `p_zinb` is not a probability; if `p_zinb = -prob^size/(1 - prob^size)`, Y_{nb} has a positive-NB distribution (see `VGAM::dposnegbin`); if `length(p_zinb) < length(size)`, the missing values are set to 0 (and ordered 1st) `pois_eps` a vector of length `k_pois` containing total cumulative probability truncation values; if none are provided, the default is 0.0001 for each variable `nb_eps` a vector of length `k_nb` containing total cumulative probability truncation values; if none are provided, the default is 0.0001 for each variable

## Value

a data.frame with `k_pois + k_nb` rows; the column names are:

`Distribution` Poisson or Negative Binomial

`Number` the variable index

`Max` the maximum support value

## References

Barbiero A & Ferrari PA (2015). Simulation of correlated Poisson variables. Applied Stochastic Models in Business and Industry, 31:669-80. doi: 10.1002/asmb.2072.

`intercorr2`, `corrvar2`