Learn R Programming

embryogrowth (version 6.4)

STRN_MHmcmc: Metropolis-Hastings algorithm for Sexualisation Thermal Reaction Norm

Description

Run the Metropolis-Hastings algorithm for Sexualisation Thermal Reaction Norm. The number of iterations is n.iter+n.adapt+1 because the initial likelihood is also displayed. I recommend that thin=1 because the method to estimate SE uses resampling. If initial point is maximum likelihood, n.adapt = 0 is a good solution. To get the SE of the point estimates from result_mcmc <- STRN_MHmcmc(result=try), use: result_mcmc$SD coda package is necessary for this function. The dataSTRN is a named list with the following objects:
  • EmbryoGrowthTRN= result of searchR
  • tsd= result of tsd
  • sexed= vector with number of sexed embryos
  • males= vector with number of males (could be also females=)
  • Temperatures= a text of the temperatures name used as CTE

The Temperatures text for CTE can be:

  • TimeWeighted.temperature.mean
  • TSP.TimeWeighted.temperature.mean
  • TSP.MassWeighted.temperature.mean
  • TSP.STRNWeighted.temperature.mean
  • TSP.MassWeighted.STRNWeighted.temperature.mean
  • MiddleThird.TimeWeighted.temperature.mean

They are explained in the info.nests function. This function is not still fully described as it has not been published still. The parameters intermediate and filename are used to save intermediate results every 'intermediate' iterations (for example 1000). Results are saved in a file of name filename. The parameter previous is used to indicate the list that has been save using the parameters intermediate and filename. It permits to continue a mcmc search. These options are used to prevent the consequences of computer crash or if the run is very very long and processes at time limited.

Usage

STRN_MHmcmc(result = NULL, n.iter = 10000, parametersMCMC = NULL, n.chains = 1, n.adapt = 0, thin = 1, trace = FALSE, batchSize = sqrt(n.iter), dataSTRN = NULL, intermediate = NULL, filename = "intermediate.Rdata", previous = NULL)

Arguments

result
An object obtained after a STRN fit
n.iter
Number of iterations for each step
parametersMCMC
A set of parameters used as initial point for searching with information on priors
n.chains
Number of replicates
n.adapt
Number of iterations before to store outputs
thin
Number of iterations between each stored output
trace
True or False, shows progress
batchSize
Number of observations to include in each batch fo SE estimation
dataSTRN
A named list data used to estimate likelihoods (see further in description)
intermediate
Period for saving intermediate result, NULL for no save
filename
If intermediate is not NULL, save intermediate result in this file
previous
Previous result to be continued. Can be the filename in which intermediate results are saved.

Value

A list with resultMCMC being mcmc.list object, resultLnL being likelihoods and parametersMCMC being the parameters used

Details

STRN_MHmcmc runs the Metropolis-Hastings algorithm for STRN (Bayesian MCMC)

Examples

Run this code
## Not run: 
# library(embryogrowth)
# ## End(Not run)

Run the code above in your browser using DataLab