1
$\begingroup$

I'm currently trying to see if the frequency of a behaviour measured in a binary format (yes/no (where yes means the behaviour is present) is related to 1. the month in which behaviour took place and 2. which group individuals belong to. I would appreciate some advice on interpreting a GLM and if this is the best model to address my data, as I am inexperienced with performing GLM's. I initially thought that a general linear model with poisson distribution would be best, using data in the following format:

month   group   fled    n
March   A       Yes     18
March   A       No      30
March   B       Yes     12
March   B       No      35
April   A       Yes     17
April   A       No      60
April   B       Yes     16
April   B       No      48
May     A       Yes     13
May     A       No      42
May     B       Yes     15
May     B       No      43
June    A       Yes     18
June    A       No      58
June    B       Yes      6
June    B       No      41
July    A       Yes      3
July    A       No      20
July    B       Yes      2
July    B       No      15

enter image description here

I performed a GLM with poisson distribution in R using AIC model selection, however I am little unsure of a few outputs and I'm starting to doubt if this is the best way to use the data. (please see workflow below). Firstly, I understand that the intercept is set usually to variable which is alphanumerically first, so does this mean the intercept been set to 'Group A' or is the intercept the response 'n' according to my model? As I'm confused about the intercept I'm having trouble making sense of the results. Also by looking at my residuals vs fitted lines graph plus my null & residual deviances that the model isn't a very good fit (due to the size gap of the values). Is this the correct assumption? Any advice on interpretation from a more experienced eye would be much appreciated! Happy to add more code/info if needed.

> full.model <- glm(n~month*group*fled, data=flee, family=poisson)
> options(na.action = "na.fail")
> output <- dredge(full.model, rank=AIC)
> output

Global model call: glm(formula = n ~ month * group * fled, family = poisson, data = flee)
---
Model selection table 
    (Int) fld grp mnt fld:grp fld:mnt grp:mnt fld:grp:mnt df   logLik   AIC  delta weight
8   4.075   +   +   +                                      7  -56.166 126.3   0.00  0.256
24  4.075   +   +   +               +                     11  -52.392 126.8   0.45  0.204
16  4.058   +   +   +       +                              8  -55.879 127.8   1.43  0.125
32  4.058   +   +   +       +       +                     12  -52.105 128.2   1.88  0.100
6   3.989   +       +                                      6  -58.235 128.5   2.14  0.088
22  3.989   +       +               +                     10  -54.461 128.9   2.59  0.070
40  4.077   +   +   +                       +             11  -53.687 129.4   3.04  0.056
56  4.077   +   +   +               +       +             15  -49.913 129.8   3.49  0.045
48  4.060   +   +   +       +               +             12  -53.400 130.8   4.47  0.027
64  4.056   +   +   +       +       +       +             16  -49.460 130.9   4.59  0.026
128 4.094   +   +   +       +       +       +           + 20  -47.839 135.7   9.35  0.002
4   3.755   +   +                                          3  -90.218 186.4  60.10  0.000
12  3.738   +   +           +                              4  -89.931 187.9  61.53  0.000
2   3.669   +                                              2  -92.287 188.6  62.24  0.000
7   3.648       +   +                                      6 -132.269 276.5 150.21  0.000
5   3.562           +                                      5 -134.338 278.7 152.34  0.000
39  3.651       +   +                       +             10 -129.790 279.6 153.25  0.000
3   3.329       +                                          2 -166.321 336.6 210.31  0.000
1   3.243                                                  1 -168.390 338.8 212.45  0.000


> #Construct best model
> fit.ddt <- glm(n~group+month+fled, data=flee, family=poisson)

> #Check assumptions
> #Independent data
> dwtest(fit.ddt)

Durbin-Watson test

data:  fit.ddt
DW = 3.128, p-value = 0.9824
alternative hypothesis: true autocorrelation is greater than 0

> #Residuals
> par(mfrow=c(2,2))
> plot(fit.ddt)
> par(mfrow=c(1,1))
> simulationOutput <- simulateResiduals(fittedModel=fit.ddt, n=250)
> plot(simulationOutput)
> testDispersion(simulationOutput)

    DHARMa nonparametric dispersion test via sd of residuals fitted vs. simulated

data:  simulationOutput
ratioObsSim = 0.82052, p-value = 0.44
alternative hypothesis: two.sided

enter image description here

enter image description here

> #Results of fitted GLM
> Anova(fit.ddt, type=3)
Analysis of Deviance Table (Type III tests)

Response: n
      LR Chisq Df Pr(>Chisq)    
group    4.138  1    0.04192 *  
month   68.104  4  5.702e-14 ***
fled   152.206  1  < 2.2e-16 ***
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
> summary(fit.ddt)

Call:
glm(formula = n ~ group + month + fled, family = poisson, data = flee)

Deviance Residuals: 
    Min       1Q   Median       3Q      Max  
-2.2024  -0.4784   0.1989   0.5698   1.5703  

Coefficients:
            Estimate Std. Error z value Pr(>|z|)    
(Intercept)  4.07458    0.09655  42.203  < 2e-16 ***
groupB      -0.18017    0.08875  -2.030  0.04234 *  
monthJuly   -1.25988    0.17914  -7.033 2.02e-12 ***
monthJune   -0.13658    0.12338  -1.107  0.26831    
monthMarch  -0.39488    0.13273  -2.975  0.00293 ** 
monthMay    -0.22137    0.12626  -1.753  0.07955 .  
fledYes     -1.18377    0.10433 -11.347  < 2e-16 ***
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

(Dispersion parameter for poisson family taken to be 1)

    Null deviance: 241.103  on 19  degrees of freedom
Residual deviance:  16.655  on 13  degrees of freedom
AIC: 126.33

Number of Fisher Scoring iterations: 4
$\endgroup$

Your Answer

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