Hi,
I’d love some feedback to confirm my understanding regarding parameter value assignment when using a hierarchical model.
Background:
I am using a model (attached at the end) to estimate parameters for individual subjects, say n=500, who each made individual choices during a task say, 100. This means I will have a dataset with 50.000 rows.
So far, I’ve defined a model with mean and sd priors, plus 500 individual-level parameters. And the model works fine (no computational warnings, and returns simulated data values fine).
However, I noticed something interesting when running the model on a subset of the participants: say I remove 100 of them so that now I have data set with n = 400 (i.e., 40.000 rows). If I forget to update the number of parameter to the new number of subjects (so I still have 500 parameters declared rather than the now correct 400), these 100 ‘phantom’ parameter are still given a value, despite there not being any observations to fit to these 100 parameters (given there is no subject id with choice-observations for these parameter values).
The Question: Does this occur because in the case of the 100 ‘phantom’ parameters the model bases the estimate only on the priors/distribution and not on choices (because there are none)?
Cheers,
Alex
**the model/code in case it’s helpful***
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]; // Reward Expectation, 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]));
}
}