On Tue, Aug 26, 2014 at 11:02 AM, Brent Pedersen <
bped...@gmail.com> wrote:
> Hi, I'm trying to recreate this lme4 fit in MixedLM (unrelated random
> intercepts):
>
> print(summary(lmer('methylation ~ asthma + age + gender + (1|id) +
> (1|CpG)', df)))
>
> Here's one variation of what I have tried:
>
> m = MixedLM.from_formula('methylation ~ asthma + age + gender',
> groups='id', re_formula="id + CpG", data=df)
> r = m.fit(free=(np.ones(2), np.eye(m.k_re)))
> print r.summary()
>
> I'm not clear on how the groups and the re_formula interact and this
> particular incantation runs without terminating. What am I missing?
I'll try a guess to see if I understand formulas and Mixed enough now,
and let Kerby correct or confirm
'methylation ~ asthma + age + gender + (1|id) + (1|CpG)`
is a two factor or crossed random effect model, that is currently not
yet covered in MixedLM
aside: constant only like here `(1|id) + (1|CpG)` would be covered in
the PanelModel PR, that allows for crossed/2-factor random constants,
but not random slope coefficients.
what MixedLM currently implements is:
'methylation ~ asthma + age + gender + (1 + CpG | id)`
which would correspond to
m = MixedLM.from_formula('methylation ~ asthma + age + gender',
groups='id', re_formula="1 + CpG", data=df)
(the `1 +` is most likely redundant)
that is, the constant and the slope coefficients for `CpG` vary by
`id` as random effects (distributed as bivariate normal)
running without terminating is always a bug and needs to be fixed with
`prio-high`
>
> BTW, the docstring for MixedLM mentions set_random() which seems to no
> longer exist.
this became obsolete with the inclusion of `re_formula` in
`from_formula`, AFAIR.
Thanks for reporting back.
Josef
>
> thanks,
> -Brent