This function checks whether all required settings for the Parallel Tempering Monte Carlo (PTMC) simulation are specified in the settings list. If any required settings are missing, it assigns default values and prints messages to notify the user. If critical settings are missing, it raises an error. This ensures that all settings are correctly specified before running the simulation.

check_settings(settings, model)

Arguments

settings

A list of settings for the PTMC simulation. This list can contain various parameters, including:

  • numberChainRuns: The number of chains to run (default: 4).

  • numberCores: The number of CPU cores to use for parallel execution (default: equal to numberChainRuns).

  • numberTempChains: The number of temperature chains to use (default: 10).

  • iterations: The number of iterations to run (default: 20000).

  • burninPosterior: The burn-in period for the posterior (default: 10000).

  • thin: The thinning interval for the MCMC chains (default: 100).

  • consoleUpdates: The frequency of console updates (default: 100).

  • numberFittedPar: The number of parameters to fit (MUST be specified by the user).

  • onAdaptiveCov: A logical flag indicating whether to use adaptive covariance (default: TRUE).

  • updatesAdaptiveCov: The frequency of adaptive covariance updates (default: 100).

  • burninAdaptiveCov: The burn-in period for adaptive covariance (default: 2000).

  • onAdaptiveTemp: A logical flag indicating whether to use adaptive temperatures (default: TRUE).

  • updatesAdaptiveTemp: The frequency of adaptive temperature updates (default: 10).

  • onDebug: A logical flag indicating whether to enable debug mode (default: FALSE).

  • lowerParBounds: The lower bounds for the parameters (MUST be specified by the user).

  • upperParBounds: The upper bounds for the parameters (MUST be specified by the user).

  • covarInitVal: The initial covariance value (default: 1e-10).

  • covarInitValAdapt: The initial covariance value for adaptive updates (default: 1e-10).

  • covarMaxVal: The maximum covariance value (default: 1).

  • runParallel: A logical flag indicating whether to run the simulation in parallel (default: TRUE).

model

A list representing the model used in the PTMC simulation. The function checks if specific model-related attributes are available to fill in missing settings (e.g., lowerParSupport_fitted, upperParSupport_fitted, and discrete_length).

Value

The updated settings list, with all required settings specified and missing settings filled with default values.

Details

This function ensures that the settings list contains all necessary values for a successful PTMC simulation. If any settings are missing, it assigns reasonable default values and notifies the user. Critical settings, such as numberFittedPar, lowerParBounds, and upperParBounds, must be specified by the user, and an error is raised if they are missing.

Examples

# Example usage of check_settings function
settings <- list(
  numberChainRuns = 5,
  numberCores = 5,
  numberFittedPar = 3,
  lowerParBounds = c(0, 0, 0),
  upperParBounds = c(10, 10, 10)
)
settings <- check_settings(settings, model = NULL)
#> `numberTempChains` not specified in settings. Default value 10. 
#> `iterations` not specified in settings. Default value 20,000. 
#> `numberChainRuns` not specified in settings. Default value 10,000. 
#> `thin` not specified in settings. Default value 100. 
#> `consoleUpdates` not specified in settings. Default value 100. 
#> `onAdaptiveCov` not specified in settings. Default value TRUE. 
#> `updatesAdaptiveCov` not specified in settings. Default value 100. 
#> `burninAdaptiveCov` not specified in settings. Default value 2000. 
#> `onAdaptiveTemp` not specified in settings.  Default value TRUE. 
#> `updatesAdaptiveTemp` not specified in settings.  Default value 10. 
#> `covarInitVal` not specified in settings.  Default value 1e-10. 
#> `covarInitValAdapt` not specified in settings.  Default value 1e-10. 
#> `covarMaxVal` not specified in settings. Default value 1. 
#> `runParallel` not specified in settings. Default value TRUE. 
print(settings)
#> $numberChainRuns
#> [1] 5
#> 
#> $numberCores
#> [1] 5
#> 
#> $numberFittedPar
#> [1] 3
#> 
#> $lowerParBounds
#> [1] 0 0 0
#> 
#> $upperParBounds
#> [1] 10 10 10
#> 
#> $numberTempChains
#> [1] 10
#> 
#> $iterations
#> [1] 20000
#> 
#> $burninPosterior
#> [1] 10000
#> 
#> $thin
#> [1] 100
#> 
#> $consoleUpdates
#> [1] 100
#> 
#> $onAdaptiveCov
#> [1] TRUE
#> 
#> $updatesAdaptiveCov
#> [1] 100
#> 
#> $burninAdaptiveCov
#> [1] 2000
#> 
#> $onAdaptiveTemp
#> [1] TRUE
#> 
#> $updatesAdaptiveTemp
#> [1] 10
#> 
#> $onDebug
#> [1] FALSE
#> 
#> $covarInitVal
#> [1] 1e-10
#> 
#> $covarInitValAdapt
#> [1] 1e-10
#> 
#> $covarMaxVal
#> [1] 1
#> 
#> $runParallel
#> [1] TRUE
#>