Hi all,
I want to recover multiple correlated random walks using binomial data. Given that the global variance for the covariance matrix (here phi) may not be known with certainty I set a prior on it (here the same as the one that generated the data). The models seems to have issues getting good draws when the value is very small (like 0.005). I’d appreciate any advice for a better parameterization of the model.
data {
int N;
int S;
int T;
int s[N];
int t[N];
cov_matrix[S] cov_mat_mu_b;
int n_supp[N];
int n_resp[N];
}
transformed data {
cholesky_factor_cov[S] cholesky_cov_mu_b;
cholesky_cov_mu_b = cholesky_decompose(cov_mat_mu_b)/sqrt(rep_row_vector(1.0, S) * cov_mat_mu_b * rep_vector(1.0, S));
}
parameters {
matrix[S, T] raw_mu_b;
real<lower = 0> phi;
}
transformed parameters {
matrix[S, T] mu_b;
vector[N] theta;
cholesky_factor_cov[S] cholesky_cov_mu_b_scaled = cholesky_cov_mu_b * phi;
mu_b[, 1] =cholesky_cov_mu_b_scaled * raw_mu_b[, 1];
for (i in 2:T) mu_b[:, i] = cholesky_cov_mu_b_scaled * raw_mu_b[:, i] + mu_b[:, i - 1];
for (i in 1:N) theta[i] = mu_b[s[i], t[i]];
}
model {
phi ~ normal(0.02, 0.01);
to_vector(raw_mu_b) ~ std_normal();
n_supp ~ binomial_logit(n_resp, theta);
}