Please also provide the following information in addition to your question:

- Operating System: Mac OS
- brms Version: 2.10.0

Hello, I’m looking to build a relatively simple model where I can manually control a scaling factor on the observation variance.

I have a number of independent observations y1, …, yn. Each observation comes from a normal distribution with a variance of sigma_sqrd / n_i, where n_i is a known value for each observation and I want to estimate sigma as a parameter. I then want to regress these y values on a set of fixed and random effects. How do I set up a model with a variance structure like this?

Thanks,

Eric.

I don’t know how to do that in brms, but the basic Stan model would be something like:

```
data {
int N;
real y[N];
real n_i[N];
}
parameters {
real mu;
real<lower = 0.0> sigma_sqrd;
}
model {
// change these priors to make sense
mu ~ normal(0, whatever);
sigma_sqrd ~ normal(0, whatever2);
for(n in 1:N) {
y[n] ~ normal(mu, sqrt(sigma_sqrd / n_i[n])); // normal in Stan is
// parameterized in terms of standard deviation
}
}
```

I didn’t check this compiled or ran, by the way. But it should be close to working. Any chance you can do it in base Stan, or is the model just too complicated?

2 Likes

I ended up just implementing it in base stan, thanks!

1 Like