library(mcmcensemble)
lower.inits
and upper.inits
?YES
## a log-pdf to sample from
<- function(x) {
p.log <- 0.03 # controls 'bananacity'
B -x[1]^2 / 200 - 1 / 2 * (x[2] + B * x[1]^2 - 100 * B)^2
}
set.seed(20201209)
<- MCMCEnsemble(
res1
p.log,lower.inits = c(a = -10, b = -10), upper.inits = c(a = -5, b = -5),
max.iter = 3000, n.walkers = 10,
method = "stretch",
coda = TRUE
)#> Using stretch move with 10 walkers.
summary(res1$samples)
#>
#> Iterations = 1:300
#> Thinning interval = 1
#> Number of chains = 10
#> Sample size per chain = 300
#>
#> 1. Empirical mean and standard deviation for each variable,
#> plus standard error of the mean:
#>
#> Mean SD Naive SE Time-series SE
#> a -3.4972 9.084 0.16584 1.4141
#> b -0.1255 4.116 0.07515 0.5463
#>
#> 2. Quantiles for each variable:
#>
#> 2.5% 25% 50% 75% 97.5%
#> a -20.642 -10.134 -2.887 3.098 12.403
#> b -9.974 -1.766 1.148 2.675 4.401
plot(res1$samples)
<- MCMCEnsemble(
res2
p.log,lower.inits = c(a = -10, b = -10), upper.inits = c(a = -5, b = -5),
max.iter = 3000, n.walkers = 10,
method = "differential.evolution",
coda = TRUE
)#> Using differential.evolution move with 10 walkers.
summary(res2$samples)
#>
#> Iterations = 1:300
#> Thinning interval = 1
#> Number of chains = 10
#> Sample size per chain = 300
#>
#> 1. Empirical mean and standard deviation for each variable,
#> plus standard error of the mean:
#>
#> Mean SD Naive SE Time-series SE
#> a 0.14194 9.874 0.18028 0.9203
#> b -0.01001 3.697 0.06751 0.4142
#>
#> 2. Quantiles for each variable:
#>
#> 2.5% 25% 50% 75% 97.5%
#> a -19.189 -6.265 -0.1711 7.735 18.07
#> b -8.556 -1.963 1.2788 2.687 4.34
plot(res2$samples)