6
$\begingroup$

I have the following model in r that compares the differences between dives where whales fed and dives where whales didn't fed (distribution is binomial: presence of feeding (foraging) = 1, abscence = 0). Whale (18 individuals) is used as random factor.

I included several metrics in the model: dive duration, maximum depth, descent/ascent rate, etc... and used scale on all numerical metrics (scale())

g_model <- glmer(foraging~max_depths*diel_2+duration+pd_times+d_rate+a_rate+bottom_prop+(1|whale),
                      data=data, control=glmerControl(optimizer="bobyqa",optCtrl=list(maxfun=2e5)),
                      family="binomial", na.action = na.fail)



summary(g_model)

Generalized linear mixed model fit by maximum likelihood (Laplace Approximation) ['glmerMod']
 Family: binomial  ( logit )
Formula: foraging ~ max_depths * diel_2 + duration + pd_times + d_rate +  
    a_rate + bottom_prop + (1 | whale)
   Data: data
Control: glmerControl(optimizer = "bobyqa", optCtrl = list(maxfun = 2e+05))

     AIC      BIC   logLik deviance df.resid 
  1244.6   1301.4   -612.3   1224.6     2164 

Scaled residuals: 
    Min      1Q  Median      3Q     Max 
-99.364  -0.195   0.083   0.285   4.311 

Random effects:
 Groups Name        Variance Std.Dev.
 whale  (Intercept) 0.2201   0.4692  
Number of obs: 2174, groups:  whale, 18

Fixed effects:
                       Estimate Std. Error z value Pr(>|z|)    
(Intercept)              0.5621     0.1600   3.514 0.000441 ***
max_depths               1.9123     0.1863  10.266  < 2e-16 ***
diel_2Night              1.5491     0.2577   6.012 1.83e-09 ***
duration                -0.3535     0.1516  -2.331 0.019739 *  
pd_times                -0.6118     0.1531  -3.996 6.45e-05 ***
d_rate                   0.6536     0.1099   5.949 2.70e-09 ***
a_rate                  -0.3688     0.1248  -2.955 0.003122 ** 
bottom_prop              2.8876     0.1343  21.502  < 2e-16 ***
max_depths:diel_2Night   1.9049     0.3184   5.984 2.18e-09 ***
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

Correlation of Fixed Effects:
            (Intr) mx_dpt dl_2Ng duratn pd_tms d_rate a_rate bttm_p
max_depths  -0.083                                                 
diel_2Night -0.313  0.206                                          
duration    -0.115 -0.678  0.066                                   
pd_times     0.034 -0.037 -0.020 -0.098                            
d_rate       0.079 -0.131 -0.042  0.409 -0.015                     
a_rate       0.095 -0.659 -0.139  0.423  0.093 -0.134              
bottom_prop  0.086  0.628  0.158 -0.449 -0.083  0.078 -0.248       
mx_dpth:_2N  0.065  0.034  0.600 -0.165  0.066 -0.138 -0.081  0.168

Two of the values do not make sense at all: duration and pd_times (post-dive duration).

Feeding dives are usually longer and since they have a high energetic cost whales usually rest for a while after at surface. Nevertheless, estimates are negative for both metrics. I know that just because that's common knowledge it doesn't mean my data will follow those assumptions but when I make boxplots of the data, duration is quite higher in feeding dives, contrary to what the model says (graph below). The post-dive duration graph is just weird (I suppose it is because of the outliers) and I can't really figure out anything out of it (also if you know what I should do to correct this boxplot it would be awesome! Graph below as well).

It was suggested that I should mean-center the variables, how can I do it? Or did I already did that by scaling? I already looked for correlation between variables and found nothing. Looked at differences between individuals (only one individual in 18 performed longer non-feeding dives than feeding dives, and thats because it only had 2 long non-feeding dives). I can't really figure it out.

F = feeding dives/ NF = non-feeding dives

DURATIONenter image description here

PD_TIMES enter image description here

Thank you!

$\endgroup$
1
  • $\begingroup$ You need to mean-centre by group (whale), as I've explained already in your other thread. What you seem to have done is just mean centre the duration variable globally, which will not help. You also need to include the means for each whale in the model. $\endgroup$ Commented Jul 26, 2020 at 10:57

1 Answer 1

2
$\begingroup$

When you use the scale function on a variable, this will apply to the whole variable.

That is not what you want here.

You need to try to disentangle the within-whale associations from the between-whale associations. One good way to do this is by mean-centering the variable(s) in question by group - that is, by whale in your case. Then you ALSO have to include the mean variable in the model. In R I would suggest using the dplyr package to create the whale means, and the built-in merge function to add the means to your data. Then you simply create the whale mean-centred variable by duducting the whale mean from it. For example:

mydata <- merge(mydata, mydata %>% group_by(id) %>% summarise(duration_whale_mean = mean(duration)))
mydata$duration_mean_cent <- mydata$duration - mydata$duration_whale_mean

Then in your model you will have:

foraging ~ duration_mean_cent + duration_whale_mean + ...

(and you will not use the duration variable in the model.

$\endgroup$
1
  • $\begingroup$ Does this answer your question ? If so please consider marking it as the accepted answer. If not please let us know why so that it can be improved $\endgroup$ Commented Aug 7, 2020 at 5:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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