This function runs the Parallel Tempering Monte Carlo (PTMC) simulation for a discrete model. It checks and validates the settings, and if the parameter list is empty, it initializes the parameters with default values. The function then calls the get_discrete_output function to perform the actual simulation and return the results.

ptmc_discrete_func(model, data, settings, par = NULL)

Arguments

model

A list representing the model, which contains necessary information for running the PTMC. This could include the model structure, parameter names, and other model-specific settings.

data

A list containing the data required for running the model. This might include observed data, priors, or any other inputs that the model requires to perform the simulation.

settings

A list of settings for the PTMC simulation. The list must include the following:

  • numberChainRuns: The number of chains to run in parallel.

  • Other settings relevant for running the PTMC simulation, which will be validated using the check_settings_discete function.

par

(Optional) A list of parameters for the chains. If provided, each element should correspond to the parameters for one chain. If not provided (or empty), default parameters will be used.

Value

A list containing the results of the PTMC simulation. The structure of the returned list will depend on the result of the get_discrete_output function, which includes:

  • mcmc: An MCMC object with posterior samples of the model parameters.

  • discrete: A list of discrete states generated during the simulation for each chain.

  • lpost: A data frame of log-posterior values, with columns representing different chains and rows representing samples.

  • temp: A data frame of temperatures for each chain at each sample.

  • acc: A data frame of acceptance rates for each chain at each sample.

  • outPTpar: A list containing the parameter values for each chain.