Re: [R] mixed effects models - negative binomial family?

From: Elizabeth Lawson <lizzylaws_at_yahoo.com>
Date: Wed 04 Jan 2006 - 08:54:43 EST


Have you tried nlme?    

  I tried to something similar.    

  Here is the code that I used for a negative binomial random effects model        

  library(nlme)
  mydata<-read.table("C:\\Plx\\plx.all\\plxall.txt",header=TRUE)   loglike = function(PLX_NRX,PD4_42D,GAT_34D,VIS_42D,MSL_42D,SPE_ROL,XM2_DUM,THX_DUM,b0,b1,b2,b3,b4,b5,b6,b7,alpha){   lambda = exp(b0 + b1*GAT_34D+b2*VIS_42D+b3*MSL_42D+b4*PD4_42D+b5*SPE_ROL+b6*XM2_DUM+b7*THX_DUM)   y=round(PLX_NRX)
  y <- table(y)
   freq <- as.vector(y)

          count <- as.numeric(names(y))
   count <- count[!(freq < 1)]

      freq <- freq[!(freq < 1)]
      n <- length(count)
      df <- n - 1
                          
   
   
   
   df <- df - 2
              xbar <- weighted.mean(count, freq)
              s2 <- var(rep(count, freq))
              p <- xbar/s2
              alpha <- xbar^2/(s2 - xbar)
   

  ( dnbinom(y,alpha,(alpha/(alpha+lambda))) )     }        

  plx.nlme<-nlme(PLX_NRX~loglike(PLX_NRX,PD4_42D,GAT_34D,VIS_42D,MSL_42D,SPE_ROL,XM2_DUM,THX_DUM,b0,b1,b2,b3,b4,b5,b6,b7,alpha),   data=mydata,
  fixed=list(b0 + b1+b2+b3+b4+b5+b6+b7+alpha~1),   random=b0~1|menum,    

  start=c(b0=0,b1=0,b2=0,b3=0,b4=0,b5=0,b6=0,b7=0,alpha=5)   )    

  I am not sure that this is what you are looking for , but I hope this helps!    

  Elizabeth Lawson
Constantinos Antoniou <antoniou@central.ntua.gr> wrote:   Hello all,

I would like to fit a mixed effects model, but my response is of the negative binomial (or overdispersed poisson) family. The only (?) package that looks like it can do this is glmm.ADMB (but it cannot run on Mac OS X - please correct me if I am wrong!) [1]

I think that glmmML {glmmML}, lmer {Matrix}, and glmmPQL {MASS} do not provide this "family" (i.e. nbinom, or overdispersed poisson). Is there any other package that offers this functionality?

Thanking you in advance,

Costas

[1] Yes, I know I can use this on another OS. But it is kind of a nuisance, as I have my whole workflow setup on a mac, including emacs +ess, the data etc etc. It will be non-trivial to start moving/ syncing files between >1 computers, in order to use this package...

--
Constantinos Antoniou, Ph.D.
Department of Transportation Planning and Engineering
National Technical University of Athens
5, Iroon Polytechniou str. GR-15773, Athens, Greece


______________________________________________
R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html --------------------------------- [[alternative HTML version deleted]]
______________________________________________
R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Received on Wed Jan 04 09:01:42 2006

This archive was generated by hypermail 2.1.8 : Fri 03 Mar 2006 - 03:41:46 EST