Skip to contents

Wrapper function for Type 1 and Power simulations

Usage

run_ligof_sims(
  model_no = 1,
  nsim = 1000,
  samp_size = 1000,
  samp = c("srs", "wtd", "strat", "clust", "strcl", "strat2"),
  simtype = c("type1", "power"),
  starting_seed = 16423,
  ncores = parallel::detectCores() - 2,
  pop_Sigma = FALSE,
  Sigma2 = NULL,
  wt = NULL
)

Arguments

model_no

(integer) Choose from 1–5. See pkgdown articles for details.

nsim

(integer) The number of simulations to conduct.

samp_size

(integer) The exact sample size for SRS simulations or stratified sampling; otherwise the average sample size for the other complex sampling methods.

samp

(character) Choose the sampling method for the simulated data. One of srs, wtd, strat, clust or strcl.

simtype

(character) Whether this is a type1 simulation or power simulation.

starting_seed

(integer) The starting random seed.

ncores

(integer) The number of cores to use for parallelisation.

pop_Sigma

(boolean) Should the population value for the multinomial covariance matrix be used, and not estimated?

Sigma2

(for internal testing only) by default calculates (weighted) sample covariance

wt

(character) Character vector indicating the column name of the sampling weights to use. Defaults to NULL.

Value

A list of tibble()s with the output from all_tests().

Examples

if (FALSE) { # \dontrun{
library(tidyverse)
library(lavaan.bingof)
analysis_path <- dirname(rstudioapi::getSourceEditorContext()$path)

# Run all scenarios described in manuscript
for (sim_type in c("type1", "power")) {
  for (samp_method in c("srs", "strat", "clust", "strcl")) {
    for (the_samp_size in c(500, 1000, 2000, 3000)) {
      for (mod_no in 1:5) {
        sim_name <- paste0(samp_method, mod_no, "_n", the_samp_size, "_",
                           sim_type)
        cat("[", as.character(Sys.time()), "]", "Now running simulation",
            sim_name, "\n")
        sim <- run_ligof_sims(mod_no, samp_size = the_samp_size,
                              samp = samp_method, simtype = sim_type)
        invisible(list2env(setNames(list(sim), sim_name), envir = .GlobalEnv))
        save(list = sim_name, file = paste0(analysis_path, "/Rsave/",
                                            sim_name, ".RData"))
      }
    }
  }
}
} # }