Created
March 24, 2025 08:34
-
-
Save njtierney/dee41c376b487345c8fcdcc7e0da4dde to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# example code from test_posteriors_geweke | |
devtools::load_all(".") | |
n <- 10 | |
# mu1 <- rnorm(1, 0, 3) | |
# sd1 <- rlnorm(1) | |
# sd2 <- rlnorm(1) | |
mu1 <- 0 | |
sd1 <- 2 | |
sd2 <- 1 | |
# prior (n draws) | |
p_theta <- function(n) { | |
rnorm(n, mu1, sd1) | |
} | |
# likelihood | |
p_x_bar_theta <- function(theta) { | |
rnorm(n, theta, sd2) | |
} | |
# define the greta model (single precision for slice sampler) | |
x <- as_data(rep(0, n)) | |
greta_theta <- normal(mu1, sd1) | |
distribution(x) <- normal(greta_theta, sd2) | |
model <- model(greta_theta) | |
geweke_adaptive_hmc <- check_geweke( | |
sampler = adaptive_hmc(), | |
model = model, | |
data = x, | |
p_theta = p_theta, | |
p_x_bar_theta = p_x_bar_theta, | |
chains = 10, | |
niter = 10, | |
warmup = 2000, | |
thin = 1 | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment