error_vars: Generate Variables for Error Loop

Description Usage Arguments Value References See Also

View source: R/error_vars.R

Description

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.

Usage

1
2
3
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)

Arguments

marginal

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)

support

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

method

the method used to generate the continuous variables. "Fleishman" uses a third-order polynomial transformation and "Polynomial" uses Headrick's fifth-order transformation.

means

a vector of means for the continuous variables

vars

a vector of variances

constants

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

lam

a vector of lambda (> 0) constants for the Poisson variables (see Poisson)

size

a vector of size parameters for the Negative Binomial variables (see NegBinomial)

prob

a vector of success probability parameters

mu

a vector of mean parameters (*Note: either prob or mu should be supplied for all Negative Binomial variables, not a mixture)

Sigma

the 2 x 2 intermediate correlation matrix generated by error_loop

rho_calc

the 2 x 2 final correlation matrix calculated in error_loop

q

the row index of the 1st variable

r

the column index of the 2nd variable

k_cat

the number of ordinal (r >= 2 categories) variables

k_cont

the number of continuous variables

k_pois

the number of Poisson variables

k_nb

the number of Negative Binomial variables

Y_cat

the ordinal variables generated from error_loop

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

n

the sample size

seed

the seed value for random number generation

Value

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

References

Please see references for error_loop.

See Also

ordcont, rcorrvar, rcorrvar2, error_loop


SimMultiCorrData documentation built on May 2, 2019, 9:50 a.m.