I have a mess on my hands. The bottom line is that I have a multivariate outcome that consists of a couple count variables and a few positive-continuous variables; in other words, multivariate but not multi-normal. My basic plan of attack is to tie the means of these outcomes in a multivariate normal. This is proving more difficult than I first thought: 1) Since the mean of the gamma is alpha/beta, I’m not sure what/how to combine this into a MVN with the other means; 2) the logistics of how to nest defined quantities such that the means end up tied together as MVN; in the code below, I have used mu_ = exp(a_) > a_ ~ MNV( nu_ ,…) > nu_ = XB.
There is an additional difficulty. Each animal was treated with both a placebo (saline) and actual treatment (LPS) such that each animal can be used as its own control. However, half of the animals previously received a complementary treatment (CCL) that is hypothesized to alter the effect of LPS. Thus, unlike for saline/LPS, in which each subject is tested under both conditions, a CCL parameter is aliased if animal is included in the model. To overcome this, my plan is to estimate unique LPS parameters for each animal, directly compare the distribution of LPS coefficients between CCL animals vs non-CCL animals in a generated quantities block.
Any help greatly appreciated!
data {
int n; # Number of subjects = 18
int conditions; # w/LPS and w/o LPS = 2
int m; # Number of outcomes in Dark (or Light) phase = 5
int Animal[n];
int LPS[conditions];
int<lower=0> nNREMS_Dark[n * conditions];
real<lower=0, upper=43200> dNREMS_Dark[n * conditions];
int<lower=0> nREMS_Dark[n * conditions];
real<lower=0, upper=43200> dREMS_Dark[n * conditions];
real<lower=0> SWA_Dark[n * conditions];
}
parameters {
matrix[n, conditions] a_LPS_nNREMS_Dark;
matrix[n, conditions] a_LPS_dNREMS_Dark;
matrix[n, conditions] a_LPS_nREMS_Dark;
matrix[n, conditions] a_LPS_dREMS_Dark;
matrix[n, conditions] a_LPS_SWA_Dark;
corr_matrix[m] Rho_Sleep_Dark;
real<lower=0> Sigma_Sleep_Dark;
real<lower=0> scale_nNREMS_Dark;
real<lower=0> scale_dNREMS_Dark;
real<lower=0> scale_nREMS_Dark;
real<lower=0> scale_dREMS_Dark;
real<lower=0> scale_SWA_Dark;
}
model {
a_LPS_nNREMS_Dark ~ dnorm(log(48), 0.5); # based on idea that 1/3 spent in NREMS
a_LPS_dNREMS_Dark ~ dnorm(log(300), 0.5); # w/avg dNREMS ~ 5 min
a_LPS_nREMS_Dark ~ dnorm(log(48), 0.5); # based on idea that 1/10 spent in REMS
a_LPS_dREMS_Dark ~ dnorm(log(90), 0.5); # w/avg dREMS ~ 1.5 min
a_LPS_SWA_Dark ~ dnorm(log(100000), 0.5);
matrix[n, conditions] nu_nNREMS_Dark;
matrix[n, conditions] nu_dNREMS_Dark;
matrix[n, conditions] nu_nREMS_Dark;
matrix[n, conditions] nu_dREMS_Dark;
matrix[n, conditions] nu_SWA_Dark;
nu_nNREMS_Dark = a_LPS_nNREMS_Dark[Animal, LPS];
nu_dNREMS_Dark = a_LPS_dNREMS_Dark[Animal, LPS];
nu_nREMS_Dark = a_LPS_nREMS_Dark[Animal, LPS];
nu_dREMS_Dark = a_LPS_dREMS_Dark[Animal, LPS];
nu_SWA_Dark = a_SWA_nNREMS_Dark[Animal, LPS];
nu_Dark = [nu_nNREMS_Dark, nu_dNREMS_Dark, nu_nREMS_Dark, nu_dREMS_Dark, nu_SWA_Dark];
Rho_Sleep_Dark ~ lkj_corr(1);
Sigma_Sleep_Dark ~ exponential(1);
matrix[n, conditions] a_nNREMS_Dark;
matrix[n, conditions] a_dNREMS_Dark;
matrix[n, conditions] a_nREMS_Dark;
matrix[n, conditions] a_dREMS_Dark;
matrix[n, conditions] a_SWA_Dark;
a_Sleep_Dark = [a_nNREMS_Dark, a_dNREMS_Dark, a_nREMS_Dark, a_dREMS_Dark, a_SWA_Dark];
a_Sleep_Dark ~ multi_normal(nu_Dark, quad_form_diag(Rho_Sleep_Dark, Sigma_Sleep_Dark));
matrix[n, conditions] mu_nNREMS_Dark;
matrix[n, conditions] mu_dNREMS_Dark;
matrix[n, conditions] mu_nREMS_Dark;
matrix[n, conditions] mu_dREMS_Dark;
matrix[n, conditions] mu_SWA_Dark;
mu_nNREMS_Dark = exp(a_nNREMS_Dark);
mu_dNREMS_Dark = exp(a_dNREMS_Dark);
mu_nREMS_Dark = exp(a_nREMS_Dark);
mu_dREMS_Dark = exp(a_dREMS_Dark);
mu_SWA_Dark = exp(a_SWA_Dark);
scale_nNREMS_Dark ~ exponential(1);
scale_dNREMS_Dark ~ exponential(1);
scale_nREMS_Dark ~ exponential(1);
scale_dREMS_Dark ~ exponential(1);
scale_SWA_Dark ~ exponential(1);
nNREMS_Dark ~ neg_binomial_2(mu_nNREMS_Dark, scale_nNREMS_Dark);
dNREMS_Dark ~ gamma(mu_dNREMS_Dark/scale_dNREMS_Dark, 1/scale_dNREMS_Dark);
nREMS_Dark ~ neg_binomial_2(mu_nREMS_Dark, scale_nREMS_Dark);
dREMS_Dark ~ gamma(mu_dREMS_Dark/scale_dREMS_Dark, 1/scale_dREMS_Dark);
SWA_Dark ~ gamma(mu_SWA_Dark/scale_SWA_Dark, 1/scale_SWA_Dark);