R/foo.R

Defines functions test

Documented in test

#' Create stanreg object
#' @param number sample size
#' @export
test <- function(number) {
  stanmodelcode <- "
    data {
    int<lower=0> N;
    real y[N];
    }
    parameters {
    real mu;
    }
    model {
    target += normal_lpdf(mu | 0, 10);
    target += normal_lpdf(y | mu, 1);
    }
    "
  y <- stats::rnorm(20)
  dat <- list(N = number, y = y);
  fit <- rstan::stan(model_code = stanmodelcode, model_name = "example",
            data = dat, iter = 2012, chains = 3, verbose = TRUE,
            sample_file = file.path(tempdir(), 'norm.csv'))
}
jyuu/deleteme documentation built on Dec. 23, 2019, 7:36 p.m.