Skip to content

refit with binomial model (lme4)

5 messages · Eric Elguero, Douglas Bates, Ben Bolker

#
Dear R users,

I'm trying to use function 'refit' from lme4
and I get this error that I can't understand:
Error in function (classes, fdef, mtable)  : 
  unable to find an inherited method for function "refit", for signature
"mer", "matrix"

if I try:
Error in asMethod(object) : matrix is not symmetric [1,2]

I get this error message that I can no more
understand but which suggests that refit expects
two columns.


the initial model was:
glmer(formula = cbind(sortis, restes) ~ mean.co2 + (1 | sujet), 
    data = dollo4.df, family = binomial)



R version 2.9.0 (2009-04-17)

and

Package: lme4
Version: 0.999375-28
Date: 2008-12-13

thank you in advance

e.e.
#
This is related to using the matrix form of the response for a
binomial glmm.  The refit method for a model fit by lmer is based on a
numeric vector response.

Is it possible to use the expanded form (i.e. a vector of 0/1 values)
of the responses instead of the matrix form?
On Mon, Apr 27, 2009 at 7:20 AM, Eric Elguero <Eric.Elguero at mpl.ird.fr> wrote:
#
On Mon, 2009-04-27 at 08:30 -0500, Douglas Bates wrote:
thank you for this explanation.
yes I could but I found that I could use the
probability/weights form, at least in my case 
where I am simulating new binomial data with
the observed number of trials.

Eric Elguero
#
I think the following works, but use with caution -- I just
wrote it last night.

setMethod("refit", signature(object = "mer", newresp = "matrix"),
          function(object, newresp, ...)
      {
        ## newresp <- as.double(newresp[!is.na(newresp)])
        wts <- rowSums(newresp)
        newresp <- newresp[,1]/wts
        stopifnot(length(newresp) == object at dims["n"])
        object at y <- newresp
        object at pWt <- wts
        lme4:::mer_finalize(object)
      })

  Ben Bolker
#
Thanks for sending that, Ben.  I have incorporated a slightly modified
version, with attribution, in the lme4 sources.
On Tue, Apr 28, 2009 at 8:03 AM, Ben Bolker <bolker at ufl.edu> wrote: