sampling weights support?

173 views
Skip to first unread message

ignacio martinez

unread,
Sep 27, 2017, 11:12:04 AM9/27/17
to brms-users
Hi everyone,

Is it possible to use sampling weights with brms (rstanarm, or stan)? In case is relevant, this is how stata does it if you are using a frequentist approach.

Thanks,

Ignacio

Paul Buerkner

unread,
Sep 27, 2017, 11:23:40 AM9/27/17
to ignacio martinez, brms-users
Let's say y is your response and w is your weight variable. Then go for

fit <- brm(y | weights(w) ~ <predictors>, ...)



--
You received this message because you are subscribed to the Google Groups "brms-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to brms-users+unsubscribe@googlegroups.com.
To post to this group, send email to brms-...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/brms-users/a2a5cd9a-3754-4f1f-8144-6e9bdb0ad6d5%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Ignacio Martinez

unread,
Sep 27, 2017, 11:28:19 AM9/27/17
to Paul Buerkner, brms-users
Thanks Paul. Is the implementation/stan model discussed somewhere?  

On Wed, Sep 27, 2017 at 11:23 AM Paul Buerkner <paul.b...@gmail.com> wrote:
Let's say y is your response and w is your weight variable. Then go for

fit <- brm(y | weights(w) ~ <predictors>, ...)



2017-09-27 17:12 GMT+02:00 ignacio martinez <igna...@gmail.com>:
Hi everyone,

Is it possible to use sampling weights with brms (rstanarm, or stan)? In case is relevant, this is how stata does it if you are using a frequentist approach.

Thanks,

Ignacio

--
You received this message because you are subscribed to the Google Groups "brms-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to brms-users+...@googlegroups.com.

Paul Buerkner

unread,
Sep 27, 2017, 11:29:24 AM9/27/17
to Ignacio Martinez, brms-users
It is discussed in ?brmsformula from a syntactical perspective.

The implementation is just a weighting of the log-likelihood.

2017-09-27 17:28 GMT+02:00 Ignacio Martinez <igna...@gmail.com>:
Thanks Paul. Is the implementation/stan model discussed somewhere?  

On Wed, Sep 27, 2017 at 11:23 AM Paul Buerkner <paul.b...@gmail.com> wrote:
Let's say y is your response and w is your weight variable. Then go for

fit <- brm(y | weights(w) ~ <predictors>, ...)



2017-09-27 17:12 GMT+02:00 ignacio martinez <igna...@gmail.com>:
Hi everyone,

Is it possible to use sampling weights with brms (rstanarm, or stan)? In case is relevant, this is how stata does it if you are using a frequentist approach.

Thanks,

Ignacio

--
You received this message because you are subscribed to the Google Groups "brms-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to brms-users+unsubscribe@googlegroups.com.

Paul Buerkner

unread,
Sep 27, 2017, 11:30:20 AM9/27/17
to Ignacio Martinez, brms-users
You can take a look at the Stan code via the stancode method or directly via the make_stancode function.

Ignacio Martinez

unread,
Sep 27, 2017, 11:33:51 AM9/27/17
to Paul Buerkner, brms-users
Thank you! 

On Wed, Sep 27, 2017 at 11:30 AM Paul Buerkner <paul.b...@gmail.com> wrote:
You can take a look at the Stan code via the stancode method or directly via the make_stancode function.
2017-09-27 17:29 GMT+02:00 Paul Buerkner <paul.b...@gmail.com>:
It is discussed in ?brmsformula from a syntactical perspective.

The implementation is just a weighting of the log-likelihood.
2017-09-27 17:28 GMT+02:00 Ignacio Martinez <igna...@gmail.com>:
Thanks Paul. Is the implementation/stan model discussed somewhere?  

On Wed, Sep 27, 2017 at 11:23 AM Paul Buerkner <paul.b...@gmail.com> wrote:
Let's say y is your response and w is your weight variable. Then go for

fit <- brm(y | weights(w) ~ <predictors>, ...)



2017-09-27 17:12 GMT+02:00 ignacio martinez <igna...@gmail.com>:
Hi everyone,

Is it possible to use sampling weights with brms (rstanarm, or stan)? In case is relevant, this is how stata does it if you are using a frequentist approach.

Thanks,

Ignacio

--
You received this message because you are subscribed to the Google Groups "brms-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to brms-users+...@googlegroups.com.

Andrew Mercer

unread,
Sep 29, 2017, 6:31:59 PM9/29/17
to brms-users
Was just looking into this. The documentation says that the the log-posterior for each case is multiplied by the weight. That doesn't seem equivalent to multiplying the likelihood by the weight. I may be missing something here though.


On Wednesday, September 27, 2017 at 11:29:24 AM UTC-4, Paul Buerkner wrote:
It is discussed in ?brmsformula from a syntactical perspective.

The implementation is just a weighting of the log-likelihood.
2017-09-27 17:28 GMT+02:00 Ignacio Martinez <igna...@gmail.com>:
Thanks Paul. Is the implementation/stan model discussed somewhere?  

On Wed, Sep 27, 2017 at 11:23 AM Paul Buerkner <paul.b...@gmail.com> wrote:
Let's say y is your response and w is your weight variable. Then go for

fit <- brm(y | weights(w) ~ <predictors>, ...)



2017-09-27 17:12 GMT+02:00 ignacio martinez <igna...@gmail.com>:
Hi everyone,

Is it possible to use sampling weights with brms (rstanarm, or stan)? In case is relevant, this is how stata does it if you are using a frequentist approach.

Thanks,

Ignacio

--
You received this message because you are subscribed to the Google Groups "brms-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to brms-users+...@googlegroups.com.

Paul Buerkner

unread,
Sep 29, 2017, 7:23:51 PM9/29/17
to Andrew Mercer, brms-users
The difference is just that in bayesian models the prior comes into play as well ;-)

To unsubscribe from this group and stop receiving emails from it, send an email to brms-users+unsubscribe@googlegroups.com.

To post to this group, send email to brms-...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages