[R] Unbalanced Mixed Linear Models With Nested Stratum
Ben Bolker
bbolker at gmail.com
Tue Feb 8 14:53:36 CET 2011
JaFF <el.romaro <at> gmail.com> writes:
>
>
> Hi bbolker,
>
> bbolker wrote:
> >
> > Doesn't "treatment" appear in fixed effects somewhere? Perhaps you mean
> > (Treatment+Period+Dose):Eye?
>
> Apologies for the confusion. What you referred to as "Treatment", I called
> "Dose" in my post. So in your terms, to avoid confusion, the fixed effects
> are (Subject + Period + Treatment):Eye.
>
> bbolker wrote:
> >
> > JaFF <el.romaro <at> gmail.com> writes:
> > Do you really want interactions only (:) rather than crossing (*)
> > for the fixed effects? You will get a model with the same number of
> > parameters either way, but parcelled out among effects differently.
> >
> I know it may not seem as the most natural of choices, but we are fairly
> certain of the random effects - they contain interactions only.
OK, but be careful: what do you mean by "interactions only"?
Do you mean that (for example) the average effect across eyes is
exactly zero, but that each eye has an effect in exactly the opposite
direction? I have found this sort of contrast difficult to code in R
(the designers may have made it difficult, or not bothered to try
to make it easy, because it's only rarely sensible); the only way I
know to do this is to build one's own design matrix, knock out the
relevant terms, and then use the columns of the design matrix as
(derived) variables.
> Could you please explain how does "subject:period + subject:period:eye"
> convert to "eye|subject:period"? What would "A:B:C + A:B:D:E + C" be in the
> function specification, for example?
In lme4's random effect specifications, there is an implicit
intercept term (as in most R formula contexts) for the 'variable'
part on the left side of the bar: thus (eye|subject:period) is
implicitly (1+eye|subject:period). Interactions between fixed
and random terms are written in this way (think of it as "the
intercept, and the effect of 'eye', vary across subjectxperiod
combinations). Converting your specification above (A:B:C etc.)
would I think require knowing which bits are fixed effects and
which are random effects.
One could also write the random effect out as
(1|subject:period)+(0+eye|subject:period); this would be almost
equivalent (the "0+" suppresses the implicit intercept), except
that the model would assume that the intercept and eye random
effects were independent (in the former case, an intercept-eye
correlation is estimated).
>
> Also, the line
> fit = lmer(ms ~ (subject + period + dose):eye + (eye|subject:period), data =
> sub)
> crashes my R with a runtime error. "ms" is one of the response variables I'm
> testing it on. I wanted to try it on earlier versions of R, but the package
> "lme4a" fails to install on 2.10.1, even though its pre-requisites ("minqa"
> and "MatrixModels") install fine. So I guess we'll have to find a way to
> make it work on 2.12.1 - the version I'm using. GenStat managed to analyse
> the same data just fine, so it's not a problem with the data.
>
Can you send data? Crashing R is by definition a bug ...
Ben Bolker
More information about the R-help
mailing list