[R] help
Spencer Graves
spencer.graves at pdf.com
Fri Dec 1 05:36:17 CET 2006
In case you haven't already received an adequate reply (which I
haven't seen) or figured this out on your own, I will comment. Consider
the following modifications of an example in the 'lmer' documentation:
(fm0.0 <- lmer(Reaction~(1|Subject), sleepstudy))
(fm0.1 <- lmer(Reaction~1+(1|Subject), sleepstudy))
(fm0.s <- lmer(Reaction~Subject+(1|Subject), sleepstudy))
The first two models are equivalent, as can be seen from looking
at the output. In the "formula" language, something like "Reaction~X"
means to estimate an intercept plus an X effect. If you want a
no-constant model, you must specify "Reaction ~ -1+X". When X is a
factor, "Reaction ~ -1+X" effectively fits the same model as
"Reaction~X" using an alternative parameterization. If X is numeric,
"Reaction~X" means estimate b0 and b1 in Reaction = b0 + b1*X + error.
Meanwhile, "Reaction ~ -1+X" means estimate only b1 in Reaction = b1*X +
error. In this latter case, the introduction of "-1" actually changes
the model.
The third model "Reaction~Subject+(1+Subject) is a confusion: The
"~Subject" part asks lmer to estimate a separate parameter for each
Subject. The (1|Subject) term asks lmer to estimate the standard
deviation for between-Subject random variability after the fixed effects
are removed. Since Subject is also listed as a fixed effect in this
model, the model is overparameterized: I'm not certain, but it appears
to me that the software doesn't know whether to allocate
subject-specific deviations from the overall mean to the fixed effects
coefficients or the random effect, and it appears to do a little of both.
It might be nice if 'lmer' included a check for factors appearing
as both fixed and random effects. However, I believe that 'lme4' and (R
more generally) is primarily a research platform for new statistical
algorithm development. Most of the R Core Team work to maintain R under
the GNU license primarily because it supports their research (and
educational) objectives. The product therefore may not strive to be as
supportive for naive users as commercial software.
Hope this helps.
Spencer Graves
Aimin Yan wrote:
> consider p as random effect with 5 levels, what is difference between these
> two models?
>
> > p5.random.p <- lmer(Y
> ~p+(1|p),data=p5,family=binomial,control=list(usePQL=FALSE,msV=1))
> > p5.random.p1 <- lmer(Y
> ~1+(1|p),data=p5,family=binomial,control=list(usePQL=FALSE,msV=1))
>
> thanks,
>
> Aimin Yan
>
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>
More information about the R-help
mailing list