Description Usage Arguments Value References See Also Examples
This function checks the parameter inputs to the simulation functions nonnormsys
,
corrsys
, and corrsys2
. 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. Since the parameter input list is extensive and this function does not check
for all possible errors, if simulation gives an error, the user should still check the parameter inputs.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | checkpar(M = NULL, method = c("Fleishman", "Polynomial"),
error_type = c("non_mix", "mix"), means = list(), vars = list(),
skews = list(), skurts = list(), fifths = list(), sixths = list(),
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 = list(), p_zip = list(), pois_eps = list(),
size = list(), prob = list(), mu = list(), p_zinb = list(),
nb_eps = list(), corr.x = list(), corr.yx = list(), corr.e = NULL,
same.var = NULL, subj.var = NULL, int.var = NULL, tint.var = NULL,
betas.0 = NULL, betas = list(), betas.subj = list(),
betas.int = list(), betas.t = NULL, betas.tint = list(),
rand.int = c("none", "non_mix", "mix"), rand.tsl = c("none", "non_mix",
"mix"), rand.var = NULL, corr.u = list(), quiet = FALSE)
|
M |
the number of dependent variables Y (outcomes); equivalently, the number of equations in the system |
method |
the PMT method used to generate all continuous variables, including independent variables (covariates), error terms, and random effects; "Fleishman" uses Fleishman's third-order polynomial transformation and "Polynomial" uses Headrick's fifth-order transformation |
error_type |
"non_mix" if all error terms have continuous non-mixture distributions, "mix" if all error terms have continuous mixture distributions |
means |
if no random effects, a list of length if there are random effects, a list of length |
vars |
a list of same length and order as |
skews |
if no random effects, a list of length if there are random effects, a list of length |
skurts |
a list of same length and order as |
fifths |
a list of same length and order as |
sixths |
a list of same length and order as |
Six |
a list of length
keep |
mix_pis |
list of length
|
mix_mus |
list of same length and order as
|
mix_sigmas |
list of same length and order as
|
mix_skews |
list of same length and order as
|
mix_skurts |
list of same length and order as
|
mix_fifths |
list of same length and order as
|
mix_sixths |
list of same length and order as
|
mix_Six |
a list of same length and order as p-th component of q-th component of |
marginal |
a list of length |
support |
a list of length |
lam |
list of length |
p_zip |
a list of vectors of probabilities of structural zeros (not including zeros from the Poisson distribution) for the
zero-inflated Poisson variables (see |
pois_eps |
list of length |
size |
list of length |
prob |
list of length |
mu |
list of length |
p_zinb |
a vector of probabilities of structural zeros (not including zeros from the NB distribution) for the zero-inflated NB variables
(see |
nb_eps |
list of length |
corr.x |
list of length |
corr.yx |
input for |
corr.e |
correlation matrix for continuous non-mixture or components of mixture error terms |
same.var |
either a vector or a matrix; if a vector, |
subj.var |
matrix where 1st column is outcome index ( |
int.var |
matrix where 1st column is outcome index ( |
tint.var |
matrix where 1st column is outcome index ( |
betas.0 |
vector of length |
betas |
list of length |
betas.subj |
list of length |
betas.int |
list of length |
betas.t |
vector of length |
betas.tint |
list of length |
rand.int |
"none" (default) if no random intercept term for all outcomes, "non_mix" if all random intercepts have a continuous
non-mixture distribution, "mix" if all random intercepts have a continuous mixture distribution;
also can be a vector of length |
rand.tsl |
"none" (default) if no random slope for time for all outcomes, "non_mix" if all random time slopes have a
continuous non-mixture distribution, "mix" if all random time slopes have a continuous mixture distribution; also can
be a vector of length |
rand.var |
matrix where 1st column is outcome index ( |
corr.u |
if the random effects are the same variables across equations, a matrix of correlations for U;
if the random effects are different variables across equations, a list of length correlations are specified in terms of components of mixture variables (if present);
order is 1st random intercept (if |
quiet |
if FALSE prints messages, if TRUE suppresses messages |
TRUE if all inputs are correct, else it will stop with a correction message
Headrick TC, Beasley TM (2004). A Method for Simulating Correlated Non-Normal Systems of Linear Statistical Equations. Communications in Statistics - Simulation and Computation, 33(1). doi: 10.1081/SAC-120028431
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 35 36 37 38 39 | # Example: system of three equations for 2 independent variables, where each
# error term has unit variance, from Headrick & Beasley (2002)
# Y_1 = beta_10 + beta_11 * X_11 + beta_12 * X_12 + sigma_1 * e_1
# Y_2 = beta_20 + beta_21 * X_21 + beta_22 * X_22 + sigma_2 * e_2
# Y_3 = beta_30 + beta_31 * X_31 + beta_32 * X_32 + sigma_3 * e_3
# X_11 = X_21 = X_31 = Exponential(2)
# X_12 = X_22 = X_32 = Laplace(0, 1)
# e_1 = e_2 = e_3 = Cauchy(0, 1)
M <- 3
Stcum1 <- calc_theory("Exponential", 2)
Stcum2 <- calc_theory("Laplace", c(0, 1))
Stcum3 <- c(0, 1, 0, 25, 0, 1500) # taken from paper
means <- lapply(seq_len(M), function(x) c(0, 0, 0))
vars <- lapply(seq_len(M), function(x) c(1, 1, 1))
skews <- lapply(seq_len(M), function(x) c(Stcum1[3], Stcum2[3], Stcum3[3]))
skurts <- lapply(seq_len(M), function(x) c(Stcum1[4], Stcum2[4], Stcum3[4]))
fifths <- lapply(seq_len(M), function(x) c(Stcum1[5], Stcum2[5], Stcum3[5]))
sixths <- lapply(seq_len(M), function(x) c(Stcum1[6], Stcum2[6], Stcum3[6]))
corr.yx <- list(matrix(c(0.4, 0.4), 1), matrix(c(0.5, 0.5), 1),
matrix(c(0.6, 0.6), 1))
corr.x <- list()
corr.x[[1]] <- corr.x[[2]] <- corr.x[[3]] <- list()
corr.x[[1]][[1]] <- matrix(c(1, 0.1, 0.1, 1), 2, 2)
corr.x[[1]][[2]] <- matrix(c(0.1974318, 0.1859656, 0.1879483, 0.1858601),
2, 2, byrow = TRUE)
corr.x[[1]][[3]] <- matrix(c(0.2873190, 0.2589830, 0.2682057, 0.2589542),
2, 2, byrow = TRUE)
corr.x[[2]][[1]] <- t(corr.x[[1]][[2]])
corr.x[[2]][[2]] <- matrix(c(1, 0.35, 0.35, 1), 2, 2)
corr.x[[2]][[3]] <- matrix(c(0.5723303, 0.4883054, 0.5004441, 0.4841808),
2, 2, byrow = TRUE)
corr.x[[3]][[1]] <- t(corr.x[[1]][[3]])
corr.x[[3]][[2]] <- t(corr.x[[2]][[3]])
corr.x[[3]][[3]] <- matrix(c(1, 0.7, 0.7, 1), 2, 2)
corr.e <- matrix(0.4, nrow = 3, ncol = 3)
diag(corr.e) <- 1
checkpar(M, "Polynomial", "non_mix", means, vars, skews,
skurts, fifths, sixths, corr.x = corr.x, corr.yx = corr.yx,
corr.e = corr.e, quiet = TRUE)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.