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 corrvar2
. The k_cont
includes regular continuous variables
and components of continuous mixture variables. The ordering of the variables must be
ordinal, continuous non-mixture, components of continuous mixture variables, regular Poisson, zero-inflated Poisson, regular Negative
Binomial (NB), and zero-inflated 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 positive-definite 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
corrvar2
, 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 corrvar2
.
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 intercorr
.
1 2 3 4 5 6 | intercorr2(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, pois_eps = 0.0001,
nb_eps = 0.0001, rho = NULL, epsilon = 0.001, maxit = 1000,
quiet = FALSE)
|
k_cat |
the number of ordinal (r >= 2 categories) variables (default = 0) |
k_cont |
the number of continuous non-mixture variables and components of continuous mixture variables (default = 0) |
k_pois |
the number of regular and zero-inflated Poisson variables (default = 0) |
k_nb |
the number of regular and zero-inflated 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 zero-inflated Poisson variables (see |
p_zip |
a vector of probabilities of structural zeros (not including zeros from the Poisson distribution) for the
zero-inflated 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 zero-inflated NB variables
(see |
pois_eps |
a vector of length |
nb_eps |
a vector of length |
rho |
the target correlation matrix which must be ordered
1st ordinal, 2nd continuous non-mixture, 3rd components of continuous mixtures, 4th regular Poisson, 5th zero-inflated Poisson,
6th regular NB, 7th zero-inflated NB; note that |
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 |
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 34 | Sigma1 <- intercorr2(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 zero-inflated Poisson, and
# 1 zero-inflated NB variable
# The defaults of pois_eps <- nb_eps <- 0.0001 are used.
# 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 <- intercorr2(k_cat, k_cont, k_pois, k_nb, "Polynomial", constants,
marginal, support, lam, p_zip, size, prob, mu = NULL, p_zinb, rho = Rey)
## End(Not run)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.