Example analysis of dyadic behavioral data

The enclosed dataset is from single sided attacks and this is a preliminary analysis.

Data description

big_dyad
## # A tibble: 9,958 x 11
## # Groups:   upen [59]
##    upen  receiver source     wr    ws interact       M      A      D previous
##    <chr>    <dbl>  <dbl>  <dbl> <dbl>    <dbl>   <dbl>  <dbl>  <dbl>    <dbl>
##  1 2_F4~       27     25 -1.82  -5.62        0 -3.72    3.80   3.80         1
##  2 2_F4~       53     25  1.98  -5.62        0 -1.82    7.6    7.6          0
##  3 2_F4~       55     25  7.38  -5.62        4  0.882  13     13            0
##  4 2_F4~       69     25  5.58  -5.62        2 -0.0182 11.2   11.2          0
##  5 2_F4~       71     25  5.58  -5.62        3 -0.0182 11.2   11.2          0
##  6 2_F4~       79     25 -0.218 -5.62        1 -2.92    5.40   5.40         1
##  7 2_F4~       83     25 15.2   -5.62        0  4.78   20.8   20.8          0
##  8 2_F4~       85     25  6.38  -5.62       21  0.382  12     12            0
##  9 2_F4~       89     25 11.6   -5.62        6  2.98   17.2   17.2          0
## 10 2_F4~       99     25 -6.42  -5.62        0 -6.02   -0.800  0.800        1
## # ... with 9,948 more rows, and 1 more variable: linte <dbl>
dim(big_dyad)
## [1] 9958   11
length(unique(big_dyad$receiver))
## [1] 794
length(unique(big_dyad$upen))
## [1] 59

Distribution of intensity of attacks (interaction)

The first problem we observe is zero inflatino: most dyads did not register single sided attacks

This does not mean that animals did not interact. They could have been involved in recyprocal fights or other types of aggression. We have more aggression phenotypes recorded, but getting those out would take more time (except for recyprocal fights)

ggplot(big_dyad, aes(x=interact)) + geom_histogram()
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.

ggplot(big_dyad, aes(x=linte)) + geom_histogram()
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.

Are there any animals that did not fight at all?

  • 17 pigs did not receive any aggression at all
  • 1 pig did not deliver aggression at all (and this one is part of the 17)
group_by(big_dyad,receiver)%>%summarize(total_received=sum(interact)==0)%>%filter(total_received)
## # A tibble: 17 x 2
##    receiver total_received
##       <dbl> <lgl>         
##  1      197 TRUE          
##  2      220 TRUE          
##  3      249 TRUE          
##  4      271 TRUE          
##  5      281 TRUE          
##  6      283 TRUE          
##  7      313 TRUE          
##  8      330 TRUE          
##  9      351 TRUE          
## 10      362 TRUE          
## 11      388 TRUE          
## 12      432 TRUE          
## 13      446 TRUE          
## 14      447 TRUE          
## 15      697 TRUE          
## 16      715 TRUE          
## 17     1089 TRUE
group_by(big_dyad,source)%>%summarize(total_received=sum(interact)==0)%>%filter(total_received)
## # A tibble: 1 x 2
##   source total_received
##    <dbl> <lgl>         
## 1    432 TRUE

Intensity of aggresion vs weight of pigs

it does not look very promising in terms of weight difference as a predictor of attack intensity. This is not expected. or maybe it is? An interesting discussion to have with behaviorists.

ggplot(big_dyad,aes(x=A,y=interact))+geom_point()+geom_smooth(method = "loess")
## `geom_smooth()` using formula 'y ~ x'

ggplot(big_dyad,aes(x=D,y=interact))+geom_point()+geom_smooth(method = "loess",se=T)
## `geom_smooth()` using formula 'y ~ x'

Intensity of aggresion vs previous aquaintanceship

This is expected: animals fight more with those who are new penmates

ggplot(big_dyad,aes(x=as.factor(previous),y=linte))+geom_boxplot()

Fit a simple dyadic model

Notice that there is no covariance estimated between receiver and source in this model (I don’t think lmer can fit that)

lm1<-lmer(interact~wr+ws+previous+(1|receiver)+(1|source)+(1|upen),data=big_dyad)
summary(lm1)
## Linear mixed model fit by REML ['lmerMod']
## Formula: interact ~ wr + ws + previous + (1 | receiver) + (1 | source) +  
##     (1 | upen)
##    Data: big_dyad
## 
## REML criterion at convergence: 81328
## 
## Scaled residuals: 
##    Min     1Q Median     3Q    Max 
## -3.718 -0.342 -0.162  0.087 31.911 
## 
## Random effects:
##  Groups   Name        Variance Std.Dev.
##  receiver (Intercept)  30.359   5.510  
##  source   (Intercept)  12.229   3.497  
##  upen     (Intercept)   1.593   1.262  
##  Residual             179.309  13.391  
## Number of obs: 9958, groups:  receiver, 794; source, 794; upen, 59
## 
## Fixed effects:
##              Estimate Std. Error t value
## (Intercept)  6.956117   0.322732  21.554
## wr          -0.025649   0.039176  -0.655
## ws           0.009338   0.035149   0.266
## previous    -4.037669   0.328319 -12.298
## 
## Correlation of Fixed Effects:
##          (Intr) wr     ws    
## wr       -0.006              
## ws       -0.004 -0.564       
## previous -0.224  0.007  0.005