From 80326e3cc84b572b78c2dec8fce6197b654ef436 Mon Sep 17 00:00:00 2001
From: matt-graham Setting up adaptation of tun
distribution.
adapters <- list(
- simple_scale_adapter(
+ scale_adapter(
initial_scale = dimension^(-1 / 6),
target_accept_prob = 0.574
),
- variance_shape_adapter()
+ shape_adapter("variance")
)
Here we set the initial scale to @@ -237,7 +237,7 @@
mean_accept_prob <- mean(barker_results$statistics[, "accept_prob"])
cat(sprintf("Average acceptance probability is %.2f", mean_accept_prob))
-#> Average acceptance probability is 0.54
+#> Average acceptance probability is 0.61
This is close to the target acceptance rate of 0.574 indicating the scale adaptation worked as expected.
We can also inspect the shape parameter of the proposal to check the @@ -253,7 +253,7 @@
Again adaptation appears to have been successful with the adapted shape close to the true target scales.
@@ -289,17 +289,17 @@We can also first explicit convert the traces
matrix to
a posterior
draws object using the
@@ -311,17 +311,17 @@
The draws object can also be manipulated and subsetted with various
functions provided by Here we create a new set of adapters using the default arguments to
- We can again check the average acceptance rate of the main chain
@@ -368,7 +368,7 @@ and use the nrZBGQ2<95@9posterior
. For example the extract_variable
@@ -337,7 +337,7 @@ Summarizing results using <
ess_mean(extract_variable(draws, "target_log_density"))
)
)
-#> Effective sample size of mean(target_log_density) is 1206
+#> Effective sample size of mean(target_log_density) is 408
Sampling using a Langevin proposal
@@ -346,9 +346,9 @@
Sampling using a Langevin proposallangevin_proposal in place of
baker_proposal
.
simple_scale_adapter
which will set the target acceptance
-rate to the Langevin proposal optimal value of 0.574 following the
-results in Roberts and Rosenthal (2001).scale_adapter
which will set the target acceptance rate to
+the Langevin proposal optimal value of 0.574 following the results in
+Roberts and Rosenthal (2001).
mala_results <- sample_chain(
target_distribution = target_distribution,
@@ -356,7 +356,7 @@
Sampling using a Langevin proposal initial_state = initial_state,
n_warm_up_iteration = n_warm_up_iteration,
n_main_iteration = n_main_iteration,
- adapters = list(simple_scale_adapter(), variance_shape_adapter()),
+ adapters = list(scale_adapter(), shape_adapter("variance")),
trace_warm_up = TRUE
)
Sampling using a Langevin proposal mean(mala_results$statistics[, "accept_prob"])
)
)
-#> Average acceptance probability is 0.61
ess_mean
function from the
posterior
package to compute the effective sample size of
the mean of the target_log_density
variableSampling using a Langevin proposal )
)
)
-#> Effective sample size of mean(target_log_density) is 2863
+#> Effective sample size of mean(target_log_density) is 1
Comparing adaptation using Barker and Langevin proposal
diff --git a/articles/barker-proposal_files/figure-html/unnamed-chunk-19-1.png b/articles/barker-proposal_files/figure-html/unnamed-chunk-19-1.png
index 11991f4e49e07f380c4922f00f3580c0e9b84673..0e0bd89b7076e0c31b1fec010e610ae211b91343 100644
GIT binary patch
literal 34257
zcmeFZXIPV2*9Q6kA~KF($DulcFjzp8-lC&`83YvREhqxg!4OJ-1j~$$7#KkXX<-mW
z5+ER*5P}T^g$NjWl@bUgKnN`)IXn2i-}$a{&j0h{9Is2jC(o{H?X~XvUK{_uY;CdY
zC)uAM2-*d|c)=Ee#Lq&I7_?(McruaL8U(&=ziw%90elC4*3Xl%;G1OVMQ0=gDcl$S
z6-k;{^oF3r5d6Y9yQs|B!RX9DKldI1Eeq!iN&FQg?|Ihq#-45BDnB3o@ZiLqx4X1%
zK6)VA9dESvqtb7DyHoxj4ju5?zv~e0&W_)Hx^~6+##6J)BE7%d=<&H$$>oj}@HsUm
zl)-tzd~rW(bq3|Zv&&)_b4=_}GuazmW&5}0_5Y184SQ?yYID(J7>QdA#^sB3ZdV3<
z@m>a(q{g_5=JX^xtbJTAeRVKk<;-u1VJ<|{XQg@Mi4sStF@_dISLZ4~5O*@qeDCbA
z!zy9^a+XKjn+*mth)yJSJA?$s`Z*oUZ_^df6lN}tMLVl&W+>BreI~l?WHg$`lqy%p
zObArJ*v7(&LfYHoa*T?{FX$3PJ$tMR?+WK%lLrA+4yMx2IH=oWs2
RsabxN1GqdT
zxYx{Y(n)>+(v*etR|?Xb^LEU5@>$9f_w?)zNZ&13M;%fBUe_9bUjFl>R>~4ddy;SL
z(QRi_6g+Sd<6u&W{yzV^tG_t{ptxjkXt4#sU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