mirror of
https://github.com/saymrwulf/prophet.git
synced 2026-05-17 21:10:45 +00:00
The vector/matrix operations fail to compile in windows due to eigen incompatibility with windows compiler. Here we opt to use a non- vectorized model for windows platform.
40 lines
1.3 KiB
Text
40 lines
1.3 KiB
Text
data {
|
|
int T; // Sample size
|
|
int<lower=1> K; // Number of seasonal vectors
|
|
vector[T] t; // Day
|
|
vector[T] y; // Time-series
|
|
int S; // Number of changepoints
|
|
matrix[T, S] A; // Split indicators
|
|
real t_change[S]; // Index of changepoints
|
|
matrix[T,K] X; // season vectors
|
|
real<lower=0> sigma; // scale on seasonality prior
|
|
real<lower=0> tau; // scale on changepoints prior
|
|
}
|
|
|
|
parameters {
|
|
real k; // Base growth rate
|
|
real m; // offset
|
|
vector[S] delta; // Rate adjustments
|
|
real<lower=0> sigma_obs; // Observation noise (incl. seasonal variation)
|
|
vector[K] beta; // seasonal vector
|
|
}
|
|
|
|
transformed parameters {
|
|
vector[S] gamma; // adjusted offsets, for piecewise continuity
|
|
|
|
for (i in 1:S) {
|
|
gamma[i] = -t_change[i] * delta[i];
|
|
}
|
|
}
|
|
|
|
model {
|
|
//priors
|
|
k ~ normal(0, 5);
|
|
m ~ normal(0, 5);
|
|
delta ~ double_exponential(0, tau);
|
|
sigma_obs ~ normal(0, 0.5);
|
|
beta ~ normal(0, sigma);
|
|
|
|
// Likelihood
|
|
y ~ normal((k + A * delta) .* t + (m + A * gamma) + X * beta, sigma_obs);
|
|
}
|