## Load or prep data
schools_data <- list(
J = 8,
y = c(28, 8, -3, 7, -1, 1, 18, 12),
sigma = c(15, 10, 16, 11, 9, 11, 10, 18)
)
## Run the Stan Function
library(cmdstanr)
file2 <- file.path("school.stan") # Reads from a file
mod <- cmdstan_model(file2, # Compiles the model given in the file
compile_model_methods = FALSE,
force_recompile = TRUE)
fit <- mod$sample(
data = schools_data,
seed = 123,
chains = 2,
parallel_chains = 1,
iter_warmup = 1000,
iter_sampling = 2000,
save_warmup = TRUE,
thin = 1,
refresh = 500 # draws posterior samples
)