Description Usage Arguments Examples
Simple Metropolis algorithm implementations for simple models.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | metro_bern(
x,
n,
step_size = 0.01,
start = 0.5,
num_steps = 10000,
prior = dunif,
...
)
metro_norm(
y,
num_steps = 1e+05,
step_size = 1,
start = list(mu = 0, log_sigma = 0)
)
|
x |
number of success in data |
n |
number of failures in data |
step_size |
sd of (normal) jump distribution(s) |
start |
starting value(s) for MCMC |
num_steps |
how long to run MCMC |
prior |
a function describing the prior |
... |
additional arguments for the prior |
y |
vecctor of numeric response values |
1 2 3 4 5 6 7 8 9 10 11 12 | Metro <-
metro_bern(10, 30, step_size = 0.1, prior = dbeta, shape1 = 4, shape2 = 4)
# posterior density
Metro %>%
gf_dens(~ theta) %>%
gf_dist("beta", shape1 = 14, shape2 = 24, color = "red")
# trace plot
Metro %>%
gf_line(theta ~ step)
metro_norm(rnorm(25, 10, 1), start = list(mu = 5, log_sigma = log(5))) %>%
gf_density( ~ mu)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.