Skip to contents

Function to run the simulation for estimating the type-1 error or the statistical power given a set of parameters.

Usage

run_simulation(
  niter,
  maxt = NULL,
  type = c("power", "type1"),
  method = c("mclust", "kmeans"),
  cmax = 5,
  dmin = 0,
  dmax = NULL,
  udata = NULL,
  progress = TRUE,
  updateProgress = NULL,
  ...
)

Arguments

niter

number of iterations.

maxt

the maximum time. If the number of iterations is not finished within the maximum time the simulations ends.

type

character indicating the simulation type. One of type1 or power.

method

character indicating the method to use for estimating the number of cluster. One of mclust or kmeans. mclust will call the model_based_clust() function and kmeans the kmeans_clust() function.

cmax

the maximum number of clusters to test. Default to 5. Be careful that increasing cmax will significantly increase the computation time.

dmin

the lower bound for the range of effect sizes (in ~Cohen's d like scale).

dmax

the lower bound for the range of effect sizes (in ~Cohen's d like scale). If not specified, dmax takes the value of dmin thus the effect size is the same for all indicators.

udata

a list. The output of the prep_user_data() function. Default to NULL. If udata is not NULL all the parameters passed to ... are ignored.

progress

logical indicating whether a progress bar (using the progress package) should be displayed.

updateProgress

a function used fo displaying a progress bar in the Shiny app. Default to NULL

...

named arguments that will be passed to the sim_clust() function. If udata is null, these parameters are used for the simulation.

Value

a list containing the estimated power or type-1 error, the number of effective iterations, the proportion of iterations with errors, a vector with the estimated number of clusters and a list with all simulation parameters.

Examples

if (FALSE) {
run_simulation(niter = 100, maxt = 50, type = "type1", method = "mclust", 
nclust = 2, n = 100, dmin = 0.5, rmin = 0.5, nind = 3)
}