[R-sig-ME] Nonlinear mixed model in lme4
Tahira Jamil
tahirajamil at yahoo.com
Mon Mar 2 10:38:30 CET 2009
Hi
I have found this forum very useful. So thank to all who contribute to this forum.
I have a problem with non-linear mixed model. When I run the model
(nm1.a <-fixef( nlmer(logmv ~ SSfpl(logC, A, B, xmid, scal)~xmid | status,
data=mix.data,start = c(A = 0.3, B = 0.7, xmid=-1.4,scal = 0.3)))
it runs nicely and gives estimates. But when I try to extract the fixed and randoms effect it gives error as
fixef( nlmer(logmv ~ SSfpl(logC, A, B, xmid, scal)~xmid | status,
+ data=mix.data,start = c(A = 0.3, B = 0.7, xmid=-1.4,scal = 0.3)))
Error in UseMethod("fixef") : no applicable method for "fixef"
Is there some applicable method that we can extract the effects for nonlinear mixed model in lme4. In nlme I am able to extract the random effect and fixed effect. But I am interested in lme4.
Can someone guide me how lme4 differ from nlme.
Tahira Jamil
Biometris
Wageningen University Wageningen
Netherlands
--- On Sun, 3/1/09, r-sig-mixed-models-request at r-project.org <r-sig-mixed-models-request at r-project.org> wrote:
> From: r-sig-mixed-models-request at r-project.org <r-sig-mixed-models-request at r-project.org>
> Subject: R-sig-mixed-models Digest, Vol 27, Issue 1
> To: r-sig-mixed-models at r-project.org
> Date: Sunday, March 1, 2009, 4:00 PM
> Send R-sig-mixed-models mailing list submissions to
> r-sig-mixed-models at r-project.org
>
> To subscribe or unsubscribe via the World Wide Web, visit
> https://stat.ethz.ch/mailman/listinfo/r-sig-mixed-models
> or, via email, send a message with subject or body
> 'help' to
> r-sig-mixed-models-request at r-project.org
>
> You can reach the person managing the list at
> r-sig-mixed-models-owner at r-project.org
>
> When replying, please edit your Subject line so it is more
> specific
> than "Re: Contents of R-sig-mixed-models
> digest..."
>
>
> Today's Topics:
>
> 1. Re: [R] lme4 and Variable level detection (Douglas
> Bates)
>
>
> ----------------------------------------------------------------------
>
> Message: 1
> Date: Sat, 28 Feb 2009 12:25:16 -0600
> From: Douglas Bates <bates at stat.wisc.edu>
> Subject: Re: [R-sig-ME] [R] lme4 and Variable level
> detection
> To: Jeroen Ooms <j.c.l.ooms at uu.nl>
> Cc: r-help at r-project.org, R Mixed Models
> <r-sig-mixed-models at r-project.org>
> Message-ID:
> <40e66e0b0902281025p5318a0c4o565e6b5038c183a1 at mail.gmail.com>
> Content-Type: text/plain; charset=ISO-8859-1
>
> On Sat, Feb 28, 2009 at 9:00 AM, Jeroen Ooms
> <j.c.l.ooms at uu.nl> wrote:
>
> > I am making a little GUI for lme4, and I was wondering
> if there is a function
> > that automatically detects on which level every
> variable exists.
> > Furtheremore I got kind of confused about what a
> random effects model
> > actually calculates.
>
> Questions such as this may be answered more quickly if you
> send them
> to the R-SIG-Mixed-Models mailing list, which I am cc:ing
> on this
> reply.
>
> > I have some experience with commercial software
> packages for multilevel
> > analysis, like HLM6, and I was surprised that lme4
> does not require the user
> > to specify the level for every predictor variable. Is
> this because the
> > function automatically detects the level by testing on
> which levels the
> > predictor has variance, or is this information simply
> not needed?
>
> In some ways, exposure to software like HLM or MLWin can be
> more of a
> hindrance than a help when learning about mixed models. In
> presentation of the model and in the software itself these
> packages
> emphasize "levels" of random effects leading to
> the impression that we
> can only associate random effects with factors that are
> nested. This
> is a misconception. There are many cases where is it
> eminently
> sensible to associate random effects with factors that are
> completely
> crossed ('subject' and 'item' are a prime
> example) or partially
> crossed. The archetypal example used in multilevel
> modeling,
> achievement scores on students nested in classes nested in
> schools
> nested in ..., becomes partially crossed when we track
> students over
> time and they move from class to class or school to school.
>
> I imagine that the reason for defining the model in terms
> of nested
> factors for random effects is computational. If you insist
> that the
> random effects must always be defined with respect to
> nested factors
> then you can employ methods that take advantage of this,
> with
> considerable simplification in the storage and
> computational burden.
> The lme4 package adopts a different approach based on
> sparse matrix
> storage and decomposition methods. It turns out that these
> methods
> are competitive with the best methods for models based on
> nested
> factors, in the cases to which they apply, and these
> methods allow for
> fitting much more general models.
>
> An unfortunate side-effect of the emphasis on levels in
> MLWin and HLM
> is the perception that other covariates must be
> characterized by the
> level at which they vary, even if these covariates only
> determine
> fixed-effects parameters. This is quite untrue and
> misleading. The
> only constraints on the covariates and the model matrix for
> the
> fixed-effects parameters is that the model matrix must be
> of full
> column rank. In models that define random effects for
> slopes, or in
> general for the coefficients associated with a covariate,
> the
> constraint is that the covariate cannot be constant within
> each level
> of the grouping factor of the random effect. For example,
> we cannot
> estimate a random effect for the coefficients for sex (M/F)
> within
> subject (assuming we do not have transgender people in the
> study).
>
> My advice would be to avoid phrasing the model in terms of
> levels of
> random effects. Although I realize that those with a
> background of
> using MLWin or HLM may find this more comfortable, I think
> it would be
> propagating bad practices and misconceptions.
>
> > I was taught that a crosslevel interaction predicts
> the regression
> > coefficient of the lower level variable, which is also
> what is implied by
> > the HLM gui. However, in an lme4 formula, a crosslevel
> interaction has the
> > same syntax as a regular interaction term.
> Furthermore, lme4 also allows
> > adding crosslevel interactions without a random slope
> for the lower level
> > variable. Now I'm confused. Is there a fundamental
> difference between a
> > crosslevel interaction, or is the same thing as a
> regular interaction when
> > the model also holds an error term for the lower level
> variable?
> >
> >
> >
> >
> > -----
> > Jeroen Ooms * Dept. of Methodology and Statistics *
> Utrecht University
> >
> > Visit ?http://www.jeroenooms.com www.jeroenooms.com
> ?to explore some of my
> > current projects.
> >
> >
> >
> >
> >
> >
> > --
> > View this message in context:
> http://www.nabble.com/lme4-and-Variable-level-detection-tp22262944p22262944.html
> > Sent from the R help mailing list archive at
> Nabble.com.
> >
> > ______________________________________________
> > R-help at r-project.org 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.
> >
>
>
>
> ------------------------------
>
> _______________________________________________
> R-sig-mixed-models mailing list
> R-sig-mixed-models at r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-sig-mixed-models
>
>
> End of R-sig-mixed-models Digest, Vol 27, Issue 1
> *************************************************
More information about the R-sig-mixed-models
mailing list