[R] lmer function
Douglas Bates
bates at stat.wisc.edu
Wed May 16 18:43:00 CEST 2007
On 5/16/07, Iasonas Lamprianou <lamprianou at yahoo.com> wrote:
> Dear all,
> the question was if lmer can estimate the variance components correctly,
> although my design is very UNbalanced.
Yes, lmer can handle unbalanced data and large data sets.
> Also, how do I find the percentage of the variance from every component? Do
> I have to add all the variance components and then divide each one by the
> total?
Yes, that should do it.
I enclose a short function to automate the process by extracting the
information from the value of VarCorr.
> P.S. lmer is excellent. It can estimate large datasets where SPSS gives me
> error messages and says it cannot estimate them. Keep on good work
> friends!!!!!
Thank you. It's wonderful to hear that it is helpful. The main
objective in developing lmer was to be able to handle large data sets
with crossed or partially crossed random effects.
> ----- Original Message ----
> From: Douglas Bates <bates at stat.wisc.edu>
> To: Steven McKinney <smckinney at bccrc.ca>
> Cc: Iasonas Lamprianou <lamprianou at yahoo.com>; r-help at stat.math.ethz.ch
> Sent: Tuesday, 15 May, 2007 2:17:34 AM
> Subject: Re: [R] lmer function
>
>
> On 5/14/07, Steven McKinney <smckinney at bccrc.ca> wrote:
> >
> > Running lme4 0.9975-13
> > I'm still getting the warning
> >
> > $ operator not defined for this S4 class, returning NULL in:
> x$symbolic.cor
>
> It was my mistake. I fixed the problem in the development sources
> long ago but I haven't uploaded a new release since doing so. I'll
> upload a new release next week - this is finals week for us and they
> seem to expect that we will do things like grade exams rather than
> debugging code. :-)
>
> > Is there a more recent version?
> > Is there any known problem with this warning
> > (incorrect results etc.) ?
>
> Not really. It is a benign cut-and-paste error. If you want to fix
> it now look for the function printMer in the source file lme4/R/lmer.R
> and change the default for the symbolic.cor argument to FALSE.
>
> > > sessionInfo()
> > R version 2.5.0 (2007-04-23)
> > powerpc-apple-darwin8.9.1
> >
> > locale:
> > C
> >
> > attached base packages:
> > [1] "stats" "graphics" "grDevices" "utils" "datasets" "methods"
> > [7] "base"
> >
> > other attached packages:
> > lme4 Matrix lattice
> > "0.9975-13" "0.9975-11" "0.15-4"
> > >
> >
> > Steven McKinney
> >
> > Statistician
> > Molecular Oncology and Breast Cancer Program
> > British Columbia Cancer Research Centre
> >
> > email: smckinney at bccrc.ca
> >
> > tel: 604-675-8000 x7561
> >
> > BCCRC
> > Molecular Oncology
> > 675 West 10th Ave, Floor 4
> > Vancouver B.C.
> > V5Z 1L3
> > Canada
> >
> >
> >
> >
> > -----Original Message-----
> > From: r-help-bounces at stat.math.ethz.ch on behalf of
> Douglas Bates
> > Sent: Mon 5/14/2007 12:43 PM
> > To: Iasonas Lamprianou
> > Cc: r-help at stat.math.ethz.ch
> > Subject: Re: [R] lmer function
> >
> > On 5/14/07, Iasonas Lamprianou <lamprianou at yahoo.com> wrote:
> > > Does anyone know if the lmer function of lme4 works fine for unbalanced
> designs? I have the examination results of 1000 pupils on three subjects,
> one score every term. So, I have three scores for English (one for every
> term), three scores for maths etc. However, not everybody was examined in
> maths, not everybody was examined in English etc, but everybody was in
> effect examined on four subjects. I also have information abouit the school.
> Would this model hive the right results for the variance components?
> > >
> > > mod_3_f <- lmer(SCORE ~ GENDER + (1 |ID ) + (1 | TERM) + (1 | SUBJECT)
> , Dataset)
> > >
> > > Linear mixed-effects model fit by REML
> > > Formula: SCORE ~ GENDER + (1 | ID) + (1 | TERM) + (1 | SUBJECT)
> > > Data: Dataset
> > > AIC BIC logLik MLdeviance REMLdeviance
> > > 247882 247926 -123936 247871 247872
> > > Random effects:
> > > Groups Name Variance Std.Dev.
> > > ID (Intercept) 5.97288 2.44395
> > > TERM (Intercept) 5.10307 2.25900
> > > SUBJECT (Intercept) 0.25943 0.50934
> > > Residual 4.41673 2.10160
> > > number of obs: 53978, groups: ID, 5695; TERM, 4; SUBJECT, 4
> > > Fixed effects:
> > > Estimate Std. Error t value
> > > (Intercept) 14.30352 1.15870 12.34
> > > GENDER[T.Male] -1.01776 0.06885 -14.78
> > > Correlation of Fixed Effects:
> > > Warning in x$symbolic.cor : $ operator not defined for this S4 class,
> returning NULL
> >
> > What version of the lme4 package are you using? (Use sessionInfo() to
> > check.) I think the bug that causes that warning has been fixed in
> > the most recent version.
> >
> > > (Intr)
> > > GENDER[T.M] -0.023
> >
> > > How do I interpert the results?
> >
> > Do you really want to treat SUBJECT as a random effect? I think it
> > would be more common to treat it as a fixed effect. If I understand
> > you correctly there are only two levels of SUBJECT and these are
> > repeatable levels. If that is the case one could model SUBJECT as a
> > fixed effect or consider its interaction within student with the term
> > (SUBJECT|ID).
> >
> > It would make sense to regard the pair of responses in maths and
> > English for each student in each term as a multivariate response but,
> > at present, that model cannot be fit with lmer.
> >
> > I would also question whether you want the TERM to be modeled with a
> > random effect.
> >
> > ______________________________________________
> > 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.
> >
> >
>
> ________________________________
> Yahoo! Mail is the world's favourite email. Don't settle for less, sign up
> for your free account today.
More information about the R-help
mailing list