Steps for
Sample candidate value from a proposal distribution
Compute acceptance probability:
3. Compute
Sample
An example
In practice, we always find the function in a published R package can not meet our needs very well. However, it’s not necessary to write a new function all over. It would be more convenient if we can modify the function directly. Let’s look at an example.
We check the source code of sd() function in the stats package. The source code is as following:
library(stats) sd function (x, na.rm = FALSE) sqrt(var(if (is.
R code for bootstrap and permutation test.