Hi,
I’ve been using map2stan to fit a multilevel model to a dataset. I was hoping to model the difference in variance between individuals, and am having difficulty achieving this.
Here’s a dummy example of the approach I have been taking:
nullModel <- ulam(
alist(
outcome ~ dnorm(mu, sigma),
mu <- a[ID] + beta[ID] * predictor,
# Individual-level priors
a[ID] ~ dnorm(a_mu, a_sig),
beta[ID] ~ dnorm(beta_mu, beta_sig),
sigma ~ dcauchy(0, 2),
# Hyperparameter priors
a_mu ~ dnorm(0, 2),
a_sig ~ dcauchy(0, 1) & T[0,],
beta_mu ~ dnorm(0, 2),
beta_sig ~ dcauchy(0, 1) & T[0,]
), data = d )
The issue arises from the fact that I expect some difference between individuals in the variance of their scores. My question is, how can I specify the model such that I end up with individual a
, beta
, and sigma
parameters for each individual in the grouping structure?
My initial attempt involved applying the same approach to the sigma parameter, like so:
sigma ~ dcauchy(sigma_mu, sigma_sig),
sigma_mu ~ dnorm(0, 2),
sigma_sig ~ dcauchy(0, 1)
However, this returned the error message:
invalid class “map2stan” object: invalid object for slot “coef” in class “map2stan”: got class “NULL”, should be or extend class “numeric”
Am I going about this the wrong way? Any advice is hugely appreciated.
Sorry for any naïvety in my question, too!