Skip to content

R package that provides an implementation of the generic adaptive Monte Carlo Markov chain sampler proposed by Vihola (2011).

License

Notifications You must be signed in to change notification settings

scheidan/adaptMCMC

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

26 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Research software impact

adaptMCMC

R package that provides an implementation of the generic adaptive Monte Carlo Markov chain sampler proposed by Vihola (2011).

Getting started

library(adaptMCMC)

## ---------------------
## Define (non-normalized) log density

## log-pdf to sample from
p.log <- function(x) {
  B <- 0.03                              # controls 'bananacity'
  -x[1]^2/200 - 1/2*(x[2]+B*x[1]^2-100*B)^2
}


## ----------------------
## generate samples

## 1) non-adaptive sampling
samp.1 <- MCMC(p.log, n=200, init=c(0, 1), scale=c(1, 0.1),
               adapt=FALSE)

## 2) adaptive sampling
samp.2 <- MCMC(p.log, n=200, init=c(0, 1), scale=c(1, 0.1),
               adapt=TRUE, acc.rate=0.234)


## ----------------------
## summarize results

str(samp.2)
summary(samp.2$samples)

## covariance of last jump distribution
samp.2$cov.jump

## plot chains and marginals
plot(convert.to.coda(samp.2))

References

Vihola, M., 2011. Robust adaptive Metropolis algorithm with coerced acceptance rate. Statistics and Computing. https://doi.org/10.1007/s11222-011-9269-5

About

R package that provides an implementation of the generic adaptive Monte Carlo Markov chain sampler proposed by Vihola (2011).

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages