README.md

Background

Bayesian inference often requires many iterations of model fitting, data replication, and model checking, before a suitable set of inferences is reached. It can be cumbersome to try to save all of the model forms and input data files for each iteration, and often researchers find themselves drowning in a sea of Stan files, MCMC traces, and datasets.

Further developments of the package will attempt to address the larger problem of what Andrew Gelman calls the network of models, which is a philosophical attempt at conveying the idea of a machine-aided inference workflow. For now, we stick with the general case, and save everything seperately.

Example

For this inference problem, the save_fit function can be used to record a simple workflow without having to resort to saving multuple stan files.

library(rstan)
options(mc.cores = 2)
rstan_options(auto_write = TRUE)

y = rnorm(10, 1, 1.2)

data = list(
    n = length(y),
    y = y
)

file = '~/Documents/stansave/vignettes/gaussian.stan'

fit = stan(file, data = data, chains = 2)

save_fit(file, fit, data)

For reference, gaussian.stan is written as

data {
    int n;
    real y[n];
}

parameters {
    real mu;
    real <lower = 0> sigma;
}

model {
    y ~ normal(mu, sigma);
}


carterce1997/stansave documentation built on May 26, 2019, 4:39 p.m.