# Examples of Hierarchical GLMs with Time-Dependent Variance?

Hello everyone!

I am a grad student just getting started in Stan and am writing with a request for example code. I really appreciate any help you can offer!

The setting: The problem I’m trying to model involves S subjects who make N repeated choices to accept or reject applicants for a job over T years. I hypothesize that each subject S has a preferred rejection rate (call this their “ideal point”–how eager they are to accept applicants in general) that is fixed over time. But with each passing year, each subject S has to process more applications, which I hypothesize increases the variance around each subject’s preferred rejection rate. In short, even though some subject S still has some influence over the rejection/acceptance, the relative signal from their preferences shrinks as T --> infty. The goal is to recover good estimates of this variance parameter, which has some independent substantive interest to my research.

This is similar to a dynamic random effect concept, except that the idea here is to model changing variance over time rather than changes in the mean of the random effect.

The ask: Are there any gold standard examples for modelling shifting variance parameters over time (ideally in the hierarchical logit setting)?

I apologize in advance if this is the wrong forum for seeking example code! I’ve found the examples in the Stan manual and on this forum extremely useful and would be grateful for any examples focused on modelling variance. Thank you, again!

You may want to look into mixed effects location scale models (MELSM).

The simplest gist is to do a random effects model, except you predict the (log) scale parameter to a distribution.

You can do both, of course; in the case of a normal distribution:
y ~ normal(muhat, sigmahat)
muhat = f(location predictors)
sigmahat = exp(g(scale predictors))

That is, just implement a random effects model for both the location (if you want) and the scale (with a log link)).
E.g., in brms, you can just use `brmsformula(outcome ~ 1 + (1|c|person), sigma ~ 1 + time + (1|c|person))`, then sigma[i,t] = exp(b0 + time[i,t]*b1 + u1i).
Make sense?

For GLMs, it’s largely the same thing; just predict the scale parameter with a random effects log-linear model.

Thank you so very much! This was extremely helpful.