1
$\begingroup$

I asked a similar question in the R forum but realized that isn't the optimal place to post. I'm working with a dataset looking like this:

> head(GLM_df)
# A tibble: 6 x 7
# Groups:   hour [6]
   hour Feeding Foraging Standing ID    Area     Feeding_Foraging
  <int>   <dbl>    <dbl>    <dbl> <fct> <fct>               <dbl>
1     0    3.61     23.2     1    41361 Seronera             26.8
2     1    2.85     24.2     1    41361 Seronera             27.0
3     2    2.5      24.3     2    41361 Seronera             26.8
4     3    6.92     18.6     3.89 41361 Seronera             25.6
5     4    7.5      17.6     3.78 41361 Seronera             25.1
6     5    7.26     19.6     2.45 41361 Seronera             26.8

And I'm trying to run a glmer() model as such to verify an interaction, the associated warning is found below:

> m1 <- glmer(cbind(Feeding_Foraging, Standing) ~ poly(hour, 2) * Area + (1 | ID), data = GLM_df, family = binomial())
Warning message:
In eval(family$initialize, rho) : non-integer counts in a binomial glm!

The model produces summary and plot() well, but I'm unsure wether I can justify the use of a binomial distribution for my data.

Is there a way I could test that, such as the Shapiro test for normal distributions?

If that helps, I will dput() my data below for reproductability:

> dput(GLM_df)
structure(list(hour = c(0L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 
10L, 11L, 12L, 13L, 14L, 15L, 16L, 17L, 18L, 19L, 20L, 21L, 22L, 
23L, 0L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L, 11L, 12L, 13L, 
14L, 15L, 16L, 17L, 18L, 19L, 20L, 21L, 22L, 23L, 0L, 1L, 2L, 
3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L, 11L, 12L, 13L, 14L, 15L, 16L, 
17L, 18L, 19L, 20L, 21L, 22L, 23L, 0L, 1L, 2L, 3L, 4L, 5L, 6L, 
7L, 8L, 9L, 10L, 11L, 12L, 13L, 14L, 15L, 16L, 17L, 18L, 19L, 
20L, 21L, 22L, 23L, 0L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L, 
11L, 12L, 13L, 14L, 15L, 16L, 17L, 18L, 19L, 20L, 21L, 22L, 23L, 
0L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L, 11L, 12L, 13L, 14L, 
15L, 16L, 17L, 18L, 19L, 20L, 21L, 22L, 23L), Feeding = c(3.61111111111111, 
2.84615384615385, 2.5, 6.92, 7.5, 7.26086956521739, 6.84, 7.16, 
6.25, 7.68965517241379, 8.13333333333333, 6.53333333333333, 7.13793103448276, 
7, 8.93333333333333, 12.8, 5.3448275862069, 3.68421052631579, 
3.17391304347826, 5, 5.11538461538461, 6.40909090909091, 5.29166666666667, 
5.75, 6.96428571428571, 4.77272727272727, 4.61904761904762, 10.5666666666667, 
13.8333333333333, 9.83333333333333, 9.43333333333333, 8.96551724137931, 
8.68965517241379, 9.26666666666667, 10.1666666666667, 9.06666666666667, 
10.2333333333333, 9.1, 9.5, 8.73333333333333, 8.03333333333333, 
5.26086956521739, 4.44, 8.19230769230769, 11.3571428571429, 10.6071428571429, 
11.1, 8.62068965517241, 5.54545454545455, 2.78947368421053, 3.04545454545455, 
8.51724137931035, 10.5666666666667, 10.4666666666667, 9.13333333333333, 
8.79310344827586, 8.53333333333333, 9.23333333333333, 9.8, 8.56666666666667, 
9.73333333333333, 9.33333333333333, 7.6, 9.34615384615385, 8, 
3.38461538461538, 4.125, 6.125, 7.48, 10.2380952380952, 6.88461538461539, 
7.4, 4.1304347826087, 3.75, 2.3, 8, 11.1935483870968, 10.7741935483871, 
9.25806451612903, 10.0967741935484, 8.64516129032258, 8.35483870967742, 
8, 7.03225806451613, 5.80645161290323, 5.64516129032258, 4.9, 
1.85, 3.96774193548387, 3.12, 3.30434782608696, 4.13793103448276, 
4.37037037037037, 6.27586206896552, 6.69230769230769, 6.46153846153846, 
3.56, 4.16, 2.75, 6.32258064516129, 6.74193548387097, 5.73333333333333, 
5.36666666666667, 5.51724137931035, 4.53333333333333, 4.48275862068965, 
4, 5.06666666666667, 4.25925925925926, 3.3448275862069, 2.75, 
1.94117647058824, 3.74193548387097, 2.69230769230769, 2.85185185185185, 
4.22727272727273, 3.75, 4.3, 5.06666666666667, 4.15384615384615, 
6.91666666666667, 3.40909090909091, 4.22727272727273, 5.6, 5.10344827586207, 
6.56666666666667, 7.35483870967742, 8.83870967741935, 8.25806451612903, 
8.09677419354839, 10.3548387096774, 9.70967741935484, 10.1290322580645, 
8.29032258064516, 6.6, 5.2962962962963, 8.36666666666667, 4.4, 
3.28571428571429, 5.96153846153846, 5.93333333333333, 6.6, 5.93333333333333, 
6.6551724137931), Foraging = c(23.2333333333333, 24.2, 24.3333333333333, 
18.6333333333333, 17.6, 19.5666666666667, 17.8, 18.7, 18.5333333333333, 
16.9333333333333, 15.4666666666667, 17.4, 17.0333333333333, 17, 
14.2666666666667, 9.92857142857143, 19.9333333333333, 23.9, 23.5, 
21.8333333333333, 21.4666666666667, 20.9, 21.3333333333333, 21.9333333333333, 
17.6551724137931, 20.4, 20.8666666666667, 8.63333333333333, 5.26923076923077, 
9.5, 10.2413793103448, 12.5172413793103, 11.6551724137931, 10.3448275862069, 
10.3, 10.0344827586207, 8.46666666666667, 8.6551724137931, 6.72413793103448, 
5.52173913043478, 13.6333333333333, 19.8666666666667, 20.0333333333333, 
15.7, 10.6333333333333, 11.7666666666667, 11.9310344827586, 14.7333333333333, 
15.3666666666667, 19.1333333333333, 18.3, 7.30769230769231, 4.47368421052632, 
5.16666666666667, 8.37931034482759, 9.35714285714286, 8.71428571428571, 
8.10344827586207, 6.31818181818182, 8.11538461538461, 7.07692307692308, 
7.53333333333333, 5.64, 4.69230769230769, 9.5, 17.4666666666667, 
17.448275862069, 14.7241379310345, 12.8571428571429, 11.8965517241379, 
13.6538461538462, 13, 22.0967741935484, 24.2258064516129, 26.4516129032258, 
9.93548387096774, 3.44, 6.04, 8.3448275862069, 9.26666666666667, 
8.6551724137931, 6.43333333333333, 7.22222222222222, 7.90322580645161, 
7.56666666666667, 6.1, 3.25, 1.57142857142857, 8.4, 23.9354838709677, 
23.3225806451613, 18.3, 15.448275862069, 14.0740740740741, 14.551724137931, 
18.8275862068966, 18.6666666666667, 21.4516129032258, 24.1290322580645, 
10.0645161290323, 4.21428571428571, 5.71428571428571, 7.56666666666667, 
7.51724137931035, 6.10344827586207, 5.66666666666667, 6.53571428571429, 
6.31034482758621, 6, 5.73076923076923, 3.33333333333333, 2.8, 
11.2333333333333, 23.258064516129, 23.9354838709677, 21.2258064516129, 
18.4516129032258, 16.6, 10.8064516129032, 15.8064516129032, 19.4, 
23.0967741935484, 22.3548387096774, 5.64285714285714, 4.75, 5.38888888888889, 
7.19230769230769, 7.29032258064516, 7.93103448275862, 8.33333333333333, 
7.07692307692308, 8.6, 6.57142857142857, 4.16666666666667, 2.94736842105263, 
2.4, 7, 21.9677419354839, 20.258064516129, 17.8666666666667, 
14.7857142857143, 12.1923076923077, 11.5806451612903, 15), Standing = c(1, 
1, 2, 3.88888888888889, 3.77777777777778, 2.45454545454545, 4.93333333333333, 
3.07692307692308, 3.1875, 2.55, 2.92, 3, 3.5, 3.8, 4, 4.35714285714286, 
1.88235294117647, 1, 1, 1.88888888888889, 1.2, 2, 2.83333333333333, 
1.6, 2.41666666666667, 1.9, 1.33333333333333, 5.85185185185185, 
6.77777777777778, 6.62962962962963, 5.77777777777778, 4.82608695652174, 
5.40740740740741, 6, 4.40740740740741, 5.93103448275862, 6.32142857142857, 
8.30769230769231, 9.03571428571429, 11.9655172413793, 3.22222222222222, 
2, 1.61538461538462, 2.78947368421053, 4.26086956521739, 4.47368421052632, 
3, 4.5, 4.6875, 4.125, 3.53846153846154, 7.72413793103448, 8.82758620689655, 
7.5, 5.2962962962963, 6.04166666666667, 5.71428571428571, 5.24137931034483, 
7.89655172413793, 7.11111111111111, 7, 5.41379310344828, 9.73333333333333, 
12, 5.96551724137931, 2.61111111111111, 3.5, 3.86363636363636, 
5.7, 4.45454545454545, 5.47826086956522, 4.82608695652174, 5.625, 
4.93333333333333, 3.26666666666667, 11.5806451612903, 15.5483870967742, 
13.8709677419355, 12.4516129032258, 10.8, 12.7741935483871, 14.9354838709677, 
15.2258064516129, 14.5806451612903, 16.3870967741935, 17.9677419354839, 
22.6774193548387, 27.9677419354839, 17.4193548387097, 5, 4.83333333333333, 
8.78571428571429, 12.4642857142857, 12.1724137931034, 12.76, 
8.375, 8.86666666666667, 5.40740740740741, 3.91304347826087, 
13.1290322580645, 18.9677419354839, 18.8064516129032, 17, 17.3225806451613, 
19.4193548387097, 20.3870967741935, 19.6129032258065, 18.7096774193548, 
20.3870967741935, 21.5806451612903, 24.4516129032258, 27.5483870967742, 
14.9032258064516, 4.76923076923077, 4.17391304347826, 6.83333333333333, 
11.5, 9.6, 13.8064516129032, 10.9310344827586, 7.26086956521739, 
7.29411764705882, 5.375, 19, 22.9032258064516, 20.0322580645161, 
16.1290322580645, 13.3870967741935, 13.8387096774194, 14.1612903225806, 
13.2258064516129, 12.8709677419355, 13.4516129032258, 18, 21.3225806451613, 
24.1290322580645, 15.5483870967742, 5.90476190476191, 8.125, 
8.96, 11.5357142857143, 13.7931034482759, 12.6, 11.0384615384615
), ID = structure(c(1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 
2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 
2L, 2L, 2L, 2L, 2L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 
3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 4L, 4L, 4L, 
4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 
4L, 4L, 4L, 4L, 4L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 
5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 6L, 6L, 6L, 
6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 
6L, 6L, 6L, 6L, 6L), .Label = c("41361", "41365", "41366", "41366bis", 
"41367", "41368"), class = "factor"), Area = structure(c(2L, 
2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 
2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 
2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 
2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 
2L, 2L, 2L, 2L, 2L, 2L, 2L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L), .Label = c("Loliondo", 
"Seronera"), class = "factor"), Feeding_Foraging = c(26.8444444444444, 
27.0461538461538, 26.8333333333333, 25.5533333333333, 25.1, 26.8275362318841, 
24.64, 25.86, 24.7833333333333, 24.6229885057471, 23.6, 23.9333333333333, 
24.1712643678161, 24, 23.2, 22.7285714285714, 25.2781609195402, 
27.5842105263158, 26.6739130434783, 26.8333333333333, 26.5820512820513, 
27.3090909090909, 26.625, 27.6833333333333, 24.6194581280788, 
25.1727272727273, 25.4857142857143, 19.2, 19.1025641025641, 19.3333333333333, 
19.6747126436782, 21.4827586206897, 20.3448275862069, 19.6114942528736, 
20.4666666666667, 19.1011494252874, 18.7, 17.7551724137931, 16.2241379310345, 
14.2550724637681, 21.6666666666667, 25.1275362318841, 24.4733333333333, 
23.8923076923077, 21.9904761904762, 22.3738095238095, 23.0310344827586, 
23.3540229885057, 20.9121212121212, 21.9228070175439, 21.3454545454545, 
15.8249336870027, 15.040350877193, 15.6333333333333, 17.5126436781609, 
18.1502463054187, 17.247619047619, 17.3367816091954, 16.1181818181818, 
16.6820512820513, 16.8102564102564, 16.8666666666667, 13.24, 
14.0384615384615, 17.5, 20.851282051282, 21.573275862069, 20.8491379310345, 
20.3371428571429, 22.1346469622332, 20.5384615384615, 20.4, 26.2272089761571, 
27.9758064516129, 28.7516129032258, 17.9354838709677, 14.6335483870968, 
16.8141935483871, 17.6028921023359, 19.3634408602151, 17.3003337041157, 
14.7881720430108, 15.2222222222222, 14.9354838709677, 13.3731182795699, 
11.7451612903226, 8.15, 3.42142857142857, 12.3677419354839, 27.0554838709677, 
26.6269284712482, 22.4379310344828, 19.8186462324393, 20.3499361430396, 
21.2440318302387, 25.289124668435, 22.2266666666667, 25.6116129032258, 
26.8790322580645, 16.3870967741935, 10.9562211981567, 11.447619047619, 
12.9333333333333, 13.0344827586207, 10.6367816091954, 10.1494252873563, 
10.5357142857143, 11.3770114942529, 10.2592592592593, 9.07559681697613, 
6.08333333333333, 4.74117647058824, 14.9752688172043, 25.9503722084367, 
26.7873357228196, 25.4530791788856, 22.2016129032258, 20.9, 15.8731182795699, 
19.9602977667494, 26.3166666666667, 26.5058651026393, 26.5821114369501, 
11.2428571428571, 9.85344827586207, 11.9555555555556, 14.5471464019851, 
16.1290322580645, 16.1890989988877, 16.4301075268817, 17.4317617866005, 
18.3096774193548, 16.7004608294931, 12.4569892473118, 9.54736842105263, 
7.6962962962963, 15.3666666666667, 26.3677419354839, 23.5437788018433, 
23.8282051282051, 20.7190476190476, 18.7923076923077, 17.5139784946237, 
21.6551724137931)), row.names = c(NA, -144L), vars = "hour", indices = list(
    c(0L, 24L, 48L, 72L, 96L, 120L), c(1L, 25L, 49L, 73L, 97L, 
    121L), c(2L, 26L, 50L, 74L, 98L, 122L), c(3L, 27L, 51L, 75L, 
    99L, 123L), c(4L, 28L, 52L, 76L, 100L, 124L), c(5L, 29L, 
    53L, 77L, 101L, 125L), c(6L, 30L, 54L, 78L, 102L, 126L), 
    c(7L, 31L, 55L, 79L, 103L, 127L), c(8L, 32L, 56L, 80L, 104L, 
    128L), c(9L, 33L, 57L, 81L, 105L, 129L), c(10L, 34L, 58L, 
    82L, 106L, 130L), c(11L, 35L, 59L, 83L, 107L, 131L), c(12L, 
    36L, 60L, 84L, 108L, 132L), c(13L, 37L, 61L, 85L, 109L, 133L
    ), c(14L, 38L, 62L, 86L, 110L, 134L), c(15L, 39L, 63L, 87L, 
    111L, 135L), c(16L, 40L, 64L, 88L, 112L, 136L), c(17L, 41L, 
    65L, 89L, 113L, 137L), c(18L, 42L, 66L, 90L, 114L, 138L), 
    c(19L, 43L, 67L, 91L, 115L, 139L), c(20L, 44L, 68L, 92L, 
    116L, 140L), c(21L, 45L, 69L, 93L, 117L, 141L), c(22L, 46L, 
    70L, 94L, 118L, 142L), c(23L, 47L, 71L, 95L, 119L, 143L)), group_sizes = c(6L, 
6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 
6L, 6L, 6L, 6L, 6L, 6L, 6L), biggest_group_size = 6L, labels = structure(list(
    hour = 0:23), row.names = c(NA, -24L), class = "data.frame", vars = "hour"), class = c("grouped_df", 
"tbl_df", "tbl", "data.frame"))
$\endgroup$
  • 1
    $\begingroup$ Could you provide more background information for the nature of the variables Feeding_Foraging and Standing because it could be that the Binomial distribution is not appropriate in this case. $\endgroup$ – Dimitris Rizopoulos Apr 10 at 13:09
1
$\begingroup$

This happens because you are specifying a discrete probability distribution for the outcome - the binomial distribution - but then you are inputting values into the model for the outcome that are not integers.

If we round the values for the outcome, the model will be fitted without a warning:

> m1 <- glmer(cbind(round(Feeding_Foraging), round(Standing)) ~ poly(hour, 2) * Area + (1 | ID), data = GLM_df, family = binomial())

>  summary(m1)
Generalized linear mixed model fit by maximum likelihood (Laplace Approximation) [glmerMod]
 Family: binomial  ( logit )
Formula: cbind(round(Feeding_Foraging), round(Standing)) ~ poly(hour,  
2) * Area + (1 | ID)
   Data: GLM_df

Random effects:
 Groups Name        Variance Std.Dev.
 ID     (Intercept) 0.1124   0.3353  
Number of obs: 144, groups:  ID, 6

Fixed effects:
                             Estimate Std. Error z value Pr(>|z|)    
(Intercept)                  0.249862   0.198522   1.259   0.2082    
poly(hour, 2)1               0.005553   0.542813   0.010   0.9918    
poly(hour, 2)2               5.911065   0.550746  10.733  < 2e-16 ***
AreaSeronera                 1.375804   0.284776   4.831 1.36e-06 ***
poly(hour, 2)1:AreaSeronera  0.845705   0.970958   0.871   0.3838    
poly(hour, 2)2:AreaSeronera -2.197180   0.970101  -2.265   0.0235 *  

If we simply ignore the warning, the output is very similar:

Random effects:
 Groups Name        Variance Std.Dev.
 ID     (Intercept) 0.1245   0.3529  
Number of obs: 144, groups:  ID, 6

Fixed effects:
                            Estimate Std. Error z value Pr(>|z|)    
(Intercept)                  0.24588    0.20843   1.180   0.2381    
poly(hour, 2)1               0.08282    0.54318   0.152   0.8788    
poly(hour, 2)2               5.92309    0.55043  10.761  < 2e-16 ***
AreaSeronera                 1.39314    0.29874   4.663 3.11e-06 ***
poly(hour, 2)1:AreaSeronera  0.77660    0.97337   0.798   0.4250    
poly(hour, 2)2:AreaSeronera -2.21217    0.97113  -2.278   0.0227 *  

Please note: I am not saying that it is OK to ignore the warning, although often it is, or to round the values (which probably isn't a great idea) - I am simply pointing out why and how the warning occurs, but without further information about your study design and what the variables represent, it is hard to give further advice.

$\endgroup$

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.