From 625c3992b7799f859c093dd74a5c2b74363ded21 Mon Sep 17 00:00:00 2001 From: Ben Letham Date: Sun, 26 Feb 2017 10:59:11 +0200 Subject: [PATCH] Removing stan files from root directory since they are now included in both R and Python directory. This means code duplication, but it seems that there can be issues in Windows with symlinks in github (http://stackoverflow.com/questions/5917249/git-symlinks-in-windows) so we are better off not using them. --- stan/prophet_linear_growth.stan | 40 -------------------- stan/prophet_logistic_growth.stan | 63 ------------------------------- 2 files changed, 103 deletions(-) delete mode 100644 stan/prophet_linear_growth.stan delete mode 100644 stan/prophet_logistic_growth.stan diff --git a/stan/prophet_linear_growth.stan b/stan/prophet_linear_growth.stan deleted file mode 100644 index 27c6458..0000000 --- a/stan/prophet_linear_growth.stan +++ /dev/null @@ -1,40 +0,0 @@ -data { - int T; // Sample size - int K; // Number of seasonal vectors - vector[T] t; // Day - vector[T] y; // Time-series - int S; // Number of split points - matrix[T, S] A; // Split indicators - int s_indx[S]; // Index of split points - matrix[T,K] X; // season vectors - real sigma; // scale on seasonality prior - real tau; // scale on changepoints prior -} - -parameters { - real k; // Base growth rate - real m; // offset - vector[S] delta; // Rate adjustments - real 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[s_indx[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); -} diff --git a/stan/prophet_logistic_growth.stan b/stan/prophet_logistic_growth.stan deleted file mode 100644 index bea299c..0000000 --- a/stan/prophet_logistic_growth.stan +++ /dev/null @@ -1,63 +0,0 @@ -data { - int T; // Sample size - int K; // Number of seasonal vectors - vector[T] t; // Day - vector[T] cap; // Capacities - vector[T] y; // Time-series - int S; // Number of split points - matrix[T, S] A; // Split indicators - int s_indx[S]; // Index of split points - matrix[T,K] X; // season vectors - real sigma; // scale on seasonality prior - real tau; // scale on changepoints prior -} - - -transformed data { - int s_ext[S + 1]; // Segment endpoints - for (j in 1:S) { - s_ext[j] = s_indx[j]; - } - s_ext[S + 1] = T + 1; // Used for the m_adj loop below. -} - - -parameters { - real k; // Base growth rate - real m; // offset - vector[S] delta; // Rate adjustments - real sigma_obs; // Observation noise (incl. seasonal variation) - vector[K] beta; // seasonal vector -} - - -transformed parameters { - vector[S] gamma; // adjusted offsets, for piecewise continuity - vector[S + 1] k_s; // actual rate in each segment - real m_pr; - - // Compute the rate in each segment - k_s[1] = k; - for (i in 1:S) { - k_s[i + 1] = k_s[i] + delta[i]; - } - - // Piecewise offsets - m_pr = m; // The offset in the previous segment - for (i in 1:S) { - gamma[i] = (t[s_indx[i]] - m_pr) * (1 - k_s[i] / k_s[i + 1]); - m_pr = m_pr + gamma[i]; // update for the next segment - } -} - -model { - //priors - k ~ normal(0, 5); - m ~ normal(0, 5); - delta ~ double_exponential(0, tau); - sigma_obs ~ normal(0, 0.1); - beta ~ normal(0, sigma); - - // Likelihood - y ~ normal(cap ./ (1 + exp(-(k + A * delta) .* (t - (m + A * gamma)))) + X * beta, sigma_obs); -}