Do you support lme4 type formula?

21 views
Skip to first unread message

Etienne Tremblay

unread,
Jan 28, 2018, 8:23:20 PM1/28/18
to PyData
Hi,

I wanted to know if you support lme4 type formula for hierarchical models?  For example:

MLexamp.8 <- lmer(extro ~ open + agree + social + (1 | school/class), data = lmm.data)

Here the (1|school/class) says that we want to fit a mixed effect term for varying intercepts 1| by schools, and for classes that are nested within schools.

This would be really helpful in doing bayesian hierarchical model in PyMC3.

Thank you!

Stephan Hoyer

unread,
Jan 28, 2018, 11:39:55 PM1/28/18
to pyd...@googlegroups.com
Hi Etienne,

Formula syntax for the PyData ecosystem is implemented by patsy:
https://github.com/pydata/patsy

I would suggest raising an issue on its GitHub page to discuss this.

Cheers,
Stephan
--
You received this message because you are subscribed to the Google Groups "PyData" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pydata+un...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Nathaniel Smith

unread,
Jan 29, 2018, 2:30:43 AM1/29/18
to pyd...@googlegroups.com
There's a bit of a chicken-and-the-egg problem here -- to fit a
mixed-effect model using lme4 syntax, you need (a) patsy support to
parse the special formula syntax, (b) some statistical package that
knows how to interpret this special formula output and do mixed-effect
fitting.

Internally, Patsy's parser is extensible, because this is one of the
use cases I had in mind when writing it... but no packages have ever
asked to take advantage of that, so I've never gotten around to
working out a proper API for them to use.
--
Nathaniel J. Smith -- https://vorpus.org

josef...@gmail.com

unread,
Jan 29, 2018, 8:21:39 AM1/29/18
to pyd...@googlegroups.com
On Mon, Jan 29, 2018 at 2:30 AM, Nathaniel Smith <n...@vorpus.org> wrote:
There's a bit of a chicken-and-the-egg problem here -- to fit a
mixed-effect model using lme4 syntax, you need (a) patsy support to
parse the special formula syntax, (b) some statistical package that
knows how to interpret this special formula output and do mixed-effect
fitting.

Internally, Patsy's parser is extensible, because this is one of the
use cases I had in mind when writing it... but no packages have ever
asked to take advantage of that, so I've never gotten around to
working out a proper API for them to use.

statsmodels is using a more explicit signature instead of using `|` in the formula.

Josef


 

On Sun, Jan 28, 2018 at 8:39 PM, Stephan Hoyer <sho...@gmail.com> wrote:
> Hi Etienne,
>
> Formula syntax for the PyData ecosystem is implemented by patsy:
> https://github.com/pydata/patsy
>
> I would suggest raising an issue on its GitHub page to discuss this.
>
> Cheers,
> Stephan
>
> On Sun, Jan 28, 2018 at 5:23 PM Etienne Tremblay <etre...@gmail.com>
> wrote:
>>
>> Hi,
>>
>> I wanted to know if you support lme4 type formula for hierarchical models?
>> For example:
>>
>> MLexamp.8 <- lmer(extro ~ open + agree + social + (1 | school/class), data
>> = lmm.data)
>>
>> Here the (1|school/class) says that we want to fit a mixed effect term for
>> varying intercepts 1| by schools, and for classes that are nested within
>> schools.
>>
>> This would be really helpful in doing bayesian hierarchical model in
>> PyMC3.
>>
>> Thank you!
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "PyData" group.
>> To unsubscribe from this group and stop receiving emails from it, send an

>> For more options, visit https://groups.google.com/d/optout.
>
> --
> You received this message because you are subscribed to the Google Groups
> "PyData" group.
> To unsubscribe from this group and stop receiving emails from it, send an

> For more options, visit https://groups.google.com/d/optout.



--
Nathaniel J. Smith -- https://vorpus.org
--
You received this message because you are subscribed to the Google Groups "PyData" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pydata+unsubscribe@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages