[R-sig-ME] model specification for continuous environmental vars
Tim Howard
tghoward at gw.dec.state.ny.us
Thu Dec 12 19:39:04 CET 2013
List members -
I am learning a lot, quickly, but still have a way to go. I would
greatly appreciate some help with model specification in glmer.
I can't find a good example that parallels what I've got.
My dataset consists of spatially-balanced random samples of rare
plants within alpine summits. There were two sampling bouts (yr1 and yr2)
with yr2 collected 6 years after yr1. A new set of random plots were
collected at each bout (e.g. new estimate of the population, not repeated
measures). I would like to test the difference in plant density from yr1 to yr2, overall.
These are count data with many zeros, fitting a negative binomial distribution.
This is what confuses me: I ALSO have environmental information
that influences density, such as elevation, solar radiation, slope (and more)
I would like to include these variables in the model, but I am not
exactly sure how. Based on my reading, this is what I think I have:
block random effects: summit
continuous random effects: elev, solrad, slope
fixed effect: time (=samp)
individual random effects to deal with overdisperson: plotID
I have over 350 plots for each sample bout, spread among 17 summits.
Given this I think my model is:
mod <- glmer(count ~ samp + (1|summit) + (1|elev) + (1|solrad) + (1|slope) + (1|pltID),
data=dat, family="poisson")
My primary questions:
Is this the appropriate way to handle these environmental variables?
Am I approaching this the right way?
###
## To provide a better feel for the structure
## I've created a reproduceable example with dummy data, below.
## ... I've only created one dummy environmental variable...
###
library(lme4)
set.seed(5555)
dat.a <- data.frame(pltID = 1001:1100,
samp = "yr1",
summit = rep(c("sOne","sTwo","sThree","sFour"),c(30, 30, 30, 10)),
count = rnbinom(size = 0.06, mu = 19.87, n=100))
dat.b <- data.frame(pltID = 2001:2100,
samp = "yr2",
summit = rep(c("sOne","sTwo","sThree","sFour"),c(33, 28, 34, 5)),
count = rnbinom(size = 0.06, mu = 20.15, n=100))
dat <- rbind(dat.a, dat.b)
x <- lapply(20+dat$count/2, function(X)rnbinom(size=1,mu=X,n=1))
dat <- cbind(dat, envvar=unlist(x))
mp1 <- glmer(count ~ samp + (1|summit) + (1|envvar) + (1|pltID),
data = dat, family="poisson")
summary(mp1)
##
# end
##
Thank you in advance for any assistance.
Tim
More information about the R-sig-mixed-models
mailing list