0
$\begingroup$

I have bird counts in three different landscape matrixes, repeated over two seasons. I want to evaluate if species richness differs between matrixes, accounting for seasonal changes.

I am not very familiar with building models using glmer, and I'm confused about how to consider the effect of the seasons, since points are repeated and then I need to consider this as a nested effect - but also I want to consider the possibility of an interaction of the effects of seasons and matrixes.

Some of my data:

birds<- data.frame(n = c(14L,1L,5L,2L,1L,4L,3L,3L,7L,3L,6L,5L,6L,1L,5L,1L,6L,5L,8L,11L,5L,10L,8L,5L,10L,2L,
                 5L,5L,2L,2L,2L,6L,5L,1L,13L,9L,9L,1L,12L,1L,1L,11L,3L,5L,5L,6L,3L,3L,1L,11L,2L,9L,7L,3L,11L,2L,
                 4L,8L,6L,5L,5L,1L,5L,14L,2L,3L,5L,5L,2L,2L,4L,3L,4L,2L,4L,6L,2L,1L,3L,5L,4L,1L,4L,3L,5L,2L,4L,
                 7L,2L,8L,5L,20L,3L,9L,8L,9L,3L,2L,9L,6L,4L,10L,7L,5L,6L,4L,4L,3L,2L,3L,5L,6L,5L,5L,12L,10L,7L,6L,
                 9L,2L,8L,6L,2L,19L,6L,7L,3L,5L,4L,7L,5L,7L,3L,2L,2L,1L,4L,4L,3L,5L,3L,6L,5L,4L,3L,3L,2L,4L,4L,
                 3L,2L,5L,2L,3L,3L,5L,3L,10L,6L,6L,6L,8L,13L,12L,6L,9L,5L,10L,6L,2L,5L,1L,15L,16L,10L,7L,7L,5L,8L,
                 6L,12L,3L,4L,8L,7L,10L,12L,10L,3L,4L,9L,6L,9L,10L,10L,6L,6L,9L,3L,10L,2L,10L,2L,4L,3L,15L,1L,5L,
                 1L,7L,11L,6L,3L,8L,5L,7L,10L,17L,5L,7L,9L,6L,10L,6L,2L,7L,2L,11L,6L,10L,4L,10L,7L,11L,5L,4L,1L,
                 2L,11L,8L,16L,5L,8L,8L,1L,7L,7L,1L,1L,10L,7L,4L,5L,1L,7L,1L,5L,6L,3L,1L,3L,10L,4L,7L,4L,1L,7L,1L,
                 6L,11L,5L,3L,4L,2L,7L,6L,3L,5L,2L,2L,7L,3L,8L,3L,4L),
       point = as.factor(c("Bo_01","Bo_01","Bo_02","Bo_02","Bo_03","Bo_03","Bo_04","Bo_04",
                  "Bo_05","Bo_05","Bo_06","Bo_06","Bo_07","Bo_07","Bo_08","Bo_08","Bo_09","Bo_09","Bo_10","Bo_10",
                  "Bo_11","Bo_11","Bo_12","Bo_12","Bo_13","Bo_13","Bo_14","Bo_14","Bo_15","Bo_15","Bo_16","Bo_16",
                  "Bo_17","Bo_17","Bo_18","Bo_18","Bo_19","Bo_19","Bo_20","Bo_20","Bo_21","Bo_21","Bo_22","Bo_22",
                  "Bo_23","Bo_23","Bo_24","Bo_24","Bo_25","Bo_25","Bo_26","Bo_26","Bo_27","Bo_27","Bo_28",
                  "Bo_28","Bo_29","Bo_29","Bo_30","Bo_30","Bo_31","Bo_31","Bo_32","Bo_32","Bo_33","Bo_33","Bo_34",
                  "Bo_34","Bo_35","Bo_35","Bo_36","Bo_36","Bo_37","Bo_37","Bo_38","Bo_38","Bo_39","Bo_39","Bo_40",
                  "Bo_40","Bo_41","Bo_41","Bo_42","Bo_42","Bo_43","Bo_43","Bo_44","Bo_44","Bo_45","Bo_45","Bo_46",
                  "Bo_46","Bo_47","Bo_47","Bo_48","He_01","He_01","He_02","He_02","He_03","He_03","He_04",
                  "He_04","He_05","He_05","He_06","He_06","He_07","He_07","He_08","He_08","He_09","He_09","He_10",
                  "He_10","He_11","He_11","He_12","He_12","He_13","He_13","He_14","He_14","He_15","He_15","He_16",
                  "He_16","He_17","He_17","He_18","He_18","He_19","He_19","He_20","He_20","He_21","He_21","He_22",
                  "He_22","He_23","He_23","He_24","He_24","He_25","He_25","He_26","He_26","He_27","He_27","He_28",
                  "He_28","He_29","He_29","He_30","He_30","He_31","He_31","He_32","He_32","He_33","He_33",
                  "He_34","He_34","He_35","He_35","He_36","He_36","He_37","He_37","He_38","He_38","He_39","He_39",
                  "He_40","He_40","He_41","He_41","He_42","He_42","He_43","He_43","He_44","He_44","He_45","He_45",
                  "He_46","He_46","He_47","He_47","He_48","Ho_01","Ho_01","Ho_02","Ho_02","Ho_03","Ho_03","Ho_04",
                  "Ho_04","Ho_05","Ho_05","Ho_06","Ho_06","Ho_07","Ho_07","Ho_08","Ho_08","Ho_09","Ho_09",
                  "Ho_10","Ho_10","Ho_11","Ho_11","Ho_12","Ho_12","Ho_13","Ho_13","Ho_14","Ho_14","Ho_15","Ho_15",
                  "Ho_16","Ho_16","Ho_17","Ho_17","Ho_18","Ho_18","Ho_19","Ho_19","Ho_20","Ho_20","Ho_21","Ho_21",
                  "Ho_22","Ho_22","Ho_23","Ho_23","Ho_24","Ho_24","Ho_25","Ho_25","Ho_26","Ho_26","Ho_27","Ho_27",
                  "Ho_28","Ho_28","Ho_29","Ho_29","Ho_30","Ho_30","Ho_31","Ho_31","Ho_32","Ho_32","Ho_33","Ho_33",
                  "Ho_34","Ho_34","Ho_35","Ho_35","Ho_36","Ho_36","Ho_37","Ho_37","Ho_38","Ho_38","Ho_39",
                  "Ho_39","Ho_40","Ho_40","Ho_41","Ho_41","Ho_42","Ho_42","Ho_43","Ho_43","Ho_44","Ho_44","Ho_45",
                  "Ho_45","Ho_46","Ho_46","Ho_47","Ho_47","Ho_48")),
      season = as.factor(c("D","R","D","R","D","R","D","R","D","R","D","R","D","R","D",
                  "R","D","R","D","R","D","R","D","R","D","R","D","R","D","R","D","R","D","R","D","R",
                  "D","R","D","R","D","R","D","R","D","R","D","R","D","R","D","R","D","R","D","R","D","R",
                  "D","R","D","R","D","R","D","R","D","R","D","R","D","R","D","R","D","R","D","R","D",
                  "R","D","R","D","R","D","R","D","R","D","R","D","R","D","R","D","D","R","D","R","D",
                  "R","D","R","D","R","D","R","D","R","D","R","D","R","D","R","D","R","D","R","D","R",
                  "D","R","D","R","D","R","D","R","D","R","D","R","D","R","D","R","D","R","D","R","D",
                  "R","D","R","D","R","D","R","D","R","D","R","D","R","D","R","D","R","D","R","D","R","D",
                  "R","D","R","D","R","D","R","D","R","D","R","D","R","D","R","D","R","D","R","D","R",
                  "D","R","D","R","D","D","R","D","R","D","R","D","R","D","R","D","R","D","R","D","R",
                  "D","R","D","R","D","R","D","R","D","R","D","R","D","R","D","R","D","R","D","R","D",
                  "R","D","R","D","R","D","R","D","R","D","R","D","R","D","R","D","R","D","R","D","R",
                  "D","R","D","R","D","R","D","R","D","R","D","R","D","R","D","R","D","R","D","R","D","R",
                  "D","R","D","R","D","R","D","R","D","R","D","R","D","R","D")),
      matrix = as.factor(c("fors","fors","fors","fors","fors","fors","fors","fors","fors",
                 "fors","fors","fors","fors","fors","fors","fors","fors","fors","fors","fors","fors","fors","fors",
                 "fors","fors","fors","fors","fors","fors","fors","fors","fors","fors","fors","fors","fors",
                 "fors","fors","fors","fors","fors","fors","fors","fors","fors","fors","fors","fors","fors",
                 "fors","fors","fors","fors","fors","fors","fors","fors","fors","fors","fors","fors","fors",
                 "fors","fors","fors","fors","fors","fors","fors","fors","fors","fors","fors","fors","fors","fors",
                 "fors","fors","fors","fors","fors","fors","fors","fors","fors","fors","fors","fors","fors",
                 "fors","fors","fors","fors","fors","fors","het","het","het","het","het","het","het","het",
                 "het","het","het","het","het","het","het","het","het","het","het","het","het","het","het",
                 "het","het","het","het","het","het","het","het","het","het","het","het","het","het","het",
                 "het","het","het","het","het","het","het","het","het","het","het","het","het","het","het","het",
                 "het","het","het","het","het","het","het","het","het","het","het","het","het","het","het",
                 "het","het","het","het","het","het","het","het","het","het","het","het","het","het","het",
                 "het","het","het","het","het","het","het","het","het","het","het","hom","hom","hom","hom",
                 "hom","hom","hom","hom","hom","hom","hom","hom","hom","hom","hom","hom","hom","hom","hom",
                 "hom","hom","hom","hom","hom","hom","hom","hom","hom","hom","hom","hom","hom","hom","hom",
                 "hom","hom","hom","hom","hom","hom","hom","hom","hom","hom","hom","hom","hom","hom","hom",
                 "hom","hom","hom","hom","hom","hom","hom","hom","hom","hom","hom","hom","hom","hom","hom","hom",
                 "hom","hom","hom","hom","hom","hom","hom","hom","hom","hom","hom","hom","hom","hom","hom",
                 "hom","hom","hom","hom","hom","hom","hom","hom","hom","hom","hom","hom","hom","hom","hom")))

My guess is that I need to write a model with varying intercepts and slopes, with an interaction term.

For example:

In this model I understand I'm accounting for points within seasons and evaluating the effect of the matrix. But I'm not sure how to include an interaction term of season and matrix - any help on this?

m1<-glmer(n ~ matrix + (1|season), data = birds, family = poisson)

I also get a message: boundary (singular) fit: see ?isSingular and a variance zero for seasons effect, so I guess it is not a good idea to consider season as Random effect? How should I consider the seasons?

I reviewed different questions and found some other posts about repeated measures, modeling this as:

m2 <- glmer(n ~ season + matrix + season:matrix + (season | point), data = birds, family = poisson)

But I'm not sure that is correct in my example, since I get an error

Error: number of observations (=285) < number of random effects (=288) for term (season | point); the random-effects parameters are probably unidentifiable

Any help on how to specify my model correctly?

$\endgroup$
  • $\begingroup$ The isSingular warning indicates that you're model is overfit (my hunch is that this is due to the way that your factor variables splice the data). You might also want to check the discussion here: stats.stackexchange.com/questions/378939/… $\endgroup$ – horseoftheyear Jun 1 at 17:50
  • $\begingroup$ By the way, based on a check of boxplot(n ~ matrix, birds) there does not seem to be much different in the bird counts between landscapes. Lack of variation is another issue. $\endgroup$ – horseoftheyear Jun 1 at 17:52
  • $\begingroup$ thanks @horseoftheyear ! Yes, you are right, although this is not the complete data set, still variation is not much. I still need to build some model with my data. Ill check on the discussion you are pointing out! $\endgroup$ – Andrea Goijman Jun 1 at 18:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.