prophet.stan (prophet-1.0) | : | prophet.stan (prophet-1.1) | ||
---|---|---|---|---|
skipping to change at line 101 | skipping to change at line 101 | |||
vector[S] t_change; // Times of trend changepoints | vector[S] t_change; // Times of trend changepoints | |||
matrix[T,K] X; // Regressors | matrix[T,K] X; // Regressors | |||
vector[K] sigmas; // Scale on seasonality prior | vector[K] sigmas; // Scale on seasonality prior | |||
real<lower=0> tau; // Scale on changepoints prior | real<lower=0> tau; // Scale on changepoints prior | |||
int trend_indicator; // 0 for linear, 1 for logistic, 2 for flat | int trend_indicator; // 0 for linear, 1 for logistic, 2 for flat | |||
vector[K] s_a; // Indicator of additive features | vector[K] s_a; // Indicator of additive features | |||
vector[K] s_m; // Indicator of multiplicative features | vector[K] s_m; // Indicator of multiplicative features | |||
} | } | |||
transformed data { | transformed data { | |||
matrix[T, S] A; | matrix[T, S] A = get_changepoint_matrix(t, t_change, T, S); | |||
A = get_changepoint_matrix(t, t_change, T, S); | matrix[T, K] X_sa = X .* rep_matrix(s_a', T); | |||
matrix[T, K] X_sm = X .* rep_matrix(s_m', T); | ||||
} | } | |||
parameters { | parameters { | |||
real k; // Base trend growth rate | real k; // Base trend growth rate | |||
real m; // Trend offset | real m; // Trend offset | |||
vector[S] delta; // Trend rate adjustments | vector[S] delta; // Trend rate adjustments | |||
real<lower=0> sigma_obs; // Observation noise | real<lower=0> sigma_obs; // Observation noise | |||
vector[K] beta; // Regressor coefficients | vector[K] beta; // Regressor coefficients | |||
} | } | |||
skipping to change at line 133 | skipping to change at line 134 | |||
model { | model { | |||
//priors | //priors | |||
k ~ normal(0, 5); | k ~ normal(0, 5); | |||
m ~ normal(0, 5); | m ~ normal(0, 5); | |||
delta ~ double_exponential(0, tau); | delta ~ double_exponential(0, tau); | |||
sigma_obs ~ normal(0, 0.5); | sigma_obs ~ normal(0, 0.5); | |||
beta ~ normal(0, sigmas); | beta ~ normal(0, sigmas); | |||
// Likelihood | // Likelihood | |||
y ~ normal( | y ~ normal_id_glm( | |||
trend | X_sa, | |||
.* (1 + X * (beta .* s_m)) | trend .* (1 + X_sm * beta), | |||
+ X * (beta .* s_a), | beta, | |||
sigma_obs | sigma_obs | |||
); | ); | |||
} | } | |||
End of changes. 2 change blocks. | ||||
8 lines changed or deleted | 9 lines changed or added |