Skip to content

Commit

Permalink
version 3.1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Bisaloo authored and cran-robot committed Mar 21, 2024
1 parent 54fb448 commit 9d572b1
Show file tree
Hide file tree
Showing 18 changed files with 1,000 additions and 522 deletions.
13 changes: 7 additions & 6 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: mcmcensemble
Title: Ensemble Sampler for Affine-Invariant MCMC
Version: 3.0.0
Version: 3.1.0
Authors@R:
c(person(given = "Hugo",
family = "Gruson",
Expand All @@ -21,23 +21,24 @@ Description: Provides ensemble samplers for
Vrugt (2008) <doi:10.1007/s11222-008-9104-9> and the 'stretch' sampler
from Goodman and Weare (2010) <doi:10.2140/camcos.2010.5.65>.
License: GPL-2
URL: https://github.com/Bisaloo/mcmcensemble,
https://bisaloo.github.io/mcmcensemble/
URL: https://hugogruson.fr/mcmcensemble/,
https://github.com/Bisaloo/mcmcensemble
BugReports: https://github.com/Bisaloo/mcmcensemble/issues
Depends: R (>= 3.5)
Imports: future.apply, progressr
Suggests: bayesplot, coda, mockery, testthat (>= 3.0.0), knitr,
rmarkdown
Encoding: UTF-8
RoxygenNote: 7.1.1.9001
RoxygenNote: 7.3.1
Config/testthat/edition: 3
Config/Needs/website: r-for-educators/flair, spacefillr
VignetteBuilder: knitr
NeedsCompilation: no
Packaged: 2021-04-27 11:29:41 UTC; hugo
Packaged: 2024-03-20 16:28:45 UTC; hugo
Author: Hugo Gruson [cre, aut, cph] (<https://orcid.org/0000-0002-4094-1476>),
Sanda Dejanic [aut, cph],
Andreas Scheidegger [aut, cph]
(<https://orcid.org/0000-0003-2575-2172>)
Maintainer: Hugo Gruson <hugo.gruson+R@normalesup.org>
Repository: CRAN
Date/Publication: 2021-04-28 13:20:03 UTC
Date/Publication: 2024-03-20 16:50:02 UTC
34 changes: 17 additions & 17 deletions MD5
Original file line number Diff line number Diff line change
@@ -1,26 +1,26 @@
e4ee17a6f62b60df0e71bb4ed31a4db3 *DESCRIPTION
0aa0328799ce412a62068ca79d85dcbe *DESCRIPTION
9c2c7cff5a3b7d6e1fe516aa5747affd *NAMESPACE
fee967acc45d63a5b6bd3fa59d42c257 *NEWS.md
048b9761aec9d50889b902f74123d5b4 *R/MCMCEnsemble.R
1cf1e9aefa09e40f35eaccae62dc89d1 *NEWS.md
a2a6f7313e718419333dd195724783e0 *R/MCMCEnsemble.R
e8c53d179790dd7584119ac16b3f219f *R/d.e.mcmc.R
5a2436fe6a4782d4b94f91bf9ee820ce *R/mcmcensemble-package.R
543a7ee1ac889238b12310a9ea073b2c *R/s.m.mcmc.R
974160b497bfe889ce6ba8ae41e3ad54 *README.md
65d78eb69e91703cba2eab4fd9bfa082 *build/partial.rdb
86da373324105b3cedc6a7d59077a8f6 *build/vignette.rds
2d3e2ffb842514a2c7c5fa0fb819cd44 *inst/doc/diagnostic-pkgs.R
ad17cd28a481dd76704222c23645ea2c *README.md
20c8d3f97d93e2e318a22508275b5a02 *build/partial.rdb
430b80a90aeb2d3b04934506d8b581eb *build/vignette.rds
cddf28d7da8ee2aebfb04cb47b60cdb5 *inst/doc/diagnostic-pkgs.R
06e526aa4bff5bf030df2efe4d09eaee *inst/doc/diagnostic-pkgs.Rmd
be8c3b10f921c139db2a059ee757cdce *inst/doc/diagnostic-pkgs.html
90da8166157ac5a2daa6bec350e67de7 *inst/doc/faq.R
ac79f1694fce4ba35d534524772b5018 *inst/doc/faq.Rmd
a06a2c05df5f97123cefddeb0839d76b *inst/doc/faq.html
2429f4d9e58825fab069450b791c7282 *man/MCMCEnsemble.Rd
6cb5440ef7a0069a18d1a57659643b5e *man/figures/README-example-de-1.svg
c19a74594d7c62a484f0f18daf6b40bf *man/figures/README-example-stretch-1.svg
23c04d0dcaf80725c567cfb046b801ab *man/mcmcensemble-package.Rd
bc4cd4af1b69f1935aa642367cc63402 *inst/doc/diagnostic-pkgs.html
07409e187a5c8bd92959cf661b4350d0 *inst/doc/faq.R
1bf3e7f34096ec719d9e96b8a6402a27 *inst/doc/faq.Rmd
082d29977c547f0d3f0880f7630d319c *inst/doc/faq.html
0a53dd2af9e9d87a5103e25e435c69d5 *man/MCMCEnsemble.Rd
5f10a09c9e6a5d026d5283cf1c155a7c *man/figures/README-example-de-1.svg
1ddbbede6988ce2c519230880a97fd53 *man/figures/README-example-stretch-1.svg
76ba62b4cc601d1ec9e2556f8ee53c71 *man/mcmcensemble-package.Rd
1495e1617d4670efb997b4dc2f4717f2 *tests/testthat.R
23b45d862066c010e38650d31bc7f365 *tests/testthat/test-MCMCEnsemble.R
814f8afcf2bb313518ab775904451310 *tests/testthat/test-MCMCEnsemble.R
5afbe2390b9ac12284e3667a2a578fcf *tests/testthat/test-convergence.R
78f2ab105798e2b132ce325f85457f57 *vignettes/blog/blog_v3.Rmd
06e526aa4bff5bf030df2efe4d09eaee *vignettes/diagnostic-pkgs.Rmd
ac79f1694fce4ba35d534524772b5018 *vignettes/faq.Rmd
1bf3e7f34096ec719d9e96b8a6402a27 *vignettes/faq.Rmd
10 changes: 9 additions & 1 deletion NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
# mcmcensemble 3.1.0

## Minor improvements

* there is now a clearer error message when trying to use a single walker since
ensemble sampling is designed to work with multiple walkers (#6 by @Bisaloo,
based on a report from @adamkucharski).

# mcmcensemble 3.0.0

## Major changes
Expand Down Expand Up @@ -49,7 +57,7 @@ an additional attribute (accessible via `attr(res, "ensemble.sampler")`).
## Major changes

* the ensemble sampling can now be parallelised with the future framework. Check
the [README](https://bisaloo.github.io/mcmcensemble/) for more information
the [README](https://hugogruson.fr/mcmcensemble/) for more information

## Other user-facing changes

Expand Down
7 changes: 6 additions & 1 deletion R/MCMCEnsemble.R
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
#' @param inits A matrix (or data.frame) containing the starting values for the
#' walkers. Each column is a variable to estimate and each row is a walker
#' @param max.iter maximum number of function evaluations
#' @param n.walkers number of walkers (ensemble size)
#' @param n.walkers number of walkers (ensemble size). An integer greater or
#' equal than 2.
#' @param method method for proposal generation, either `"stretch"`, or
#' `"differential.evolution"`. This argument will be saved as an attribute
#' in the output (see examples).
Expand Down Expand Up @@ -97,6 +98,10 @@ MCMCEnsemble <- function(f, inits, max.iter, n.walkers = 10 * ncol(inits),
inits <- as.matrix(inits)
}

if (n.walkers < 2) {
stop("The number of walkers must be at least 2", call. = FALSE)
}

if (nrow(inits) != n.walkers) {
stop(
"The number of rows of `inits` must be equal to `n.walkers`",
Expand Down
37 changes: 23 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,16 @@ status](https://www.r-pkg.org/badges/version-ago/mcmcensemble)](https://CRAN.R-p
[![R build
status](https://github.com/Bisaloo/mcmcensemble/workflows/R-CMD-check/badge.svg)](https://github.com/Bisaloo/mcmcensemble/actions)
[![Codecov test
coverage](https://codecov.io/gh/Bisaloo/mcmcensemble/branch/master/graph/badge.svg)](https://codecov.io/gh/Bisaloo/mcmcensemble?branch=master)
coverage](https://codecov.io/gh/Bisaloo/mcmcensemble/branch/main/graph/badge.svg)](https://app.codecov.io/gh/Bisaloo/mcmcensemble?branch=main)
[![Lifecycle:
stable](https://img.shields.io/badge/lifecycle-stable-brightgreen.svg)](https://lifecycle.r-lib.org/articles/stages.html)

This R package provides ensemble samplers for affine-invariant Monte
Carlo Markov Chain, which allow a faster convergence for badly scaled
estimation problems. Two samplers are proposed: the
‘differential.evolution’ sampler from [ter Braak and
Vrugt](#ref-terBraak2008) ([2008](#ref-terBraak2008)) and the ‘stretch’
sampler from [Goodman and Weare](#ref-Goodman2010)
([2010](#ref-Goodman2010)).
‘differential.evolution’ sampler from ter Braak and Vrugt
([2008](#ref-terBraak2008)) and the ‘stretch’ sampler from Goodman and
Weare ([2010](#ref-Goodman2010)).

For theoretical background about Ensemble MCMC (what are the benefits
over simple MCMC? How do they work? What are the pitfalls?), please
Expand All @@ -37,7 +36,7 @@ install.packages("mcmcensemble")
```

or the development version from [GitHub](https://github.com/bisaloo),
via my [r-universe](https://bisaloo.r-universe.dev/):
via my [r-universe](https://bisaloo.r-universe.dev/packages):

``` r
install.packages("mcmcensemble", repos = "https://bisaloo.r-universe.dev")
Expand Down Expand Up @@ -119,6 +118,11 @@ summary(res2$samples)
#> a -19.563 -8.1257 -1.429 4.862 13.448
#> b -8.809 -0.7837 1.199 2.519 4.225
plot(res2$samples)
#> Warning in rep(col, length = nchain(x)): partial argument match of 'length' to
#> 'length.out'

#> Warning in rep(col, length = nchain(x)): partial argument match of 'length' to
#> 'length.out'
```

<img src="man/figures/README-example-stretch-1.svg" width="100%" />
Expand Down Expand Up @@ -153,13 +157,18 @@ summary(res3$samples)
#> a -23.87 -6.4298 -0.2157 6.038 16.33
#> b -13.53 -0.8687 1.6170 2.583 4.22
plot(res3$samples)
#> Warning in rep(col, length = nchain(x)): partial argument match of 'length' to
#> 'length.out'

#> Warning in rep(col, length = nchain(x)): partial argument match of 'length' to
#> 'length.out'
```

<img src="man/figures/README-example-de-1.svg" width="100%" />

To see more plotting and MCMC diagnostic options, please refer to the
relevant vignette:
[`vignette("diagnostic-pkgs", package = "mcmcensemble")`](https://bisaloo.github.io/mcmcensemble/articles/diagnostic-pkgs.html)
[`vignette("diagnostic-pkgs", package = "mcmcensemble")`](https://hugogruson.fr/mcmcensemble/articles/diagnostic-pkgs.html)

## Progress bar

Expand Down Expand Up @@ -193,20 +202,20 @@ at the start of your session.
## Similar projects

The Goodman-Weare ‘stretch’ sampler is also available in the [tonic R
package](https://github.com/svdataman/tonic).
package](https://github.com/SimonVaughanDataAndCode/tonic).

The methods used in this package also have (independent) implementations
in other languages:

- [emcee v3: A Python ensemble sampling toolkit for affine-invariant
MCMC](https://doi.org/10.21105/joss.01864)
- [GWMCMC which implements the Goodman-Weare ‘stretch’ sampler in
Matlab](https://github.com/grinsted/gwmcmc)
- [emcee v3: A Python ensemble sampling toolkit for affine-invariant
MCMC](https://doi.org/10.21105/joss.01864)
- [GWMCMC which implements the Goodman-Weare ‘stretch’ sampler in
Matlab](https://github.com/grinsted/gwmcmc)

## Who is talking about this package?

- [R View from October
2020](https://rviews.rstudio.com/2020/11/19/october-2020-top-40-new-cran-packages/)
- [R View from October
2020](https://rviews.rstudio.com/2020/11/19/october-2020-top-40-new-cran-packages/)

## References

Expand Down
Binary file modified build/partial.rdb
Binary file not shown.
Binary file modified build/vignette.rds
Binary file not shown.
6 changes: 3 additions & 3 deletions inst/doc/diagnostic-pkgs.R
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
## ---- include = FALSE---------------------------------------------------------
## ----include = FALSE----------------------------------------------------------
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>"
Expand Down Expand Up @@ -36,7 +36,7 @@ class(res$samples)
## -----------------------------------------------------------------------------
summary(res$samples)

## ---- eval = identical(Sys.getenv("IN_PKGDOWN"), "true")----------------------
## ----eval = identical(Sys.getenv("IN_PKGDOWN"), "true")-----------------------
# plot(res$samples)

## -----------------------------------------------------------------------------
Expand All @@ -58,7 +58,7 @@ res_coda <- MCMCEnsemble(
max.iter = 3000, n.walkers = 10, method = "stretch", coda = TRUE
)

## ---- out.width='45%', fig.show='hold'----------------------------------------
## ----out.width='45%', fig.show='hold'-----------------------------------------
# Density of log-posterior of each parameter
mcmc_areas(res_nocoda$samples)
mcmc_areas(res_coda$samples)
Expand Down

0 comments on commit 9d572b1

Please sign in to comment.