Last active
November 11, 2020 22:28
-
-
Save bakfoo/2447eb7d551ff256706a to your computer and use it in GitHub Desktop.
Rstan ADVI Test using rats examples.
This file contains 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
y <- read.table('https://raw.github.com/wiki/stan-dev/rstan/rats.txt', header = TRUE) | |
x <- c(8, 15, 22, 29, 36) | |
xbar <- mean(x) | |
N <- nrow(y) | |
T <- ncol(y) | |
data <- list(y=y, x=x, xbar=xbar, N=N, T=T) | |
rats_model <- stan_model(file = "https://raw.githubusercontent.com/stan-dev/example-models/master/bugs_examples/vol1/rats/rats.stan") | |
#NUTS | |
rats_fit <- sampling(rats_model, data=data, iter=1000, warmup=500, chains=4, seed=123) | |
# ADVI | |
rats_fit_vb <- vb(rats_model, data=data, output_samples=2000, seed=123) | |
# ADVI+fullrank | |
racets_fit_vbfr <- vb(rats_model, data=data, output_samples=2000, seed=123, algorithm = "fullrank") | |
# by Julian King (https://groups.google.com/d/msg/stan-users/FaBvi8w7pc4/pogd3zmVAQAJ) | |
rats_0 <- vb(rats_model, data = data, eta=5, adapt_engaged=FALSE, iter = 1000000, tol_rel_obj=0.00001) | |
print(rats_fit) | |
print(rats_fit_vb) | |
print(rats_fit_vbfr) | |
print(rats_0) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
thanks from me too!