Takes simulation conditions as input, exports power.
sim_pow_nested(
fixed,
random,
fixed_param,
random_param = list(),
cov_param,
n,
p,
error_var,
with_err_gen,
arima = FALSE,
data_str,
cor_vars = NULL,
fact_vars = list(NULL),
unbal = FALSE,
unbal_design = NULL,
lvl1_err_params = NULL,
arima_mod = list(NULL),
contrasts = NULL,
homogeneity = TRUE,
heterogeneity_var = NULL,
cross_class_params = NULL,
knot_args = list(NULL),
missing = FALSE,
missing_args = list(NULL),
pow_param = NULL,
alpha,
pow_dist = c("z", "t"),
pow_tail = c(1, 2),
lme4_fit_mod = NULL,
nlme_fit_mod = NULL,
arima_fit_mod = NULL,
general_mod = NULL,
general_extract = NULL,
...
)
One sided formula for fixed effects in the simulation. To suppress intercept add -1 to formula.
One sided formula for random effects in the simulation. Must be a subset of fixed.
Fixed effect parameter values (i.e. beta weights). Must be same length as fixed.
A list of named elements that must contain:
random_var: variance of random parameters,
rand_gen: Name of simulation function for random effects.
Optional elements are:
ther: Theorectial mean and variance from rand_gen,
ther_sim: Simulate mean/variance for standardization purposes,
cor_vars: Correlation between random effects,
...: Additional parameters needed for rand_gen function.
List of arguments to pass to the continuous generating function, must be the same order as the variables specified in fixed. This list does not include intercept, time, factors, or interactions. Required arguments include:
dist_fun: This is a quoted R distribution function.
var_type: This is the level of variable to generate. Must be 'level1' or 'level2'. Must be same order as fixed formula above.
Optional arguments to the distribution functions are in a nested list, see the examples or vignettes for example code.
Cluster sample size.
Within cluster sample size.
Scalar of error variance.
Simulated within cluster error distribution. Must be a quoted 'r' distribution function.
TRUE/FALSE flag indicating whether residuals should
be correlated. If TRUE, must specify a valid model to pass to
arima.sim via the arima_mod argument.
See arima.sim
for examples.
Type of data. Must be "cross", "long", or "single".
A vector of correlations between variables.
A nested list of factor, categorical, or ordinal variable specification, each list must include:
numlevels: Number of levels for ordinal or factor variables.
var_type: Must be 'level1' or 'level2'.
Optional arguments include:
replace
prob
value.labels
See also sample
for use of these optional arguments.
A vector of sample sizes for the number of observations for each level 2 cluster. Must have same length as level two sample size n. Alternative specification can be TRUE, which uses additional argument, unbal_design.
When unbal = TRUE, this specifies the design for unbalanced simulation in one of two ways. It can represent the minimum and maximum sample size within a cluster via a named list. This will be drawn from a random uniform distribution with min and max specified. Secondly, the sample sizes within each cluster can be specified. This takes the form of a vector that must have the same length as the level two sample size.
Additional parameters passed as a list on to the level one error generating function
A list indicating the ARIMA model to pass to arima.sim.
See arima.sim
for examples.
An optional list that specifies the contrasts to be used
for factor variables (i.e. those variables with .f or .c).
See contrasts
for more detail.
Either TRUE (default) indicating homogeneity of variance assumption is assumed or FALSE to indicate desire to generate heterogeneity of variance.
Variable name as a character string to use for heterogeneity of variance simulation.
A list of named parameters when cross classified data structures are desired. Must include the following arguments:
num_ids: The number of cross classified clusters. These are in addition to the typical cluster ids
random_param: This argument is a list of arguments passed to
sim_rand_eff
. These must include:
random_var: The variance of the cross classified random effect
rand_gen: The random generating function used to generate the cross classified random effect.
Optional elements are:
ther: Theorectial mean and variance from rand_gen,
ther_sim: Simulate mean/variance for standardization purposes,
cor_vars: Correlation between random effects,
...: Additional parameters needed for rand_gen function.
A nested list of named knot arguments. See sim_knot
for more details. Arguments must include:
var
knot_locations
TRUE/FALSE flag indicating whether missing data should be simulated.
Additional missing arguments to pass to the missing_data
function. See missing_data
for examples.
Name of variable to calculate power for, must be a name from fixed.
What should the per test alpha rate be used for the hypothesis testing.
Which distribution should be used when testing hypothesis test, z or t?
One-tailed or two-tailed test?
Valid lme4 syntax to be used for model fitting.
Valid nlme syntax to be used for model fitting. This should be specified as a named list with fixed and random components.
Valid nlme syntax for fitting serial correlation structures.
See corStruct
for help. This must be specified to
include serial correlation.
Valid model syntax. This syntax can be from any R package. By default, broom is used to extract model result information. Note, package must be defined or loaded prior to running the sim_pow function.
A valid function to extract model results if general_mod argument is used. This argument is primarily used if extracting model results is not possibly using the broom package. If this is left NULL (default), broom is used to collect model results.
Not currently used.
Power function to compute power for a regression term for the linear
mixed model. This function would need to be replicated to make any statement
about power. Use sim_pow
as a convenient wrapper for this.
sim_pow
for a wrapper to replicate.