Run the Metropolis-Hastings algorithm for data.
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 <- GRTRN_MHmcmc(result=try)
, use:
result_mcmc$SD
coda
package is necessary for this function.
The parameters intermediate
and filename
are used to save intermediate results every 'intermediate' iterations (for example 1000). Results are saved in a file named 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 with user limited time.
GRTRN_MHmcmc(
result = NULL,
n.iter = 10000,
parametersMCMC = NULL,
n.chains = 1,
n.adapt = 0,
thin = 1,
trace = NULL,
traceML = FALSE,
parallel = TRUE,
adaptive = FALSE,
adaptive.lag = 500,
adaptive.fun = function(x) {
ifelse(x > 0.234, 1.3, 0.7)
},
intermediate = NULL,
filename = "intermediate.Rdata",
previous = NULL
)
A list with resultMCMC being mcmc.list object, resultLnL being likelihoods and parametersMCMC being the parameters used
An object obtained after a SearchR fit
Number of iterations for each step
A set of parameters used as initial point for searching with information on priors
Number of replicates
Number of iterations before to store outputs
Number of iterations between each stored output
TRUE or FALSE or period, shows progress
TRUE or FALSE to show ML
If true, try to use several cores using parallel computing
Should an adaptive process for SDProp be used
Lag to analyze the SDProp value in an adaptive content
Function used to change the SDProp
Period for saving intermediate result, NULL for no save
If intermediate is not NULL, save intermediate result in this file
Previous result to be continued. Can be the filename in which intermediate results are saved.
Marc Girondot
GRTRN_MHmcmc runs the Metropolis-Hastings algorithm for data (Bayesian MCMC)