simulate_slopes_for_GOF: Simulate slopes for the goodness of fit test

View source: R/goodness_of_fit.R

simulate_slopes_for_GOFR Documentation

Simulate slopes for the goodness of fit test

Description

This function creates the data required to apply a goodness of fit test (see goodness_of_fit). It it the function of this package that is the most computationally demanding. Depending on the number of cores CPU you use, the function call may lead to many days of computation time or a large memory requirement.

Usage

simulate_slopes_for_GOF(
  N_replicates_level1 = 200L,
  N_replicates_level2 = 49L,
  birth_level_data,
  scenario,
  life_history_fits = NULL,
  nb_cores = 2L,
  lapply_pkg = "pbmcapply",
  seed = 1L,
  timeout = Inf,
  verbose = list(fit = FALSE, simu = FALSE),
  .log = FALSE
)

Arguments

N_replicates_level1

the number of simulation replicates to run at the first level (see simulate_slopes)

N_replicates_level2

the number of simulation replicates to run at the second level (see simulate_slopes)

birth_level_data

a tibble or data.frame with birth level data (expanded or not)

scenario

the scenario defining which models to be fitted: e.g. "ABCD", "AC"... (see paper for explanations)

life_history_fits

a named list containing the fits of each three life history models

nb_cores

the number of CPU core(s) to use

lapply_pkg

the R package used to implement a lapply() kind of function (default = "pbmcapply"; other possibilities are "parallel" and "base")

seed

a seed for the random number generator that will be added to the seeds for individual simulations; with such seeds corresponding to 1:N_replicates_level1

timeout

the maximal duration (in seconds) allowed for the fitting procedure (default = Inf)

verbose

whether to display the formula of the fit during the fitting procedure

.log

a boolean indicating whether or not to write progress in a log file (for debugging purposes)

Details

The function performs the double bootstrapping procedure and proceeds as follow:

  1. if life_history_fits is not provided, the function starts by fitting the life history models (see fit_life_histories) on the input data (i.e. birth_level_data which unless studying the robustness of the function, should be the observed data).

  2. the function then run a first series of simulation using the models fitted in step 1 (or the set provided as an input using the argument life_history_fits) by calling simulate_slopes N_replicates_level1 times.

  3. on each simulation outcome, a new set of life history models is fitted (using again fit_life_histories). This is the step that is computationally intensive.

  4. the function then run a second series of simulation using the models fitted during step 3 by calling simulate_slopes N_replicates_level2 times.

For details on the implementation used for the parallel computing and its settings, see test_parallel_computation.

Value

a tibble containing all the results

See Also

simulate_slopes, goodness_of_fit, test_parallel_computation

Examples

#See ?twinR


courtiol/twinR documentation built on July 11, 2024, 12:04 a.m.