简体   繁体   中英

Nesting success (binomial glmm) in r

I am running a GLMM using glmer() in R:

glmer(survive ~ fyear + site + fyear * site.x + (1|fyear),
family = binomial(link = logexp(shaffer.sub$exposure)),
data = shaffer.sub)

where survive is 0 or 1 depending if the nest was successful or not. Here you can see what the data looks like:

structure(list(id = structure(1:7, .Label = c("1", "2", "3", 
"4", "5", "6", "7"), class = "factor"), year.x = structure(c(1L, 
1L, 2L, 3L, 3L, 3L, 3L), .Label = c("1994", "1995", "1999"), class = "factor"), 
    survive = structure(c(1L, 2L, 2L, 2L, 2L, 2L, 1L), .Label = c("0", 
    "1"), class = "factor"), fyear = structure(c(1L, 1L, 2L, 
    3L, 3L, 3L, 3L), .Label = c("1994", "1995", "1999"), class = "factor"), 
    site.x = structure(c(1L, 2L, 1L, 1L, 1L, 2L, 1L), .Label = c("N", 
    "S"), class = "factor")), .Names = c("id", "year.x", "survive", 
"fyear", "site.x"), row.names = c(NA, -7L), class = "data.frame")

but I get this warning message:

*Warning messages:
1: In checkConv(attr(opt, "derivs"), opt$par, ctrl = control$checkConv,  :
  Model failed to converge with max|grad| = 0.0299425 (tol = 0.001, component 12)
2: In checkConv(attr(opt, "derivs"), opt$par, ctrl = control$checkConv,  :
  Model is nearly unidentifiable: large eigenvalue ratio
 - Rescale variables?*

I was told I should not use the same random factor as a fixed effect on the same model.

At the end, I would like to have an output where I can see year, site and the interaction year:site effects. Like in an ANOVA table (is this possible? I've been trying to use summary(aov(model)) but this doesn't work; anova(model) does not either.

I get this error for the aov() command:

*Error in summary`(aov(syearXsite))` : 
  error in evaluating the argument 'object' in selecting a method for function 'summary': Error in if (fixed.only) { : argument is not interpretable as logical*

How can I see the effect of this variables on survival?

Whoever told you not to use a categorical input variable ( fyear ) as both a fixed and a random effect was correct. It's hard to know exactly what to recommend, it depends on the number of years and sites you have in your data set (is the data you linked to all of your data (I hope not), or just the first few rows? How many years and how many sites and how many total observations do you have?)

If you want to treat year as random and site as fixed (which would be sensible if you have only two sites ( N vs S as seen in your data) and quite a few years, eg more than 5) then you could fit:

g1 <- glmer(survive~site.x+(site.x|fyear),
      family=binomial(link=logexp(shaffer.sub$exposure)),
      data=shaffer.sub)

I don't know what site vs site.x are: I only see site.x in your data snippet.

To get information, try summary(g1) . (That will only give you variances for random effects, not for fixed effects; GLMMs don't operate in the same "variance explained" mode as ANOVA does, in particular because the variances explained by different terms usually do not add up to the total variance.)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM