Skip to content

Instantly share code, notes, and snippets.

data {
int<lower=0> n;
vector[n] y;
vector[n] x2;
vector[n] x3;
real<lower= -1, upper= 1> rho;
real g; // slope for u
vector[2] prior;
}
transformed data {
change <- function(x, days = 10, method = 'last', intvl = .9) {
# distribution of change over days
stopifnot(days < length(x))
stopifnot(method %in% c('last', 'max', 'min'))
N <- length(x)
vec <- c()
for (i in 1:(N - days)) {
extract <- x[i:(i + days)]
lastchange <- extract[days] / extract[1] - 1