The dataset is quite large: S=56, C=35000. The model works fine for e.g. C= 100, but now I need to include all the data. The process is just using a small part of the memory of the server (120 GB) and there's plenty of disk space.
Any suggestions on what the problem is and how to make it work? Should I optimize the code somehow? If the dataset is too large, how can I assess what the limit would be ?
data {
int<lower=0> S; // number of subjects
int<lower=0> C; // number of connections
real values[C, S]; // values
real age[S]; // age
}
parameters {
// global parameters governing distribution of connection-specific intercepts and slopes
real<lower=-1, upper=1> intercept_muc_mu;
real<lower=0, upper=1> intercept_muc_sigma;
real<lower=-.01, upper=.01> slope_muc_mu;
real<lower=0, upper=.1> slope_muc_sigma;
real<lower=-4, upper=0> log_intercept_sigmac_mu;
real<lower=0, upper=1> log_intercept_sigmac_sigma;
real<lower=-.03, upper=.03> log_slope_sigmac_mu;
real<lower=0, upper=.5> log_slope_sigmac_sigma;
// connection-specific intercepts and slopes
real<lower=-3, upper=3> intercept_muc[C];
real<lower=-.3, upper=.3> slope_muc[C];
real<lower=-6, upper=1> log_intercept_sigmac[C];
real<lower=-.3, upper=.3> log_slope_sigmac[C];
}
transformed parameters {
real muc[C, S];
real<lower=0> sigmac[C, S];
for (c in 1:C)
{
for (s in 1:S){
muc[c, s] <- intercept_muc[c] + slope_muc[c]*age[s];
sigmac[c, s] <- exp(log_intercept_sigmac[c] + log_slope_sigmac[c]*age[s]);
}
}
}
model {
// priors
intercept_muc_mu ~ normal(0, .5);
intercept_muc_sigma ~ uniform(0, 1);
slope_muc_mu ~ normal(0, .005);
slope_muc_sigma ~ uniform(0, .1);
log_intercept_sigmac_mu ~ uniform(-4, 0); //normal(-2, .5);
log_intercept_sigmac_sigma ~ uniform(0, 1);
log_slope_sigmac_mu ~ normal(0, .01);
log_slope_sigmac_sigma ~ uniform(0, .5);
intercept_muc ~ normal(intercept_muc_mu, intercept_muc_sigma);
slope_muc ~ normal(slope_muc_mu, slope_muc_sigma);
log_intercept_sigmac ~ normal(log_intercept_sigmac_mu, log_intercept_sigmac_sigma);
log_slope_sigmac ~ normal(log_slope_sigmac_mu, log_slope_sigmac_sigma);
for (c in 1:C)
{
for (s in 1:S){
print(sigmac[c, s])
values[c, s] ~ normal(muc[c, s], sigmac[c, s]);
}
}
}