validpar {SimCorrMix} | R Documentation |
Parameter Check for Simulation or Correlation Validation Functions
Description
This function checks the parameter inputs to the simulation functions contmixvar1
,
corrvar
, and corrvar2
and to the correlation validation functions
validcorr
and validcorr2
. It should be used prior to execution of these
functions to ensure all inputs are of the correct format. Those functions do not contain parameter checks in order to decrease
simulation time. This would be important if the user is running several simulation repetitions so that the inputs only have to
be checked once. Note that the inputs do not include all of the inputs to the simulation functions. See the appropriate function
documentation for more details about parameter inputs.
Usage
validpar(k_cat = 0, k_cont = 0, k_mix = 0, k_pois = 0, k_nb = 0,
method = c("Fleishman", "Polynomial"), means = NULL, vars = NULL,
skews = NULL, skurts = NULL, fifths = NULL, sixths = NULL,
Six = list(), mix_pis = list(), mix_mus = list(), mix_sigmas = list(),
mix_skews = list(), mix_skurts = list(), mix_fifths = list(),
mix_sixths = list(), mix_Six = list(), 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, Sigma = NULL, cstart = list(), quiet = FALSE)
Arguments
k_cat |
the number of ordinal (r >= 2 categories) variables (default = 0) |
k_cont |
the number of continuous non-mixture variables (default = 0) |
k_mix |
the number of continuous mixture variables (default = 0) |
k_pois |
the number of regular Poisson and zero-inflated Poisson variables (default = 0) |
k_nb |
the number of regular Negative Binomial and zero-inflated Negative Binomial variables (default = 0) |
method |
the method used to generate the |
means |
a vector of means for the |
vars |
a vector of variances for the |
skews |
a vector of skewness values for the |
skurts |
a vector of standardized kurtoses (kurtosis - 3, so that normal variables have a value of 0)
for the |
fifths |
a vector of standardized fifth cumulants for the |
sixths |
a vector of standardized sixth cumulants for the |
Six |
a list of vectors of sixth cumulant correction values for the |
mix_pis |
a vector if using |
mix_mus |
a vector if using |
mix_sigmas |
a vector if using |
mix_skews |
a vector if using |
mix_skurts |
a vector if using |
mix_fifths |
a vector if using |
mix_sixths |
a vector if using |
mix_Six |
if using |
marginal |
a list of length equal to |
support |
a list of length equal to |
lam |
a vector of lambda (mean > 0) constants for the 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 |
Sigma |
an intermediate correlation matrix to use if the user wants to provide one, else it is calculated within by
|
cstart |
a list of length equal to |
quiet |
if FALSE prints messages, if TRUE suppresses message printing |
Value
TRUE if all inputs are correct, else it will stop with a correction message
See Also
contmixvar1
, corrvar
, corrvar2
,
validcorr
, validcorr2
Examples
validpar(k_cat = 1, k_cont = 1, method = "Polynomial", means = 0,
vars = 1, skews = 0, skurts = 0, fifths = 0, sixths = 0,
marginal = list(c(1/3, 2/3)), rho = matrix(c(1, 0.4, 0.4, 1), 2, 2),
quiet = TRUE)
## Not run:
# 2 continuous mixture, 1 binary, 1 zero-inflated Poisson, and
# 1 zero-inflated NB variable
# Mixture variables: Normal mixture with 2 components;
# mixture of Logistic(0, 1), Chisq(4), Beta(4, 1.5)
# Find cumulants of components of 2nd mixture variable
L <- calc_theory("Logistic", c(0, 1))
C <- calc_theory("Chisq", 4)
B <- calc_theory("Beta", c(4, 1.5))
skews <- skurts <- fifths <- sixths <- NULL
Six <- list()
mix_pis <- list(c(0.4, 0.6), c(0.3, 0.2, 0.5))
mix_mus <- list(c(-2, 2), c(L[1], C[1], B[1]))
mix_sigmas <- list(c(1, 1), c(L[2], C[2], B[2]))
mix_skews <- list(rep(0, 2), c(L[3], C[3], B[3]))
mix_skurts <- list(rep(0, 2), c(L[4], C[4], B[4]))
mix_fifths <- list(rep(0, 2), c(L[5], C[5], B[5]))
mix_sixths <- list(rep(0, 2), c(L[6], C[6], B[6]))
mix_Six <- list(list(NULL, NULL), list(1.75, NULL, 0.03))
Nstcum <- calc_mixmoments(mix_pis[[1]], mix_mus[[1]], mix_sigmas[[1]],
mix_skews[[1]], mix_skurts[[1]], mix_fifths[[1]], mix_sixths[[1]])
Mstcum <- calc_mixmoments(mix_pis[[2]], mix_mus[[2]], mix_sigmas[[2]],
mix_skews[[2]], mix_skurts[[2]], mix_fifths[[2]], mix_sixths[[2]])
means <- c(Nstcum[1], Mstcum[1])
vars <- c(Nstcum[2]^2, Mstcum[2]^2)
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 <- 0
k_mix <- 2
Rey <- matrix(0.39, 8, 8)
diag(Rey) <- 1
rownames(Rey) <- colnames(Rey) <- c("O1", "M1_1", "M1_2", "M2_1", "M2_2",
"M2_3", "P1", "NB1")
# set correlation between components of the same mixture variable to 0
Rey["M1_1", "M1_2"] <- Rey["M1_2", "M1_1"] <- 0
Rey["M2_1", "M2_2"] <- Rey["M2_2", "M2_1"] <- Rey["M2_1", "M2_3"] <- 0
Rey["M2_3", "M2_1"] <- Rey["M2_2", "M2_3"] <- Rey["M2_3", "M2_2"] <- 0
# use before contmixvar1 with 1st mixture variable:
# change mix_pis to not sum to 1
check1 <- validpar(k_mix = 1, method = "Polynomial", means = Nstcum[1],
vars = Nstcum[2]^2, mix_pis = C(0.4, 0.5), mix_mus = mix_mus[[1]],
mix_sigmas = mix_sigmas[[1]], mix_skews = mix_skews[[1]],
mix_skurts = mix_skurts[[1]], mix_fifths = mix_fifths[[1]],
mix_sixths = mix_sixths[[1]])
# use before validcorr: should return TRUE
check2 <- validpar(k_cat, k_cont, k_mix, k_pois, k_nb, "Polynomial", means,
vars, skews, skurts, fifths, sixths, Six, mix_pis, mix_mus, mix_sigmas,
mix_skews, mix_skurts, mix_fifths, mix_sixths, mix_Six, marginal, support,
lam, p_zip, size, prob, mu = NULL, p_zinb, rho = Rey)
## End(Not run)