Description Usage Arguments Value References See Also Examples
This function calculates a k x k
intermediate matrix of correlations, where k = k_cat + k_cont +
k_pois + k_nb
, to be used in simulating variables with corrvar
. The k_cont
includes regular continuous variables
and components of continuous mixture variables. The ordering of the variables must be
ordinal, continuous nonmixture, components of continuous mixture variables, regular Poisson, zeroinflated Poisson, regular Negative
Binomial (NB), and zeroinflated NB (note that it is possible for k_cat
, k_cont
, k_pois
, and/or k_nb
to be 0).
There are no parameter input checks in order to decrease simulation time. All inputs should be checked prior to simulation with
validpar
. There is a message given if the calculated
intermediate correlation matrix Sigma
is not positivedefinite because it may not be possible to find a MVN correlation
matrix that will produce the desired marginal distributions. This function is called by the simulation function
corrvar
, and would only be used separately if the user wants to first find the intermediate correlation matrix.
This matrix Sigma
can be used as an input to corrvar
.
Please see the Comparison of Correlation Methods 1 and 2 vignette for information about calculations by variable pair type and the differences between
this function and intercorr2
.
1 2 3 4 5 6  intercorr(k_cat = 0, k_cont = 0, k_pois = 0, k_nb = 0,
method = c("Fleishman", "Polynomial"), constants = NULL,
marginal = list(), support = list(), lam = NULL, p_zip = 0,
size = NULL, prob = NULL, mu = NULL, p_zinb = 0, rho = NULL,
seed = 1234, epsilon = 0.001, maxit = 1000, nrand = 100000,
quiet = FALSE)

k_cat 
the number of ordinal (r >= 2 categories) variables (default = 0) 
k_cont 
the number of continuous nonmixture variables and components of continuous mixture variables (default = 0) 
k_pois 
the number of regular and zeroinflated Poisson variables (default = 0) 
k_nb 
the number of regular and zeroinflated Negative Binomial variables (default = 0) 
method 
the method used to generate the 
constants 
a matrix with 
marginal 
a list of length equal to 
support 
a list of length equal to 
lam 
a vector of lambda (mean > 0) constants for the regular and zeroinflated Poisson variables (see 
p_zip 
a vector of probabilities of structural zeros (not including zeros from the Poisson distribution) for the
zeroinflated Poisson variables (see 
size 
a vector of size parameters for the Negative Binomial variables (see 
prob 
a vector of success probability parameters for the NB variables; order the same as in 
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 zeroinflated NB variables
(see 
rho 
the target correlation matrix which must be ordered
1st ordinal, 2nd continuous nonmixture, 3rd components of continuous mixtures, 4th regular Poisson, 5th zeroinflated Poisson,
6th regular NB, 7th zeroinflated NB; note that 
seed 
the seed value for random number generation (default = 1234) 
epsilon 
the maximum acceptable error between the pairwise correlations (default = 0.001)
in the calculation of ordinal intermediate correlations with 
maxit 
the maximum number of iterations to use (default = 1000) in the calculation of ordinal
intermediate correlations with 
nrand 
the number of random numbers to generate in calculating intermediate correlations (default = 10000) 
quiet 
if FALSE prints simulation messages, if TRUE suppresses message printing 
the intermediate MVN correlation matrix
Please see references for SimCorrMix
.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33  Sigma1 < intercorr(k_cat = 1, k_cont = 1, method = "Polynomial",
constants = matrix(c(0, 1, 0, 0, 0, 0), 1, 6), marginal = list(0.3),
support = list(c(0, 1)), rho = matrix(c(1, 0.4, 0.4, 1), 2, 2),
quiet = TRUE)
## Not run:
# 1 continuous mixture, 1 binary, 1 zeroinflated Poisson, and
# 1 zeroinflated NB variable
seed < 1234
# Mixture of N(2, 1) and N(2, 1)
constants < rbind(c(0, 1, 0, 0, 0, 0), c(0, 1, 0, 0, 0, 0))
marginal < list(0.3)
support < list(c(0, 1))
lam < 0.5
p_zip < 0.1
size < 2
prob < 0.75
p_zinb < 0.2
k_cat < k_pois < k_nb < 1
k_cont < 2
Rey < matrix(0.35, 5, 5)
diag(Rey) < 1
rownames(Rey) < colnames(Rey) < c("O1", "M1_1", "M1_2", "P1", "NB1")
# set correlation between components of the same mixture variable to 0
Rey["M1_1", "M1_2"] < Rey["M1_2", "M1_1"] < 0
Sigma2 < intercorr(k_cat, k_cont, k_pois, k_nb, "Polynomial", constants,
marginal, support, lam, p_zip, size, prob, mu = NULL, p_zinb, Rey, seed)
## End(Not run)

Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.