I using rstan to estimate the average time use for different laboratory analysis. The model is
T = a*beta, where T is a vector of length N of time used per person in different projects, a is a NxA matrix with counts of analysis performed. There are A different analysis types. Beta is the expression for a vector of length A of average times that I would like to estimate.
There exists estimates of time use from before, and I would prefer to use these in the prior for each beta to be estimated.
The model code is
progm ← "
data {
int<lower = 0> N;
int<lower = 0> A;
vector<lower = 0>[A] bp;
vector<lower = 0>[A] beta_sigma;
vector<lower = 0>[N] t;
matrix<lower = 0>[N,A] a;
}
parameters {
vector<lower = 0>[A] beta;
vector<lower = 0>[A] sigma;
}
model {
t ~ normal(a * beta, sigma);
beta ~ normal(bp, beta_sigma);
sigma ~ exponential(3);
}
"
sim1 ← stan(model_code = progm,
data = list(N = nrow(ma), A = ncol(ma),
t = vt, a = ma,
bp = beta_prior, beta_sigma = beta_sigma),
chains = 1, iter=5000*2, seed = 2345)
I have tried to indicate the individual priors as beta ~ normal(bp, beta_sigma), where bp is a vector of length A of the existing estimates, and beta_sigma is a vector of length A of identical values 0.1. This formulation causes an error. The program works fine with an identical prior distribution for all beta.