[R-sig-ME] using glmer with user-defined link function

Ben Bolker bolker at ufl.edu
Tue Oct 21 22:47:48 CEST 2008


  The rationale certainly makes sense.

  Eventually I would like to add a negative binomial link
function, but that will (a) require some time and (b) require
me to write an additional loop around glmer that searches
for the MLE of the overdispersion parameter.  (I did look briefly
at the code, but I don't remember offhand whether it would
be hard to have a link function with an additional parameter.
Looking now at lme4_varFunc, it looks hard -- the function
takes only var (computed variance), mu (mean value), n (number
of samples), vTyp (variance model) -- no slot for a "theta"
or "k" parameter.)

  thanks
    Ben Bolker

Douglas Bates wrote:
> You can use a "quasi" family with separate specification of the link
> and the variance function but there are only a limited number of
> variance functions available.
> 
> The reason that the inverse link and the variance functions are
> hard-coded in glmer is because the number of evaluations of these
> functions is potentially much, much greater than the number of
> evaluations involved in fitting a generalized linear model (glm).  As
> always, it doesn't matter that much when you have a small to moderate
> sample size but it does matter when you have large sample sizes and
> for models like IRT (item response theory) models the sample size can
> be large indeed (tens of millions is not uncommon since each answer by
> each candidate constitutes a distinct response).  It is difficult to
> design code that is both efficient on large data sets and is flexible
> in terms of the model specification.  In this case I chose to go with
> the ability to handle large data sets.
> 
> If you have a custom variance function of inverse link function that
> you would like to use, you are welcome to contribute the code for
> them.  See the C functions lme4_varFunc, lme4_muEta and lme4_devResid
> in lme4/src/lmer.c for the currently available code.
> 
> On Tue, Oct 21, 2008 at 1:57 PM, Ben Bolker <bolker at ufl.edu> wrote:
>>
>>  I tried to deal with this at one point to put in a negative
>> binomial model.  I, too, was hopeful that just
>> adding the name of my link function to the list
>> of allowed names would be all that was
>> needed. Unfortunately, the variance functions are
>> hard coded within the glmer code, so it will not be completely
>> trivial to do this ...
>>
>>   Ben
>>
>>
>> vito muggeo wrote:
>>> dear all,
>>> I am trying to use an user-specified link function in glmer() (via the
>>> argument family), but the error is
>>>
>>> Error in famType(glmFit$family) : unknown link: 'my_link'
>>>
>>> my_link is a proper link function (of class "link-glm") which works
>>> correctly with glm() and also with MASS::glmmPQL()
>>>
>>> It appears that the function lme4::famType() checks for the name by
>>> comparing it with the names in "famNms" which includes "gaussian",
>>> "binomial", "Gamma", ... however I do not know whether it is sufficient
>>> to include "my_link" in famNms, and possibly I do not how to do it.. :-)
>>>
>>> many thanks,
>>> vito
>>>
>>>
>>>
>> _______________________________________________
>> R-sig-mixed-models at r-project.org mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-sig-mixed-models
>>




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