[R] Linear mixed models with custom link functions in R

Daniel Barton daniel.barton at umontana.edu
Fri Mar 26 19:59:24 CET 2010


Hello All,
    I am looking for an R library/function that allows the specification 
of a custom link function in a linear mixed model.  I've been using 
glm() in library MASS to fit fixed-effect models with a custom link but 
my study design demands mixed models.  Any suggestions on the best R 
library/function to achieve this would be greatly appreciated.  I have 
tried, to no avail, to locate a library that fits my needs by searching 
CRAN and the web on the basis of which ones allow custom link 
functions.  Some of the mixed-effect models I'm hoping to fit involve 
more than a single random factor.  An example of how I've been doing 
this with glm() is shown below to illustrate what I'm hoping to scale up 
to a mixed model.  Thanks very much for your time and thoughts.

-----------------

library(MASS)
logexp <- function(days = 1)  ##Custom link function from Shaffer (2004) 
Auk 121:526-540.
{
    linkfun <- function(mu) qlogis(mu^(1/days))
    linkinv <- function(eta) plogis(eta)^days
    mu.eta <- function(eta) days * plogis(eta)^(days-1) *
      .Call("logit_mu_eta", eta, PACKAGE = "stats")
    valideta <- function(eta) TRUE
    link <- paste("logexp(", days, ")", sep="")
    structure(list(linkfun = linkfun, linkinv = linkinv,
                   mu.eta = mu.eta, valideta = valideta, name = link),
              class = "link-glm")
}

model0 <- glm(survive~1, family=binomial(logexp(days=expos))) ##Call to 
glm with custom link

---------------------

Best,
Dan Barton

--
Daniel C. Barton
PhD Candidate
USGS Montana Cooperative Wildlife Research Unit &
Program in Organismal Biology and Ecology
University of Montana
205 Natural Science
Missoula, MT 59812
daniel.barton at umontana.edu
Missoula, MT 59812



More information about the R-help mailing list