Hi,
The question:
In my hierarchical model the parameters of interest are log-normally distributed, so do I still use the ‘mean’ estimates provided in the stan object after fitting as my estimate for the parameter - that is, the ‘mean’ estimates you see when running ‘print(object)’? Or am I best to calculate the mode of the (log-normal) distribution of all my draws for each parameter?
In case it is useful, here is the code snipped defining the parameters as log-normal; the full code is included at the end of the post.
noise ~ lognormal(meannoise, sdnoise);
alpha ~ lognormal(meanalpha, sdalpha);
M ~ lognormal(meanM, sdM);
The parameter of interest is ‘M’ and it is estimated separately for each individual completing my experiment.
BTW, I previously posted my model and received helpful assistance regarding ‘divergence’ before: RStan divergence issue - assistance with experimental research - I am happy to say ‘divergences’ are not a problem any longer: thank you!
Thanks for having a look and let me know if you have any further questions that I can clarify.
Cheers,
Alex
****
Here’s the full Stan model code:
data {
int N; // number of trials total (across participants), integer
int nsubj; // number of subjects,
int choices[N]; // the binary choice vector
real <lower=0> x2a[N];
real <lower=0> x1b[N];
real <lower=0> p2a[N];
real <lower=0> p1b[N];
int sid[N];
}
parameters {
// Group-level:
real<lower=-2.30, upper=1.61> meannoise; // assuming mean is 0.1 to 5 -
real<lower=0, upper=1.13> sdnoise; // according sds - calculated as sd = (b - a) / sqrt(12)
real<lower=-2.3, upper=2.3> meanalpha; // assuming mean is 0.1 to 10
real<lower=0, upper=1.33> sdalpha;
real<lower=-2.3, upper=4.5> meanM; // assuming mean is 0.1 to 90
real<lower=0, upper=1.96> sdM;
// Individual-level:
real<lower=0.1> noise[nsubj]; // Noise, constrained it to be above [0.1, INF]
real<lower=0.1> alpha[nsubj]; // alpha, constrained it to be above [0.1, INF]
real<lower=0.1> M[nsubj]; // M, constrained it to be [0.1, INF)
}
model {
real ua; // utility of the option a
real ub; // utility of the option b
// Group-level parameters:
meannoise ~ uniform(-2.30,1.61); // assuming mean is 0.1 to 5
sdnoise ~ uniform(0,1.13); // according sds
meanalpha ~ uniform(-2.3,2.3); // assuming mean is 0.1 to 10
sdalpha ~ uniform(0,1.33);
meanM ~ uniform(-2.3, 4.5); // assuming mean is 0.1 to 90
sdM ~ uniform(0,1.96);
// Individual-level parameters:
noise ~ lognormal(meannoise, sdnoise);
alpha ~ lognormal(meanalpha, sdalpha);
M ~ lognormal(meanM, sdM);
for (i in 1:N) {
int t = sid[i];
ua=0.0;
ua += p2a[i]*((x2a[i]^alpha[t])/((x2a[i]^alpha[t])+(M[t]^alpha[t])));
ub=0.0;
ub += p1b[i]*((x1b[i]^alpha[t])/((x1b[i]^alpha[t])+(M[t]^alpha[t])));
choices[i] ~ bernoulli_logit(((ua-ub)*noise[t]));
}
}