-
-
Notifications
You must be signed in to change notification settings - Fork 191
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature request: Allow weights to also be specified at group level #1719
Comments
I like this idea. My suggestion for syntax would be y | weights(w) ~ x + ( 1 | gr(g, weights = w_g) ) The |
Thanks, Paul. I think that syntax using I inspected the |
Makes sense, so we need an actual new feature for this. At least the user-interface (something like |
along with unit tests.
Summary
This request is to allow the user to specify not only unit-level weights in a brms formula, but group-level weights as well. This would extend the current syntax from this:
to maybe something like this
where$w$ is a unit-level weight variable with potentially $n$ distinct values, and $w_g$ is a group-level weight variable with one value per group.
I don't know what the best syntax for this functionality would be, but I hope this illustrates the idea well enough.
The motivation for this is to make
brms
able to fit survey-weighted multilevel models: Savitsky and Williams (2022) showed that only weighting the unit-level likelihood doesn't produce reasonable estimates for multilevel models, but adding group-level weights to the random effects' priors works well.I think would be a valuable addition to
brms
for many folks who want to analyze data from health and social surveys. I would be happy to work on implementing this if you are open to it and have a preferred way for how this would look.Example Data
Below is an example dataset of size$n=6$ with $M=3$ groups. The variable
w
is a unit level weight, and the variablew_g
is a group-level weight.We want to estimate a simple varying-intercepts model of the form
y ~ x + (1 | g)
.Below is Stan code that would be generated for this model:
Click to show generated Stan code
Details
The context that motivates this request is the situation where the analyst has data from a complex survey sample with sample weights and they want to fit a model with group-level parameters (i.e., random intercepts or other group-varying parameters).
The current formula syntax allows users to specify unit-level weights that go into the model likelihood at the unit level, using the syntax
The key part of the generated Stan code that uses the weights is highlighted below:
When there are group-varying parameters in the model, such as random intercepts, Savitsky and Williams (2022) showed that the above approach (which they call "single weighting") is insufficient: it tends to produce substantial bias in estimation of the variance parameters and the group-varying parameters.
They showed though that reasonable estimates can be obtained with a strategy they called "double weighting", which applies weights at the individual level and also at the group level. In other words, this approach weights the likelihood as well as the prior on the random effects, where the weights for the prior are group-level weights.
Below is what this could look like in the Stan code:
The text was updated successfully, but these errors were encountered: