should be:
target += bilognormal_lpdf(nu_tau | [0.57, -2.3]‘, [0.2462207, 1.26]’, rho);
Sorry, it was the uncorrected model in my copy&paste, since I got problems with discourse
formatting, I re-pasted the “old” model. I checked again, should compile now. But its after midnight,
my time, time is already late for me.
1 Like
I’m working to extend my model with an AR(1) component. I also ran into the low energy issue. I’ve done some background reading on “energy” and also read Michael’s low energy guide.
I used @claudiofronterre’s pairs function above that focuses on “energy” with the mu
hyperparameter and three of the ~ 20 or so group specific estimates. As an aside @claudiofronterre, somehow my extract
function was masked in the global env, so I had to add rstan::extract
.
Am I right to conclude this bimodality in mu_phi
is a likely source of the issue?
Here’s the model for reference,
data {
int<lower=1> J; // number of apps
int<lower=1> N; // number of observations, the rows
int K; // number of features, the columns
int<lower=0> y[N]; // dependent variable index by the number of rows
matrix[N, K] X; // trend covariates
matrix[N, K] X2; // action covariates
matrix[N, K] X3; // lagged y
int IDs[N]; // apps
}
parameters {
real mu_alpha_raw;
real<lower=0> tau_alpha_raw; // hyper parameter for alpha variance
// I split out the intercept from other paraters in the design matrix;
vector[J] alpha; // the intercepts indexed by J apps
vector[K] beta; // a feature parameter K in length
vector[K] action_slope; // a feature parameter K in length
vector<lower=0>[J] theta;
real<lower=0> mu_theta;
real<lower=0> tau_theta;
real mu_action_slope_raw;
real<lower=0> tau_action_slope_raw;
real mu_beta_raw;
real<lower=0> tau_beta_raw;
real mu_phi;
real tau_phi;
vector[K] phi;
}
transformed parameters {
real mu_action_slope = 0.5 + 0.2 * mu_action_slope_raw;
real<lower=0> tau_action_slope = 0.6 + 0.05 * tau_action_slope_raw;
real mu_beta = (0.05 * mu_beta_raw) - 0.3;
real<lower=0> tau_beta = 0.07 + 0.05 * tau_beta_raw;
}
model {
real mu_alpha;
real tau_alpha;
mu_phi ~ normal(0, 0.25);
tau_phi ~ normal(0.5, 0.5);
phi ~ normal(mu_phi, tau_phi);
mu_theta ~ normal(1, 5);
tau_theta ~ normal(3.6, 4);
theta ~ normal(mu_theta, tau_theta);
mu_alpha = 0.56 + 0.2 * mu_alpha_raw;
mu_alpha_raw ~ normal(0, 1);
tau_alpha = 2.4 + 0.3 * tau_alpha_raw;
tau_alpha_raw ~ normal(0, 1);
alpha ~ normal(mu_alpha, tau_alpha);
mu_beta_raw ~ normal(0, 1);
tau_beta_raw ~ normal(0, 1);
beta ~ normal(mu_beta, tau_beta);
mu_action_slope_raw ~ normal(0, 1);
tau_action_slope_raw ~ normal(0, 0.05);
action_slope ~ normal(mu_action_slope, tau_action_slope);
y ~ neg_binomial_2_log(alpha[IDs] + X * beta + X2 * action_slope + X3 * phi, theta[IDs]);
}
EDIT: perhaps it was naive to slap a simple AR(1) process into this model? It looks like the condition (?) of stationarity is not so simple for discrete distributions (another source). For those following along, here’s a previous post where Bob walks through a Poisson AR(1) model.
The first thing I’d try here is non-centering phi
.
1 Like