[R-sig-ME] New alpha release of lme4 available on R-forge

Douglas Bates bates at stat.wisc.edu
Thu Jan 31 20:46:24 CET 2008


On Jan 31, 2008 12:07 PM, Douglas Bates <bates at stat.wisc.edu> wrote:
> Thanks for the report David.

> As you have seen there are two problems here.  One is that the offset
> slot is being assigned an integer vector but I try to use it as a
> double vector.  (One of the latent issues in the S4 class system is
> whether "numeric" is an atomic class and whether "integer" inherits
> from "numeric".)  I will simply add a coercion of the offset to a
> double before installing it in the slot.

Now fixed and committed.

> Even with that corrected there seems to be a problem with the
> evaluation of the deviance.  I'll take a longer look at that.

The problem is with the values of the offset.  Perhaps I am
misunderstanding the use of offset but I add the offset, when
specified, to the value of the linear predictor.  Because the values
of the offset are sometimes in the thousands, this makes for very
large values of the linear predictor (the 'eta' slot) and when the
inverse link function is applied some of the elements of mu become
infinite.

If I read the section in McCullagh and Nelder correctly the offset for
this example should be log(service), not service.

I enclose a sample run of how I think the model should be fit, both in
glm and in lmer/glmer.

I am grateful for the example because it exposed a bug in the call to
glm.fit within the glmer function.  That too is now fixed and
committed.

> On Jan 31, 2008 12:35 AM, David Duffy <David.Duffy at qimr.edu.au> wrote:
> > On Wed, 30 Jan 2008, Douglas Bates wrote:
> >
> > > There is a new alpha release (0.999375-2) of the lme4 package on
> > > R-forge.R-project.org.  Major changes in this release are:
> > >
> >
> > I haven't had much luck with the ships example
> >
> > R version 2.6.1 Patched (2007-12-18 r43730)
> > i686-pc-linux-gnu
> >
> > attached base packages:
> > [1] stats     graphics  grDevices utils     datasets  methods   base
> >
> > other attached packages:
> > [1] MASS_7.2-38       lme4_0.999375-2   Matrix_0.999375-4 lattice_0.17-2
> >
> > library(lme4)
> > library(MASS)
> > data(ships)
> > ships$period <- as.factor(ships$period)
> > ships$year <- as.factor(ships$year)
> > lmer(formula = incidents ~ type + (1 | period/year) + (1 | year),
> >       data = ships[ships$service>0,], family = poisson, offset = service,
> >       verbose=TRUE)
> >
> > Error in mer_finalize(ans, verbose) :
> >    REAL() can only be applied to a 'numeric', not a 'integer'
> >
> > > debug(glmer)
> > ...
> > debug: mer_finalize(ans, verbose)
> > Browse[1]> ans
> > Error in chol2inv(object at RXy, size = object at dims["p"]) :
> >    element (1, 1) is zero, so the inverse cannot be computed
> >
> > Browse[1]> ans at fixef
> > (Intercept)       typeB       typeC       typeD       typeE
> >    1.7917595   1.7957199  -1.2527630  -0.9044563  -0.1177830
> >
> >
> > Which used to be something like:
> >
> > # Fixed effects:
> > #              Estimate Std. Error  z value  Pr(>|z|)
> > # (Intercept) -5.573280   0.217482 -25.6264 < 2.2e-16 ***
> > # typeB       -0.605271   0.176118  -3.4367 0.0005888 ***
> > # typeC       -0.716560   0.328634  -2.1804 0.0292262 *
> > # typeD       -0.061478   0.289935  -0.2120 0.8320749
> > # typeE        0.309430   0.235577   1.3135 0.1890160
> > #
> > # Solution for Fixed Effects (SAS GLMMIX)
> > #   Effect       type    Estimate       Error      DF    t Value    Pr > |t|
> > #   Intercept             -5.6799      0.3286       1     -17.28      0.0368
> > #   type         B        -0.5798      0.2277      23      -2.55      0.0180
> > #   type         C        -0.6984      0.4248      23      -1.64      0.1138
> > #   type         D       -0.08703      0.3746      23      -0.23      0.8183
> > #   type         E         0.3301      0.3046      23       1.08      0.2897
> >
> > And:
> >
> > Browse[1]> ans at deviance
> >     ML  REML  ldL2 ldRX2 pwrss  disc  usqr  wrss
> >        NA    NA    NA    NA    NA    NA    NA    NA
> >
> > Hopefully, I haven't made any obvious errors.
> >
> > Cheers, David Duffy.
> >
> > --
> > | David Duffy (MBBS PhD)                                         ,-_|\
> > | email: davidD at qimr.edu.au  ph: INT+61+7+3362-0217 fax: -0101  /     *
> > | Epidemiology Unit, Queensland Institute of Medical Research   \_,-._/
> > | 300 Herston Rd, Brisbane, Queensland 4029, Australia  GPG 4D0B994A v
> >
>
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: ships_Rout.txt
URL: <https://stat.ethz.ch/pipermail/r-sig-mixed-models/attachments/20080131/61859a2c/attachment.txt>


More information about the R-sig-mixed-models mailing list