Phillip J van Mantgem
2008-Feb-13 18:58 UTC
[R] Generalized nonlinear mixed model function?
I am wondering if there is an R function that could estimate a generalized nonlinear mixed model.>From my reading it seems that nlme from the nlme package can fit nonlinearmixed models, while lmer from the lme4 package can fit generalized linear mixed models. One alternative I?ve found is gnlmix from the repeated package, although this only allows for a single random effect. Is there anything else out there that I have missed? Thanks, Phil Phillip van Mantgem USGS Western Ecological Research Center Sequoia and Kings Canyon Field Station 47050 Generals Highway #4 Three Rivers, CA 93271-9651 USA ----------------------------------------------------------- The motivating problem is estimating average trends in forest mortality rates with unequally spaced census intervals. The census interval has an exponential effect on survival (i.e., p = annual survival, year.interval = census interval, and p^year.interval; annual morality = 1 - p), leading me to use a nonlinear model. Our data are composed of counts of live and dead trees, so I?ll need to use a binomial or poisson model. Our data look like the following... # plot identifier (random effect) # eventually I?ll need to add another random term for species identity plot <- rep(c("A", "B", "C"), each = 3) # census identifier census <- rep(1:3, 3) # year of census year <- c(1960, 1989, 2004, 1960, 1989, 2004, 1955, 1989, 2004) # interval between census years year.interval <- c(NA, 29, 15, NA, 29, 15, NA, 34, 15) # count of live trees n.live <- c(1509, 1249, 1106, 1986, 1616, 1383, 3529, 2831, 2511) # count of dead trees n.dead <- c(NA, 260, 143, NA, 370, 233, NA, 698, 320) forest.mort <- data.frame(plot, census, year, year.interval, n.live, n.dead) [[alternative HTML version deleted]]
Phillip J van Mantgem
2008-Feb-13 19:18 UTC
[R] Generalized nonlinear mixed model function?
(Sorry for the re-posting. My first attempt failed.) I am wondering if there is an R function that could estimate a generalized nonlinear mixed model. From my reading it seems that nlme from the nlme package can fit nonlinear mixed models, while lmer from the lme4 package can fit generalized linear mixed models. One alternative I?ve found is gnlmix from the repeated package, although this only allows for a single random effect. Is there anything else out there that I have missed? Thanks, Phil Phillip van Mantgem USGS Western Ecological Research Center Sequoia and Kings Canyon Field Station 47050 Generals Highway #4 Three Rivers, CA 93271-9651 USA ----------------------------------------------------------- The motivating problem is estimating average trends in forest mortality rates with unequally spaced census intervals. The census interval has an exponential effect on survival (i.e., p = annual survival, year.interval census interval, and p^year.interval; annual morality = 1 - p), leading me to use a nonlinear model. Our data are composed of counts of live and dead trees, so I?ll need to use a binomial or poisson model. Our data look like the following... # plot identifier (random effect) # eventually I?ll need to add another random term for species identity plot <- rep(c("A", "B", "C"), each = 3) # census identifier census <- rep(1:3, 3) # year of census year <- c(1960, 1989, 2004, 1960, 1989, 2004, 1955, 1989, 2004) # interval between census years year.interval <- c(NA, 29, 15, NA, 29, 15, NA, 34, 15) # count of live trees n.live <- c(1509, 1249, 1106, 1986, 1616, 1383, 3529, 2831, 2511) # count of dead trees n.dead <- c(NA, 260, 143, NA, 370, 233, NA, 698, 320) forest.mort <- data.frame(plot, census, year, year.interval, n.live, n.dead)
Phillip J van Mantgem <pvanmantgem <at> usgs.gov> writes:> > I am wondering if there is an R function that could estimate a generalized > nonlinear mixed model. >Short answer: no (not really/not that I'm aware of). Long answer: AD Model Builder? WinBUGS? shortcuts like nlme applied to the proportion dying, with appropriate scaling of the variance (weights argument)? I'm afraid that a nonlinear generalized mixed model with two random effects, although fairly straightforward to define, is pretty darned difficult to solve reliably ... cheers Ben Bolker
Hi Philip, your data are event times because you're monitoring the same trees in each plot over time, the event being death of a tree. Therefore methods from survival analysis are more appropriate. Start out having a look at the package survival, possibly considering a Cox model with adjustment for clusters or with strata (the function coxph()) or a parametric model using the function survreg(). Christian