Learn R Programming

EMC (version 1.3)

evolMonteCarlo: evolutionary Monte Carlo algorithm

Description

Given a multi-modal and multi-dimensional target density function, a (possibly asymmetric) proposal distribution and a temperature ladder, this function produces samples from the target using the evolutionary Monte Carlo algorithm.

Below sampDim refers to the dimension of the sample space, temperLadderLen refers to the length of the temperature ladder, and levelsSaveSampForLen refers to the length of the levelsSaveSampFor.

Usage

evolMonteCarlo(nIters,
               temperLadder,                       
               startingVals,                       
               logTarDensFunc,                     
               MHPropNewFunc,                      
               logMHPropDensFunc = NULL,           
               MHBlocks          = NULL,
               MHBlockNTimes     = NULL,
               moveProbsList     = NULL,               
               moveNTimesList    = NULL,              
               SCRWMNTimes       = NULL,                     
               SCRWMPropSD       = NULL,                         
               levelsSaveSampFor = NULL,
               nThin             = 1,
               saveFitness       = FALSE,                
               verboseLevel      = 0,
               ...)

Arguments

nIters
integer $>$ 0.
temperLadder
double vector with all positive entries, in decreasing order.
startingVals
double matrix of dimension temperLadderLen $\times$ sampDim or vector of length sampDim, in which case the same starting values are used for every temperature level.
logTarDensFunc
function of two arguments (draw, ...) that returns the target density evaluated in the log scale.
MHPropNewFunc
function of four arguments (temperature, block, currentDraw, ...) that returns new Metropolis-Hastings proposals. See details below on the argument block.
logMHPropDensFunc
function of five arguments (temperature, block, currentDraw, proposalDraw, ...) that returns the proposal density evaluated in the log scale. See details below on the argument block.
MHBlocks
list of integer vectors giving dimensions to be blocked together for sampling. It defaults to as.list(1:sampDim), i.e., each dimension is treated as a block on its own. See details below for an example.
MHBlockNTimes
integer vector of number of times each block given by MHBlocks should be sampled in each iteration. It defaults to rep(1, length(MHBlocks)). See details below for an example.
moveProbsList
named list of probabilities adding upto 1.
moveNTimesList
named list of integers $\ge$ 0.
SCRWMNTimes
integer $>$ 0.
SCRWMPropSD
double $>$ 0.
levelsSaveSampFor
integer vector with positive entries.
nThin
integer $\ge$ 1. Every nThin draw is saved.
saveFitness
logical.
verboseLevel
integer, a value $\ge$ 2 produces a lot of output.
...
optional arguments to be passed to logTarDensFunc, MHPropNewFunc and logMHPropDensFunc.

Value

  • Below nSave refers to ceil(nIters / nThin). This function returns a list with the following components:
  • drawsarray of dimension nSave $\times$ sampDim $\times$ levelsSaveSampForLen, if saveFitness = FALSE. If saveFitness = TRUE, then the returned array is of dimension nSave $\times$ (sampDim + 1) $\times$ levelsSaveSampForLen; i.e., each of the levelsSaveSampForLen matrices contain the fitness values in their last column.
  • acceptRatiosmatrix of the acceptance rates for various moves used.
  • detailedAcceptRatioslist of matrices with detailed summary of the acceptance rates for various moves used.
  • nItersthe nIters argument.
  • nThinthe nThin argument.
  • nSaveas defined above.
  • temperLadderthe temperLadder argument.
  • startingValsthe startingVals argument.
  • moveProbsListthe moveProbsList argument.
  • moveNTimesListthe moveNTimesList argument.
  • levelsSaveSampForthe levelsSaveSampFor argument.
  • timethe time taken by the run.

Details

[object Object],[object Object],[object Object],rl{ MH Metropolis-Hastings or mutation RC real crossover SC snooker crossover RE (random) exchange }

The target oriented EMC (TOEMC; Goswami and Liu, 2007) algorithm has the following additional moves on top of EMC:

rl{ BCE best chromosome exchange BIRE best importance ratio exchange BSE best swap exchange CE cyclic exchange }

The current function could be used to run both EMC and TOEMC algorithms by specifying what moves to employ using the following variables. [object Object],moveProbsList = list(MH = 0.4, RC = 0.3, SC = 0.3)

moveNTimesList = list(MH = 1, RC = floor(temperLadderLen / 2), SC = floor(temperLadderLen / 2), RE = temperLadderLen),[object Object],[object Object],[object Object]

References

Gopi Goswami and Jun S. Liu (2007). On learning strategies for evolutionary Monte Carlo. Statistics and Computing 17:1:23-38. Faming Liang and Wing H.Wong (2001). Real-Parameter Evolutionary Monte Carlo with Applications to Bayesian Mixture Models. Journal of the American Statistical Association 96:653-666.

See Also

parallelTempering

Examples

Run this code
samplerObj <-
    with(VShapedFuncGenerator(-13579),
     {
         allMovesNTimesList <- list(MH = 1, RC = 2, SC = 2, RE = 4,
                                    BIRE = 2, BCE = 2, BSE = 2, CE = 2)
         evolMonteCarlo(nIters            = 2000,
                        temperLadder      = c(15, 6, 2, 1),
                        startingVals      = c(0, 0),
                        logTarDensFunc    = logTarDensFunc,
                        MHPropNewFunc     = MHPropNewFunc,
                        moveNTimesList    = allMovesNTimesList,
                        SCRWMNTimes       = 1,
                        SCRWMPropSD       = 3.0,
                        levelsSaveSampFor = seq_len(4),
                        verboseLevel      = 1)
     })
print(samplerObj)
print(names(samplerObj))
with(samplerObj,
 {
     print(detailedAcceptRatios)
     print(dim(draws))
     par(mfcol = c(2, 2))
     for (ii in seq_along(levelsSaveSampFor)) {
         main <- paste('temper:', round(temperLadder[levelsSaveSampFor[ii]], 3))
         plot(draws[ , , ii],
              xlim = c(-5, 20),
              ylim = c(-8, 8),
              pch  = '.',
              ask  = FALSE,
              main = as.expression(main),
              xlab = as.expression(substitute(x[xii], list(xii = 1))),
              ylab = as.expression(substitute(x[xii], list(xii = 2))))
     }
 })

Run the code above in your browser using DataLab