This function simulates the continuous, ordinal (r >= 2 categories), Poisson, or Negative Binomial variables
used in error_loop
. It is called in each iteration, regenerates all variables, and calculates the
resulting correlation matrix.
This function would not ordinarily be called directly by the user.
error_vars(marginal, support, method, means, vars, constants, lam, size, prob,
mu, Sigma, rho_calc, q, r, k_cat, k_cont, k_pois, k_nb, Y_cat, Y, Yb, Y_pois,
Y_nb, n, seed)
a list of length equal k_cat
; the i-th element is a vector of the cumulative
probabilities defining the marginal distribution of the i-th variable;
if the variable can take r values, the vector will contain r - 1 probabilities (the r-th is assumed to be 1)
a list of length equal k_cat
; the i-th element is a vector of containing the r
ordered support values; if not provided, the default is for the i-th element to be the vector 1, ..., r
the method used to generate the continuous variables. "Fleishman" uses a third-order polynomial transformation and "Polynomial" uses Headrick's fifth-order transformation.
a vector of means for the continuous variables
a vector of variances
a matrix with k_cont
rows, each a vector of constants c0, c1, c2, c3 (if method
= "Fleishman") or
c0, c1, c2, c3, c4, c5 (if method
= "Polynomial"), like that returned by
find_constants
a vector of lambda (> 0) constants for the Poisson variables (see dpois
)
a vector of size parameters for the Negative Binomial variables (see dnbinom
)
a vector of success probability parameters
a vector of mean parameters (*Note: either prob
or mu
should be supplied for all Negative Binomial variables,
not a mixture)
the 2 x 2 intermediate correlation matrix generated by error_loop
the 2 x 2 final correlation matrix calculated in error_loop
the row index of the 1st variable
the column index of the 2nd variable
the number of ordinal (r >= 2 categories) variables
the number of continuous variables
the number of Poisson variables
the number of Negative Binomial variables
the ordinal variables generated from error_loop
the continuous (mean 0, variance 1) variables
the continuous variables with desired mean and variance
the Poisson variables
the Negative Binomial variables
the sample size
the seed value for random number generation
A list with the following components:
Sigma
the intermediate MVN correlation matrix
rho_calc
the calculated final correlation matrix generated from Sigma
Y_cat
the ordinal variables
Y
the continuous (mean 0, variance 1) variables
Yb
the continuous variables with desired mean and variance
Y_pois
the Poisson variables
Y_nb
the Negative Binomial variables
Please see references for error_loop
.