iterations

Quarto

Quarto enables you to weave together content and executable code into a finished document. To learn more about Quarto see https://quarto.org.

Running Code

When you click the Render button a document will be generated that includes both content and the output of embedded code. You can embed code like this:

library(broom)
library(lme4)
Loading required package: Matrix
library(dplyr)

Attaching package: 'dplyr'
The following objects are masked from 'package:stats':

    filter, lag
The following objects are masked from 'package:base':

    intersect, setdiff, setequal, union
library(lme4)
library(lmerTest)

Attaching package: 'lmerTest'
The following object is masked from 'package:lme4':

    lmer
The following object is masked from 'package:stats':

    step
library(emmeans)
library(car)
Loading required package: carData

Attaching package: 'car'
The following object is masked from 'package:dplyr':

    recode
library(tidyverse)
-- Attaching core tidyverse packages ------------------------ tidyverse 2.0.0 --
v forcats   1.0.0     v readr     2.1.4
v ggplot2   3.4.3     v stringr   1.5.0
v lubridate 1.9.2     v tibble    3.2.1
v purrr     1.0.1     v tidyr     1.3.0
-- Conflicts ------------------------------------------ tidyverse_conflicts() --
x tidyr::expand() masks Matrix::expand()
x dplyr::filter() masks stats::filter()
x dplyr::lag()    masks stats::lag()
x tidyr::pack()   masks Matrix::pack()
x car::recode()   masks dplyr::recode()
x purrr::some()   masks car::some()
x tidyr::unpack() masks Matrix::unpack()
i Use the conflicted package (<http://conflicted.r-lib.org/>) to force all conflicts to become errors
library(corrplot)
corrplot 0.92 loaded
library(RColorBrewer)
library(ggplot2)
library(MASS)

Attaching package: 'MASS'

The following object is masked from 'package:dplyr':

    select
library(agricolae)
library(vegan)
Loading required package: permute
Loading required package: lattice
Registered S3 methods overwritten by 'vegan':
  method      from
  plot.rda    klaR
  predict.rda klaR
  print.rda   klaR
This is vegan 2.6-4
library(dplyr)
library(readr)
library(DT)
library(ggplot2)
library(quantreg)
Loading required package: SparseM

Attaching package: 'SparseM'

The following object is masked from 'package:base':

    backsolve
library(broom.mixed)
library(pedigree)
library(pedigreemm)
library(pedtools)

Data Reading

You can add options to executable code like this

rm(list = ls())

setwd("C:/Users/anune/OneDrive/Desktop/PIC_DataAnalysis_files")

data_PIC <- read.csv("PIC_65_FIRE.AN.1.csv")

head(data_PIC$ENTRY_TIME)
[1] "10/27/2022 12:51" "10/27/2022 12:00" "10/27/2022 13:03" "10/27/2022 7:27" 
[5] "10/27/2022 8:04"  "10/27/2022 8:41" 
data_PIC <- mutate(data_PIC, 

                   ENTRY_DATE = as_date(mdy_hm(ENTRY_TIME, tz = "UTC")),

                   ENTRY = mdy_hm(ENTRY_TIME, tz = "UTC"),
                   
                   
                   EXIT_DATE = as_date(mdy_hm(EXIT_TIME, tz = "UTC")),

                   EXIT = mdy_hm(EXIT_TIME, tz = "UTC")

                   )

summary(data_PIC$ENTRY_DATE)
        Min.      1st Qu.       Median         Mean      3rd Qu.         Max. 
"2022-04-06" "2023-01-02" "2023-02-19" "2023-02-18" "2023-04-08" "2023-06-19" 

Data Arrange

The echo: false option disables the printing of code (only output is displayed).

class(data_PIC)
[1] "data.frame"
data_PIC$PEN <- as.factor(data_PIC$PEN)

data_PIC$Social_Group <- paste(data_PIC$PEN, data_PIC$START_DAY, data_PIC$OFFTEST_DAY, sep = "_")

head(data_PIC$Social_Group)
[1] "B0113_27-Oct-22_2-Jan-23" "B0113_27-Oct-22_2-Jan-23"
[3] "B0113_27-Oct-22_2-Jan-23" "B0113_27-Oct-22_2-Jan-23"
[5] "B0113_27-Oct-22_2-Jan-23" "B0113_27-Oct-22_2-Jan-23"
data_PIC <- group_by(data_PIC, Social_Group)


data_PIC.arrange <- arrange(data_PIC, Social_Group, ENTRY, by_group = TRUE)%>%
  mutate(line= row_number())


data_PIC.arrange
# A tibble: 114,263 x 22
# Groups:   Social_Group [36]
         ID  LINE    SIRE    DAM LITTER PEN    FARM ENTRY_TIME EXIT_TIME STAY_IN
      <int> <int>   <int>  <int>  <int> <fct> <int> <chr>      <chr>       <int>
 1 97900600    65  8.82e7 9.22e7 7.90e7 B0111   774 3/15/2023~ 3/15/202~     156
 2 97900500    65  9.20e7 9.15e7 7.86e7 B0111   774 3/15/2023~ 3/15/202~     416
 3 97900600    65  8.82e7 9.22e7 7.90e7 B0111   774 3/15/2023~ 3/15/202~     469
 4 97887849    65  8.83e7 9.34e7 7.90e7 B0111   774 3/15/2023~ 3/15/202~      48
 5 97900500    65  9.20e7 9.15e7 7.86e7 B0111   774 3/15/2023~ 3/15/202~     166
 6 97900600    65  8.82e7 9.22e7 7.90e7 B0111   774 3/15/2023~ 3/15/202~     113
 7 97887847    65  8.83e7 9.34e7 7.90e7 B0111   774 3/15/2023~ 3/15/202~       7
 8 97900600    65  8.82e7 9.22e7 7.90e7 B0111   774 3/15/2023~ 3/15/202~     103
 9 97887847    65  8.83e7 9.34e7 7.90e7 B0111   774 3/15/2023~ 3/15/202~      24
10 97900231    65  8.83e7 9.37e7 7.90e7 B0111   774 3/15/2023~ 3/15/202~    1862
# i 114,253 more rows
# i 12 more variables: FEED_INTK <int>, ENTRY_WT <int>, EXIT_WT <int>,
#   FEEDER_NO <int>, START_DAY <chr>, OFFTEST_DAY <chr>, ENTRY_DATE <date>,
#   ENTRY <dttm>, EXIT_DATE <date>, EXIT <dttm>, Social_Group <chr>, line <int>
data_PIC.arrange %>%
  dplyr::select(ID, ENTRY, Social_Group)
# A tibble: 114,263 x 3
# Groups:   Social_Group [36]
         ID ENTRY               Social_Group             
      <int> <dttm>              <chr>                    
 1 97900600 2023-03-15 08:06:00 B0111_16-Mar-23_15-May-23
 2 97900500 2023-03-15 08:12:00 B0111_16-Mar-23_15-May-23
 3 97900600 2023-03-15 08:19:00 B0111_16-Mar-23_15-May-23
 4 97887849 2023-03-15 08:34:00 B0111_16-Mar-23_15-May-23
 5 97900500 2023-03-15 08:36:00 B0111_16-Mar-23_15-May-23
 6 97900600 2023-03-15 08:39:00 B0111_16-Mar-23_15-May-23
 7 97887847 2023-03-15 08:44:00 B0111_16-Mar-23_15-May-23
 8 97900600 2023-03-15 08:49:00 B0111_16-Mar-23_15-May-23
 9 97887847 2023-03-15 08:52:00 B0111_16-Mar-23_15-May-23
10 97900231 2023-03-15 09:04:00 B0111_16-Mar-23_15-May-23
# i 114,253 more rows

Creating Time Between

data_PIC <- data_PIC %>%
  arrange(Social_Group, ENTRY) %>%
  group_by(Social_Group) %>%
  mutate(Follower_ID = lead(ID),
         Follower_Time = lead(ENTRY),
         Follower_Social_Group = lead(Social_Group),
         line= row_number(),
         Hour_ENTRY = hour(ENTRY),
         time_between= as.numeric(Follower_Time - EXIT, unit="secs"))%>%
  filter(time_between < 36000,time_between>=0)

Filters

data_PIC%>% mutate(time_between= as.numeric(Follower_Time - ENTRY, unit="secs"),
         lapse_Time = seconds(Follower_Time - ENTRY))%>%
  dplyr::select(time_between, lapse_Time)
Adding missing grouping variables: `Social_Group`
# A tibble: 113,056 x 3
# Groups:   Social_Group [36]
   Social_Group              time_between lapse_Time
   <chr>                            <dbl> <Period>  
 1 B0111_16-Mar-23_15-May-23          360 360S      
 2 B0111_16-Mar-23_15-May-23          420 420S      
 3 B0111_16-Mar-23_15-May-23          900 900S      
 4 B0111_16-Mar-23_15-May-23          120 120S      
 5 B0111_16-Mar-23_15-May-23          180 180S      
 6 B0111_16-Mar-23_15-May-23          300 300S      
 7 B0111_16-Mar-23_15-May-23          300 300S      
 8 B0111_16-Mar-23_15-May-23          180 180S      
 9 B0111_16-Mar-23_15-May-23          720 720S      
10 B0111_16-Mar-23_15-May-23         1920 1920S     
# i 113,046 more rows
data_PIC_pvalues_morethan_60  <- as.numeric(data_PIC$time_between)


data_PIC_pvalues_morethan_60 <- filter (data_PIC, time_between >  60) %>%
  mutate(TIME_FEEDER = as.numeric(STAY_IN))


dim(data_PIC_pvalues_morethan_60)
[1] 32528    28
summary(data_PIC_pvalues_morethan_60$TIME_FEEDER)
   Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
    5.0   564.8  1246.0  1364.2  1970.0  7200.0 

Fixed Effect L_Time

head(data_PIC_pvalues_morethan_60)
# A tibble: 6 x 28
# Groups:   Social_Group [1]
        ID  LINE     SIRE    DAM LITTER PEN    FARM ENTRY_TIME EXIT_TIME STAY_IN
     <int> <int>    <int>  <int>  <int> <fct> <int> <chr>      <chr>       <int>
1 97900600    65 88153118 9.22e7 7.90e7 B0111   774 3/15/2023~ 3/15/202~     156
2 97900600    65 88153118 9.22e7 7.90e7 B0111   774 3/15/2023~ 3/15/202~     469
3 97900600    65 88153118 9.22e7 7.90e7 B0111   774 3/15/2023~ 3/15/202~     113
4 97887847    65 88291968 9.34e7 7.90e7 B0111   774 3/15/2023~ 3/15/202~       7
5 97900600    65 88153118 9.22e7 7.90e7 B0111   774 3/15/2023~ 3/15/202~     103
6 97887847    65 88291968 9.34e7 7.90e7 B0111   774 3/15/2023~ 3/15/202~      24
# i 18 more variables: FEED_INTK <int>, ENTRY_WT <int>, EXIT_WT <int>,
#   FEEDER_NO <int>, START_DAY <chr>, OFFTEST_DAY <chr>, ENTRY_DATE <date>,
#   ENTRY <dttm>, EXIT_DATE <date>, EXIT <dttm>, Social_Group <chr>,
#   Follower_ID <int>, Follower_Time <dttm>, Follower_Social_Group <chr>,
#   line <int>, Hour_ENTRY <int>, time_between <dbl>, TIME_FEEDER <dbl>
data_PIC_pvalues60 <- data_PIC_pvalues_morethan_60 %>%
  mutate(L_time = log(TIME_FEEDER))

Thresholds

summarise(total = n())

print(total_counts1)

umbral <- 60

data_PIC_pvalues_60 <- data_PIC_pvalues60 %>%
  mutate(time_between_group = case_when(
    time_between <= umbral ~ "immediate",
    time_between > umbral ~ "distant"
  ))%>% group_by(time_between_group) %>%
  group_modify( ~ broom.mixed::tidy(lme4::lmer(L_time ~ (1|ID) + (1|Follower_ID) + (1|Social_Group) + as.factor(Hour_ENTRY) , data = .x)))%>% filter(., effect == "ran_pars")

total_counts1 <- data_PIC_pvalues60 %>%
  mutate(time_between_group = case_when(
    time_between <= umbral ~ "immediate",
    time_between > umbral ~ "distant"
  )) %>%
  group_by(time_between_group) %>%
  summarise(total = n())  

print(total_counts1)
# A tibble: 1 x 2
  time_between_group total
  <chr>              <int>
1 distant            32528

Linear Mixed Model Lmer

## modelo sin pedigree modelo original efectos directos e indirectos

reduced_model_Follower.lmer <- lmer(
  L_time ~ as.factor(Hour_ENTRY) +  (1 | ID) +  (1 | Follower_ID) + (1 | Social_Group),
  data = data_PIC_pvalues60
)

Summary model

summary(reduced_model_Follower.lmer)
Linear mixed model fit by REML. t-tests use Satterthwaite's method [
lmerModLmerTest]
Formula: L_time ~ as.factor(Hour_ENTRY) + (1 | ID) + (1 | Follower_ID) +  
    (1 | Social_Group)
   Data: data_PIC_pvalues60

REML criterion at convergence: 112336.2

Scaled residuals: 
    Min      1Q  Median      3Q     Max 
-4.1568 -0.2782  0.2500  0.6290  2.3587 

Random effects:
 Groups       Name        Variance Std.Dev.
 ID           (Intercept) 0.08985  0.2997  
 Follower_ID  (Intercept) 0.02763  0.1662  
 Social_Group (Intercept) 0.05039  0.2245  
 Residual                 1.78311  1.3353  
Number of obs: 32528, groups:  ID, 548; Follower_ID, 548; Social_Group, 36

Fixed effects:
                          Estimate Std. Error         df t value Pr(>|t|)    
(Intercept)              6.891e+00  5.166e-02  8.839e+01 133.408  < 2e-16 ***
as.factor(Hour_ENTRY)1   9.990e-03  4.493e-02  3.199e+04   0.222  0.82405    
as.factor(Hour_ENTRY)2   2.395e-02  4.572e-02  3.201e+04   0.524  0.60045    
as.factor(Hour_ENTRY)3   6.582e-03  4.569e-02  3.211e+04   0.144  0.88547    
as.factor(Hour_ENTRY)4   1.036e-02  4.707e-02  3.220e+04   0.220  0.82581    
as.factor(Hour_ENTRY)5  -2.148e-01  4.867e-02  3.230e+04  -4.414 1.02e-05 ***
as.factor(Hour_ENTRY)6  -6.621e-01  4.876e-02  3.236e+04 -13.578  < 2e-16 ***
as.factor(Hour_ENTRY)7  -5.208e-01  5.171e-02  3.238e+04 -10.072  < 2e-16 ***
as.factor(Hour_ENTRY)8  -4.327e-01  5.337e-02  3.235e+04  -8.107 5.37e-16 ***
as.factor(Hour_ENTRY)9  -4.564e-01  5.421e-02  3.232e+04  -8.418  < 2e-16 ***
as.factor(Hour_ENTRY)10 -4.459e-01  5.579e-02  3.234e+04  -7.992 1.37e-15 ***
as.factor(Hour_ENTRY)11 -5.680e-01  5.709e-02  3.234e+04  -9.950  < 2e-16 ***
as.factor(Hour_ENTRY)12 -6.549e-01  5.718e-02  3.234e+04 -11.453  < 2e-16 ***
as.factor(Hour_ENTRY)13 -6.203e-01  5.717e-02  3.236e+04 -10.850  < 2e-16 ***
as.factor(Hour_ENTRY)14 -7.948e-01  5.560e-02  3.232e+04 -14.296  < 2e-16 ***
as.factor(Hour_ENTRY)15 -5.725e-01  5.590e-02  3.239e+04 -10.242  < 2e-16 ***
as.factor(Hour_ENTRY)16 -3.670e-01  5.299e-02  3.236e+04  -6.927 4.39e-12 ***
as.factor(Hour_ENTRY)17 -1.282e-01  4.882e-02  3.236e+04  -2.626  0.00863 ** 
as.factor(Hour_ENTRY)18 -8.832e-02  4.750e-02  3.226e+04  -1.860  0.06295 .  
as.factor(Hour_ENTRY)19  7.098e-03  4.654e-02  3.223e+04   0.153  0.87878    
as.factor(Hour_ENTRY)20  1.583e-03  4.539e-02  3.217e+04   0.035  0.97218    
as.factor(Hour_ENTRY)21 -2.649e-02  4.498e-02  3.209e+04  -0.589  0.55596    
as.factor(Hour_ENTRY)22  1.199e-02  4.498e-02  3.203e+04   0.267  0.78978    
as.factor(Hour_ENTRY)23 -1.492e-02  4.524e-02  3.206e+04  -0.330  0.74153    
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

Correlation matrix not shown by default, as p = 24 > 12.
Use print(x, correlation=TRUE)  or
    vcov(x)        if you need it
print(VarCorr(reduced_model_Follower.lmer), comp = "Variance")
 Groups       Name        Variance
 ID           (Intercept) 0.089848
 Follower_ID  (Intercept) 0.027628
 Social_Group (Intercept) 0.050390
 Residual                 1.783112

Checking results

hist(data_PIC$time_between)

hist(data_PIC$time_between[data_PIC$time_between<7200])

hist(data_PIC$time_between[data_PIC$time_between<3600])

table(data_PIC$time_between<=3600)

 FALSE   TRUE 
  2431 110625 
table(data_PIC$time_between<=60)

FALSE  TRUE 
32528 80528 

120 threshold

rm(list = ls())

setwd("C:/Users/anune/OneDrive/Desktop/PIC_DataAnalysis_files")

data_PIC <- read.csv("PIC_65_FIRE.AN.1.csv")

head(data_PIC$ENTRY_TIME)
[1] "10/27/2022 12:51" "10/27/2022 12:00" "10/27/2022 13:03" "10/27/2022 7:27" 
[5] "10/27/2022 8:04"  "10/27/2022 8:41" 
data_PIC <- mutate(data_PIC, 

                   ENTRY_DATE = as_date(mdy_hm(ENTRY_TIME, tz = "UTC")),

                   ENTRY = mdy_hm(ENTRY_TIME, tz = "UTC"),
                   
                   
                   EXIT_DATE = as_date(mdy_hm(EXIT_TIME, tz = "UTC")),

                   EXIT = mdy_hm(EXIT_TIME, tz = "UTC")

                   )

summary(data_PIC$ENTRY_DATE)
        Min.      1st Qu.       Median         Mean      3rd Qu.         Max. 
"2022-04-06" "2023-01-02" "2023-02-19" "2023-02-18" "2023-04-08" "2023-06-19" 
data_PIC$PEN <- as.factor(data_PIC$PEN)

data_PIC$Social_Group <- paste(data_PIC$PEN, data_PIC$START_DAY, data_PIC$OFFTEST_DAY, sep = "_")

head(data_PIC$Social_Group)
[1] "B0113_27-Oct-22_2-Jan-23" "B0113_27-Oct-22_2-Jan-23"
[3] "B0113_27-Oct-22_2-Jan-23" "B0113_27-Oct-22_2-Jan-23"
[5] "B0113_27-Oct-22_2-Jan-23" "B0113_27-Oct-22_2-Jan-23"
data_PIC <- group_by(data_PIC, Social_Group)


data_PIC.arrange <- arrange(data_PIC, Social_Group, ENTRY, by_group = TRUE)%>%
  mutate(line= row_number())



head(data_PIC.arrange)
# A tibble: 6 x 22
# Groups:   Social_Group [1]
        ID  LINE     SIRE    DAM LITTER PEN    FARM ENTRY_TIME EXIT_TIME STAY_IN
     <int> <int>    <int>  <int>  <int> <fct> <int> <chr>      <chr>       <int>
1 97900600    65 88153118 9.22e7 7.90e7 B0111   774 3/15/2023~ 3/15/202~     156
2 97900500    65 92013924 9.15e7 7.86e7 B0111   774 3/15/2023~ 3/15/202~     416
3 97900600    65 88153118 9.22e7 7.90e7 B0111   774 3/15/2023~ 3/15/202~     469
4 97887849    65 88291968 9.34e7 7.90e7 B0111   774 3/15/2023~ 3/15/202~      48
5 97900500    65 92013924 9.15e7 7.86e7 B0111   774 3/15/2023~ 3/15/202~     166
6 97900600    65 88153118 9.22e7 7.90e7 B0111   774 3/15/2023~ 3/15/202~     113
# i 12 more variables: FEED_INTK <int>, ENTRY_WT <int>, EXIT_WT <int>,
#   FEEDER_NO <int>, START_DAY <chr>, OFFTEST_DAY <chr>, ENTRY_DATE <date>,
#   ENTRY <dttm>, EXIT_DATE <date>, EXIT <dttm>, Social_Group <chr>, line <int>
data_PIC.arrange %>%
  dplyr::select(ID, ENTRY, Social_Group)
# A tibble: 114,263 x 3
# Groups:   Social_Group [36]
         ID ENTRY               Social_Group             
      <int> <dttm>              <chr>                    
 1 97900600 2023-03-15 08:06:00 B0111_16-Mar-23_15-May-23
 2 97900500 2023-03-15 08:12:00 B0111_16-Mar-23_15-May-23
 3 97900600 2023-03-15 08:19:00 B0111_16-Mar-23_15-May-23
 4 97887849 2023-03-15 08:34:00 B0111_16-Mar-23_15-May-23
 5 97900500 2023-03-15 08:36:00 B0111_16-Mar-23_15-May-23
 6 97900600 2023-03-15 08:39:00 B0111_16-Mar-23_15-May-23
 7 97887847 2023-03-15 08:44:00 B0111_16-Mar-23_15-May-23
 8 97900600 2023-03-15 08:49:00 B0111_16-Mar-23_15-May-23
 9 97887847 2023-03-15 08:52:00 B0111_16-Mar-23_15-May-23
10 97900231 2023-03-15 09:04:00 B0111_16-Mar-23_15-May-23
# i 114,253 more rows
data_PIC <- data_PIC %>%
  arrange(Social_Group, ENTRY) %>%
  group_by(Social_Group) %>%
  mutate(Follower_ID = lead(ID),
         Follower_Time = lead(ENTRY),
         Follower_Social_Group = lead(Social_Group),
         line= row_number(),
         Hour_ENTRY = hour(ENTRY),
         time_between= as.numeric(Follower_Time - EXIT, unit="secs"))%>%
  filter(time_between < 36000,time_between>=0)

data_PIC%>% mutate(time_between= as.numeric(Follower_Time - ENTRY, unit="secs"),
         lapse_Time = seconds(Follower_Time - ENTRY))%>%
  dplyr::select(time_between, lapse_Time)
Adding missing grouping variables: `Social_Group`
# A tibble: 113,056 x 3
# Groups:   Social_Group [36]
   Social_Group              time_between lapse_Time
   <chr>                            <dbl> <Period>  
 1 B0111_16-Mar-23_15-May-23          360 360S      
 2 B0111_16-Mar-23_15-May-23          420 420S      
 3 B0111_16-Mar-23_15-May-23          900 900S      
 4 B0111_16-Mar-23_15-May-23          120 120S      
 5 B0111_16-Mar-23_15-May-23          180 180S      
 6 B0111_16-Mar-23_15-May-23          300 300S      
 7 B0111_16-Mar-23_15-May-23          300 300S      
 8 B0111_16-Mar-23_15-May-23          180 180S      
 9 B0111_16-Mar-23_15-May-23          720 720S      
10 B0111_16-Mar-23_15-May-23         1920 1920S     
# i 113,046 more rows
class(data_PIC)
[1] "grouped_df" "tbl_df"     "tbl"        "data.frame"
data_PIC_pvalues_morethan_120  <- as.numeric(data_PIC$time_between)


data_PIC_pvalues_morethan_120 <- filter (data_PIC, time_between >  120) %>%
  mutate(TIME_FEEDER = as.numeric(STAY_IN))


dim(data_PIC_pvalues_morethan_120)
[1] 27011    28
summary(data_PIC_pvalues_morethan_120$TIME_FEEDER)
   Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
      5     569    1234    1360    1958    7200 
head(data_PIC_pvalues_morethan_120)
# A tibble: 6 x 28
# Groups:   Social_Group [1]
        ID  LINE     SIRE    DAM LITTER PEN    FARM ENTRY_TIME EXIT_TIME STAY_IN
     <int> <int>    <int>  <int>  <int> <fct> <int> <chr>      <chr>       <int>
1 97900600    65 88153118 9.22e7 7.90e7 B0111   774 3/15/2023~ 3/15/202~     156
2 97900600    65 88153118 9.22e7 7.90e7 B0111   774 3/15/2023~ 3/15/202~     469
3 97900600    65 88153118 9.22e7 7.90e7 B0111   774 3/15/2023~ 3/15/202~     113
4 97887847    65 88291968 9.34e7 7.90e7 B0111   774 3/15/2023~ 3/15/202~       7
5 97887847    65 88291968 9.34e7 7.90e7 B0111   774 3/15/2023~ 3/15/202~      24
6 97900500    65 92013924 9.15e7 7.86e7 B0111   774 3/15/2023~ 3/15/202~      62
# i 18 more variables: FEED_INTK <int>, ENTRY_WT <int>, EXIT_WT <int>,
#   FEEDER_NO <int>, START_DAY <chr>, OFFTEST_DAY <chr>, ENTRY_DATE <date>,
#   ENTRY <dttm>, EXIT_DATE <date>, EXIT <dttm>, Social_Group <chr>,
#   Follower_ID <int>, Follower_Time <dttm>, Follower_Social_Group <chr>,
#   line <int>, Hour_ENTRY <int>, time_between <dbl>, TIME_FEEDER <dbl>
data_PIC_pvalues120 <- data_PIC_pvalues_morethan_120 %>%
  mutate(L_time = log(TIME_FEEDER))
umbral <- 120

data_PIC_pvalues_120 <- data_PIC_pvalues120 %>%
  mutate(time_between_group = case_when(
    time_between <= umbral ~ "immediate",
    time_between > umbral ~ "distant"
  ))%>% group_by(time_between_group) %>%
  group_modify( ~ broom.mixed::tidy(lme4::lmer(L_time ~ (1|ID) + (1|Follower_ID) + (1|Social_Group) + as.factor(Hour_ENTRY) , data = .x)))%>% filter(., effect == "ran_pars")

total_counts2 <- data_PIC_pvalues120 %>%
  mutate(time_between_group = case_when(
    time_between <= umbral ~ "immediate",
    time_between > umbral ~ "distant"
  )) %>% group_by(time_between_group) %>%
  summarise(total = n())  

print(total_counts2)
# A tibble: 1 x 2
  time_between_group total
  <chr>              <int>
1 distant            27011
reduced_model_Follower.lmer_120 <- lmer(
  L_time ~ as.factor(Hour_ENTRY) +  (1 | ID) +  (1 | Follower_ID) + (1 | Social_Group),
  data = data_PIC_pvalues120
)

summary(reduced_model_Follower.lmer_120)
Linear mixed model fit by REML. t-tests use Satterthwaite's method [
lmerModLmerTest]
Formula: L_time ~ as.factor(Hour_ENTRY) + (1 | ID) + (1 | Follower_ID) +  
    (1 | Social_Group)
   Data: data_PIC_pvalues120

REML criterion at convergence: 92896.9

Scaled residuals: 
    Min      1Q  Median      3Q     Max 
-4.2152 -0.2802  0.2435  0.6258  2.1399 

Random effects:
 Groups       Name        Variance Std.Dev.
 ID           (Intercept) 0.08931  0.2988  
 Follower_ID  (Intercept) 0.02746  0.1657  
 Social_Group (Intercept) 0.04775  0.2185  
 Residual                 1.75218  1.3237  
Number of obs: 27011, groups:  ID, 548; Follower_ID, 548; Social_Group, 36

Fixed effects:
                          Estimate Std. Error         df t value Pr(>|t|)    
(Intercept)              6.879e+00  5.209e-02  9.834e+01 132.070  < 2e-16 ***
as.factor(Hour_ENTRY)1   1.504e-02  4.755e-02  2.653e+04   0.316 0.751785    
as.factor(Hour_ENTRY)2   2.493e-02  4.853e-02  2.654e+04   0.514 0.607496    
as.factor(Hour_ENTRY)3   1.017e-02  4.847e-02  2.665e+04   0.210 0.833882    
as.factor(Hour_ENTRY)4   1.789e-02  5.024e-02  2.673e+04   0.356 0.721793    
as.factor(Hour_ENTRY)5  -1.840e-01  5.351e-02  2.680e+04  -3.438 0.000586 ***
as.factor(Hour_ENTRY)6  -7.086e-01  5.527e-02  2.686e+04 -12.820  < 2e-16 ***
as.factor(Hour_ENTRY)7  -5.334e-01  5.764e-02  2.687e+04  -9.254  < 2e-16 ***
as.factor(Hour_ENTRY)8  -4.477e-01  5.831e-02  2.684e+04  -7.677 1.68e-14 ***
as.factor(Hour_ENTRY)9  -4.968e-01  6.065e-02  2.681e+04  -8.192 2.68e-16 ***
as.factor(Hour_ENTRY)10 -4.953e-01  6.158e-02  2.683e+04  -8.043 9.15e-16 ***
as.factor(Hour_ENTRY)11 -6.121e-01  6.364e-02  2.684e+04  -9.618  < 2e-16 ***
as.factor(Hour_ENTRY)12 -7.309e-01  6.224e-02  2.684e+04 -11.743  < 2e-16 ***
as.factor(Hour_ENTRY)13 -6.270e-01  6.311e-02  2.685e+04  -9.935  < 2e-16 ***
as.factor(Hour_ENTRY)14 -8.198e-01  6.070e-02  2.681e+04 -13.506  < 2e-16 ***
as.factor(Hour_ENTRY)15 -6.365e-01  6.118e-02  2.688e+04 -10.403  < 2e-16 ***
as.factor(Hour_ENTRY)16 -3.652e-01  5.752e-02  2.685e+04  -6.349 2.20e-10 ***
as.factor(Hour_ENTRY)17 -1.123e-01  5.230e-02  2.687e+04  -2.148 0.031750 *  
as.factor(Hour_ENTRY)18 -6.815e-02  5.055e-02  2.678e+04  -1.348 0.177599    
as.factor(Hour_ENTRY)19  3.495e-02  4.924e-02  2.672e+04   0.710 0.477766    
as.factor(Hour_ENTRY)20  1.238e-02  4.812e-02  2.669e+04   0.257 0.796955    
as.factor(Hour_ENTRY)21 -8.144e-03  4.751e-02  2.663e+04  -0.171 0.863903    
as.factor(Hour_ENTRY)22  1.068e-02  4.760e-02  2.657e+04   0.224 0.822493    
as.factor(Hour_ENTRY)23 -2.429e-02  4.774e-02  2.659e+04  -0.509 0.610973    
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

Correlation matrix not shown by default, as p = 24 > 12.
Use print(x, correlation=TRUE)  or
    vcov(x)        if you need it
print(VarCorr(reduced_model_Follower.lmer_120), comp = "Variance")
 Groups       Name        Variance
 ID           (Intercept) 0.089308
 Follower_ID  (Intercept) 0.027461
 Social_Group (Intercept) 0.047750
 Residual                 1.752183
hist(data_PIC$time_between)

hist(data_PIC$time_between[data_PIC$time_between<7200])

hist(data_PIC$time_between[data_PIC$time_between<3600])

table(data_PIC$time_between<=3600)

 FALSE   TRUE 
  2431 110625 
table(data_PIC$time_between > 120)

FALSE  TRUE 
86045 27011 

180 threshold

rm(list = ls())

setwd("C:/Users/anune/OneDrive/Desktop/PIC_DataAnalysis_files")

data_PIC <- read.csv("PIC_65_FIRE.AN.1.csv")

head(data_PIC$ENTRY_TIME)
[1] "10/27/2022 12:51" "10/27/2022 12:00" "10/27/2022 13:03" "10/27/2022 7:27" 
[5] "10/27/2022 8:04"  "10/27/2022 8:41" 
data_PIC <- mutate(data_PIC, 

                   ENTRY_DATE = as_date(mdy_hm(ENTRY_TIME, tz = "UTC")),

                   ENTRY = mdy_hm(ENTRY_TIME, tz = "UTC"),
                   
                   
                   EXIT_DATE = as_date(mdy_hm(EXIT_TIME, tz = "UTC")),

                   EXIT = mdy_hm(EXIT_TIME, tz = "UTC")

                   )

summary(data_PIC$ENTRY_DATE)
        Min.      1st Qu.       Median         Mean      3rd Qu.         Max. 
"2022-04-06" "2023-01-02" "2023-02-19" "2023-02-18" "2023-04-08" "2023-06-19" 
data_PIC$PEN <- as.factor(data_PIC$PEN)

data_PIC$Social_Group <- paste(data_PIC$PEN, data_PIC$START_DAY, data_PIC$OFFTEST_DAY, sep = "_")

head(data_PIC$Social_Group)
[1] "B0113_27-Oct-22_2-Jan-23" "B0113_27-Oct-22_2-Jan-23"
[3] "B0113_27-Oct-22_2-Jan-23" "B0113_27-Oct-22_2-Jan-23"
[5] "B0113_27-Oct-22_2-Jan-23" "B0113_27-Oct-22_2-Jan-23"
data_PIC <- group_by(data_PIC, Social_Group)


data_PIC.arrange <- arrange(data_PIC, Social_Group, ENTRY, by_group = TRUE)%>%
  mutate(line= row_number())


data_PIC.arrange
# A tibble: 114,263 x 22
# Groups:   Social_Group [36]
         ID  LINE    SIRE    DAM LITTER PEN    FARM ENTRY_TIME EXIT_TIME STAY_IN
      <int> <int>   <int>  <int>  <int> <fct> <int> <chr>      <chr>       <int>
 1 97900600    65  8.82e7 9.22e7 7.90e7 B0111   774 3/15/2023~ 3/15/202~     156
 2 97900500    65  9.20e7 9.15e7 7.86e7 B0111   774 3/15/2023~ 3/15/202~     416
 3 97900600    65  8.82e7 9.22e7 7.90e7 B0111   774 3/15/2023~ 3/15/202~     469
 4 97887849    65  8.83e7 9.34e7 7.90e7 B0111   774 3/15/2023~ 3/15/202~      48
 5 97900500    65  9.20e7 9.15e7 7.86e7 B0111   774 3/15/2023~ 3/15/202~     166
 6 97900600    65  8.82e7 9.22e7 7.90e7 B0111   774 3/15/2023~ 3/15/202~     113
 7 97887847    65  8.83e7 9.34e7 7.90e7 B0111   774 3/15/2023~ 3/15/202~       7
 8 97900600    65  8.82e7 9.22e7 7.90e7 B0111   774 3/15/2023~ 3/15/202~     103
 9 97887847    65  8.83e7 9.34e7 7.90e7 B0111   774 3/15/2023~ 3/15/202~      24
10 97900231    65  8.83e7 9.37e7 7.90e7 B0111   774 3/15/2023~ 3/15/202~    1862
# i 114,253 more rows
# i 12 more variables: FEED_INTK <int>, ENTRY_WT <int>, EXIT_WT <int>,
#   FEEDER_NO <int>, START_DAY <chr>, OFFTEST_DAY <chr>, ENTRY_DATE <date>,
#   ENTRY <dttm>, EXIT_DATE <date>, EXIT <dttm>, Social_Group <chr>, line <int>
data_PIC.arrange %>%
  dplyr::select(ID, ENTRY, Social_Group)
# A tibble: 114,263 x 3
# Groups:   Social_Group [36]
         ID ENTRY               Social_Group             
      <int> <dttm>              <chr>                    
 1 97900600 2023-03-15 08:06:00 B0111_16-Mar-23_15-May-23
 2 97900500 2023-03-15 08:12:00 B0111_16-Mar-23_15-May-23
 3 97900600 2023-03-15 08:19:00 B0111_16-Mar-23_15-May-23
 4 97887849 2023-03-15 08:34:00 B0111_16-Mar-23_15-May-23
 5 97900500 2023-03-15 08:36:00 B0111_16-Mar-23_15-May-23
 6 97900600 2023-03-15 08:39:00 B0111_16-Mar-23_15-May-23
 7 97887847 2023-03-15 08:44:00 B0111_16-Mar-23_15-May-23
 8 97900600 2023-03-15 08:49:00 B0111_16-Mar-23_15-May-23
 9 97887847 2023-03-15 08:52:00 B0111_16-Mar-23_15-May-23
10 97900231 2023-03-15 09:04:00 B0111_16-Mar-23_15-May-23
# i 114,253 more rows
data_PIC <- data_PIC %>%
  arrange(Social_Group, ENTRY) %>%
  group_by(Social_Group) %>%
  mutate(Follower_ID = lead(ID),
         Follower_Time = lead(ENTRY),
         Follower_Social_Group = lead(Social_Group),
         line= row_number(),
         Hour_ENTRY = hour(ENTRY),
         time_between= as.numeric(Follower_Time - EXIT, unit="secs"))%>%
  filter(time_between < 36000,time_between>=0)

data_PIC%>% mutate(time_between= as.numeric(Follower_Time - ENTRY, unit="secs"),
         lapse_Time = seconds(Follower_Time - ENTRY))%>%
  dplyr::select(time_between, lapse_Time)
Adding missing grouping variables: `Social_Group`
# A tibble: 113,056 x 3
# Groups:   Social_Group [36]
   Social_Group              time_between lapse_Time
   <chr>                            <dbl> <Period>  
 1 B0111_16-Mar-23_15-May-23          360 360S      
 2 B0111_16-Mar-23_15-May-23          420 420S      
 3 B0111_16-Mar-23_15-May-23          900 900S      
 4 B0111_16-Mar-23_15-May-23          120 120S      
 5 B0111_16-Mar-23_15-May-23          180 180S      
 6 B0111_16-Mar-23_15-May-23          300 300S      
 7 B0111_16-Mar-23_15-May-23          300 300S      
 8 B0111_16-Mar-23_15-May-23          180 180S      
 9 B0111_16-Mar-23_15-May-23          720 720S      
10 B0111_16-Mar-23_15-May-23         1920 1920S     
# i 113,046 more rows
class(data_PIC)
[1] "grouped_df" "tbl_df"     "tbl"        "data.frame"
data_PIC_pvalues_morethan_180  <- as.numeric(data_PIC$time_between)


data_PIC_pvalues_morethan_180 <- filter (data_PIC, time_between >  180) %>%
  mutate(TIME_FEEDER = as.numeric(STAY_IN))


dim(data_PIC_pvalues_morethan_180)
[1] 24386    28
summary(data_PIC_pvalues_morethan_180$TIME_FEEDER)
   Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
      5     583    1241    1366    1961    7200 
head(data_PIC_pvalues_morethan_180)
# A tibble: 6 x 28
# Groups:   Social_Group [1]
        ID  LINE     SIRE    DAM LITTER PEN    FARM ENTRY_TIME EXIT_TIME STAY_IN
     <int> <int>    <int>  <int>  <int> <fct> <int> <chr>      <chr>       <int>
1 97900600    65 88153118 9.22e7 7.90e7 B0111   774 3/15/2023~ 3/15/202~     156
2 97900600    65 88153118 9.22e7 7.90e7 B0111   774 3/15/2023~ 3/15/202~     469
3 97887847    65 88291968 9.34e7 7.90e7 B0111   774 3/15/2023~ 3/15/202~       7
4 97887847    65 88291968 9.34e7 7.90e7 B0111   774 3/15/2023~ 3/15/202~      24
5 97887847    65 88291968 9.34e7 7.90e7 B0111   774 3/15/2023~ 3/15/202~      13
6 97900500    65 92013924 9.15e7 7.86e7 B0111   774 3/15/2023~ 3/15/202~       5
# i 18 more variables: FEED_INTK <int>, ENTRY_WT <int>, EXIT_WT <int>,
#   FEEDER_NO <int>, START_DAY <chr>, OFFTEST_DAY <chr>, ENTRY_DATE <date>,
#   ENTRY <dttm>, EXIT_DATE <date>, EXIT <dttm>, Social_Group <chr>,
#   Follower_ID <int>, Follower_Time <dttm>, Follower_Social_Group <chr>,
#   line <int>, Hour_ENTRY <int>, time_between <dbl>, TIME_FEEDER <dbl>
data_PIC_pvalues180 <- data_PIC_pvalues_morethan_180 %>%
  mutate(L_time = log(TIME_FEEDER))
umbral <- 180

data_PIC_pvalues_180 <- data_PIC_pvalues180 %>%
  mutate(time_between_group = case_when(
    time_between <= umbral ~ "immediate",
    time_between > umbral ~ "distant"
  ))%>% group_by(time_between_group) %>%
  group_modify( ~ broom.mixed::tidy(lme4::lmer(L_time ~ (1|ID) + (1|Follower_ID) + (1|Social_Group) + as.factor(Hour_ENTRY) , data = .x)))%>% filter(., effect == "ran_pars")

total_counts2 <- data_PIC_pvalues180 %>%
  mutate(time_between_group = case_when(
    time_between <= umbral ~ "immediate",
    time_between > umbral ~ "distant"
  )) %>% group_by(time_between_group) %>%
  summarise(total = n())  

print(total_counts2)
# A tibble: 1 x 2
  time_between_group total
  <chr>              <int>
1 distant            24386
reduced_model_Follower.lmer_180 <- lmer(
  L_time ~ as.factor(Hour_ENTRY) +  (1 | ID) +  (1 | Follower_ID) + (1 | Social_Group),
  data = data_PIC_pvalues180
)

summary(reduced_model_Follower.lmer_180)
Linear mixed model fit by REML. t-tests use Satterthwaite's method [
lmerModLmerTest]
Formula: L_time ~ as.factor(Hour_ENTRY) + (1 | ID) + (1 | Follower_ID) +  
    (1 | Social_Group)
   Data: data_PIC_pvalues180

REML criterion at convergence: 83483.7

Scaled residuals: 
    Min      1Q  Median      3Q     Max 
-4.2264 -0.2729  0.2424  0.6202  2.1778 

Random effects:
 Groups       Name        Variance Std.Dev.
 ID           (Intercept) 0.08970  0.2995  
 Follower_ID  (Intercept) 0.02506  0.1583  
 Social_Group (Intercept) 0.04500  0.2121  
 Residual                 1.72235  1.3124  
Number of obs: 24386, groups:  ID, 548; Follower_ID, 548; Social_Group, 36

Fixed effects:
                          Estimate Std. Error         df t value Pr(>|t|)    
(Intercept)              6.872e+00  5.209e-02  1.078e+02 131.912  < 2e-16 ***
as.factor(Hour_ENTRY)1   2.709e-02  4.907e-02  2.395e+04   0.552  0.58087    
as.factor(Hour_ENTRY)2   4.524e-02  5.011e-02  2.396e+04   0.903  0.36666    
as.factor(Hour_ENTRY)3   3.093e-02  5.019e-02  2.404e+04   0.616  0.53772    
as.factor(Hour_ENTRY)4   3.496e-02  5.196e-02  2.414e+04   0.673  0.50106    
as.factor(Hour_ENTRY)5  -1.750e-01  5.615e-02  2.420e+04  -3.117  0.00183 ** 
as.factor(Hour_ENTRY)6  -6.317e-01  5.882e-02  2.423e+04 -10.740  < 2e-16 ***
as.factor(Hour_ENTRY)7  -5.164e-01  6.109e-02  2.424e+04  -8.453  < 2e-16 ***
as.factor(Hour_ENTRY)8  -4.506e-01  6.166e-02  2.423e+04  -7.309 2.78e-13 ***
as.factor(Hour_ENTRY)9  -4.582e-01  6.340e-02  2.418e+04  -7.227 5.08e-13 ***
as.factor(Hour_ENTRY)10 -5.201e-01  6.516e-02  2.421e+04  -7.981 1.51e-15 ***
as.factor(Hour_ENTRY)11 -5.385e-01  6.748e-02  2.421e+04  -7.981 1.52e-15 ***
as.factor(Hour_ENTRY)12 -6.769e-01  6.543e-02  2.421e+04 -10.345  < 2e-16 ***
as.factor(Hour_ENTRY)13 -6.062e-01  6.625e-02  2.423e+04  -9.150  < 2e-16 ***
as.factor(Hour_ENTRY)14 -8.109e-01  6.353e-02  2.421e+04 -12.763  < 2e-16 ***
as.factor(Hour_ENTRY)15 -6.006e-01  6.404e-02  2.425e+04  -9.378  < 2e-16 ***
as.factor(Hour_ENTRY)16 -3.204e-01  6.017e-02  2.423e+04  -5.326 1.01e-07 ***
as.factor(Hour_ENTRY)17 -1.012e-01  5.441e-02  2.425e+04  -1.860  0.06295 .  
as.factor(Hour_ENTRY)18 -3.709e-02  5.253e-02  2.418e+04  -0.706  0.48018    
as.factor(Hour_ENTRY)19  5.714e-02  5.091e-02  2.413e+04   1.122  0.26167    
as.factor(Hour_ENTRY)20  1.647e-02  4.978e-02  2.410e+04   0.331  0.74078    
as.factor(Hour_ENTRY)21 -3.787e-03  4.908e-02  2.405e+04  -0.077  0.93849    
as.factor(Hour_ENTRY)22  1.068e-02  4.916e-02  2.399e+04   0.217  0.82800    
as.factor(Hour_ENTRY)23 -1.767e-02  4.933e-02  2.402e+04  -0.358  0.72016    
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

Correlation matrix not shown by default, as p = 24 > 12.
Use print(x, correlation=TRUE)  or
    vcov(x)        if you need it
print(VarCorr(reduced_model_Follower.lmer_180), comp = "Variance")
 Groups       Name        Variance
 ID           (Intercept) 0.089695
 Follower_ID  (Intercept) 0.025056
 Social_Group (Intercept) 0.045003
 Residual                 1.722346
hist(data_PIC$time_between)

hist(data_PIC$time_between[data_PIC$time_between<7200])

hist(data_PIC$time_between[data_PIC$time_between<3600])

table(data_PIC$time_between<=3600)

 FALSE   TRUE 
  2431 110625 
table(data_PIC$time_between > 180)

FALSE  TRUE 
88670 24386 

240 threshold

rm(list = ls())

setwd("C:/Users/anune/OneDrive/Desktop/PIC_DataAnalysis_files")

data_PIC <- read.csv("PIC_65_FIRE.AN.1.csv")

head(data_PIC$ENTRY_TIME)
[1] "10/27/2022 12:51" "10/27/2022 12:00" "10/27/2022 13:03" "10/27/2022 7:27" 
[5] "10/27/2022 8:04"  "10/27/2022 8:41" 
data_PIC <- mutate(data_PIC, 

                   ENTRY_DATE = as_date(mdy_hm(ENTRY_TIME, tz = "UTC")),

                   ENTRY = mdy_hm(ENTRY_TIME, tz = "UTC"),
                   
                   
                   EXIT_DATE = as_date(mdy_hm(EXIT_TIME, tz = "UTC")),

                   EXIT = mdy_hm(EXIT_TIME, tz = "UTC")

                   )

summary(data_PIC$ENTRY_DATE)
        Min.      1st Qu.       Median         Mean      3rd Qu.         Max. 
"2022-04-06" "2023-01-02" "2023-02-19" "2023-02-18" "2023-04-08" "2023-06-19" 
data_PIC$PEN <- as.factor(data_PIC$PEN)

data_PIC$Social_Group <- paste(data_PIC$PEN, data_PIC$START_DAY, data_PIC$OFFTEST_DAY, sep = "_")

head(data_PIC$Social_Group)
[1] "B0113_27-Oct-22_2-Jan-23" "B0113_27-Oct-22_2-Jan-23"
[3] "B0113_27-Oct-22_2-Jan-23" "B0113_27-Oct-22_2-Jan-23"
[5] "B0113_27-Oct-22_2-Jan-23" "B0113_27-Oct-22_2-Jan-23"
data_PIC <- group_by(data_PIC, Social_Group)


data_PIC.arrange <- arrange(data_PIC, Social_Group, ENTRY, by_group = TRUE)%>%
  mutate(line= row_number())


head(data_PIC.arrange)
# A tibble: 6 x 22
# Groups:   Social_Group [1]
        ID  LINE     SIRE    DAM LITTER PEN    FARM ENTRY_TIME EXIT_TIME STAY_IN
     <int> <int>    <int>  <int>  <int> <fct> <int> <chr>      <chr>       <int>
1 97900600    65 88153118 9.22e7 7.90e7 B0111   774 3/15/2023~ 3/15/202~     156
2 97900500    65 92013924 9.15e7 7.86e7 B0111   774 3/15/2023~ 3/15/202~     416
3 97900600    65 88153118 9.22e7 7.90e7 B0111   774 3/15/2023~ 3/15/202~     469
4 97887849    65 88291968 9.34e7 7.90e7 B0111   774 3/15/2023~ 3/15/202~      48
5 97900500    65 92013924 9.15e7 7.86e7 B0111   774 3/15/2023~ 3/15/202~     166
6 97900600    65 88153118 9.22e7 7.90e7 B0111   774 3/15/2023~ 3/15/202~     113
# i 12 more variables: FEED_INTK <int>, ENTRY_WT <int>, EXIT_WT <int>,
#   FEEDER_NO <int>, START_DAY <chr>, OFFTEST_DAY <chr>, ENTRY_DATE <date>,
#   ENTRY <dttm>, EXIT_DATE <date>, EXIT <dttm>, Social_Group <chr>, line <int>
data_PIC.arrange %>%
  dplyr::select(ID, ENTRY, Social_Group)
# A tibble: 114,263 x 3
# Groups:   Social_Group [36]
         ID ENTRY               Social_Group             
      <int> <dttm>              <chr>                    
 1 97900600 2023-03-15 08:06:00 B0111_16-Mar-23_15-May-23
 2 97900500 2023-03-15 08:12:00 B0111_16-Mar-23_15-May-23
 3 97900600 2023-03-15 08:19:00 B0111_16-Mar-23_15-May-23
 4 97887849 2023-03-15 08:34:00 B0111_16-Mar-23_15-May-23
 5 97900500 2023-03-15 08:36:00 B0111_16-Mar-23_15-May-23
 6 97900600 2023-03-15 08:39:00 B0111_16-Mar-23_15-May-23
 7 97887847 2023-03-15 08:44:00 B0111_16-Mar-23_15-May-23
 8 97900600 2023-03-15 08:49:00 B0111_16-Mar-23_15-May-23
 9 97887847 2023-03-15 08:52:00 B0111_16-Mar-23_15-May-23
10 97900231 2023-03-15 09:04:00 B0111_16-Mar-23_15-May-23
# i 114,253 more rows
data_PIC <- data_PIC %>%
  arrange(Social_Group, ENTRY) %>%
  group_by(Social_Group) %>%
  mutate(Follower_ID = lead(ID),
         Follower_Time = lead(ENTRY),
         Follower_Social_Group = lead(Social_Group),
         line= row_number(),
         Hour_ENTRY = hour(ENTRY),
         time_between= as.numeric(Follower_Time - EXIT, unit="secs"))%>%
  filter(time_between < 36000,time_between>=0)

data_PIC%>% mutate(time_between= as.numeric(Follower_Time - ENTRY, unit="secs"),
         lapse_Time = seconds(Follower_Time - ENTRY))%>%
  dplyr::select(time_between, lapse_Time)
Adding missing grouping variables: `Social_Group`
# A tibble: 113,056 x 3
# Groups:   Social_Group [36]
   Social_Group              time_between lapse_Time
   <chr>                            <dbl> <Period>  
 1 B0111_16-Mar-23_15-May-23          360 360S      
 2 B0111_16-Mar-23_15-May-23          420 420S      
 3 B0111_16-Mar-23_15-May-23          900 900S      
 4 B0111_16-Mar-23_15-May-23          120 120S      
 5 B0111_16-Mar-23_15-May-23          180 180S      
 6 B0111_16-Mar-23_15-May-23          300 300S      
 7 B0111_16-Mar-23_15-May-23          300 300S      
 8 B0111_16-Mar-23_15-May-23          180 180S      
 9 B0111_16-Mar-23_15-May-23          720 720S      
10 B0111_16-Mar-23_15-May-23         1920 1920S     
# i 113,046 more rows
class(data_PIC)
[1] "grouped_df" "tbl_df"     "tbl"        "data.frame"
data_PIC_pvalues_morethan_240  <- as.numeric(data_PIC$time_between)


data_PIC_pvalues_morethan_240 <- filter (data_PIC, time_between >  240) %>%
  mutate(TIME_FEEDER = as.numeric(STAY_IN))


dim(data_PIC_pvalues_morethan_240)
[1] 22683    28
summary(data_PIC_pvalues_morethan_240$TIME_FEEDER)
   Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
      5     597    1247    1373    1964    7200 
head(data_PIC_pvalues_morethan_240)
# A tibble: 6 x 28
# Groups:   Social_Group [1]
        ID  LINE     SIRE    DAM LITTER PEN    FARM ENTRY_TIME EXIT_TIME STAY_IN
     <int> <int>    <int>  <int>  <int> <fct> <int> <chr>      <chr>       <int>
1 97900600    65 88153118 9.22e7 7.90e7 B0111   774 3/15/2023~ 3/15/202~     469
2 97887847    65 88291968 9.34e7 7.90e7 B0111   774 3/15/2023~ 3/15/202~       7
3 97887847    65 88291968 9.34e7 7.90e7 B0111   774 3/15/2023~ 3/15/202~      24
4 97900489    65 88291968 9.18e7 7.90e7 B0111   774 3/15/2023~ 3/15/202~     605
5 97900600    65 88153118 9.22e7 7.90e7 B0111   774 3/15/2023~ 3/15/202~     313
6 97887845    65 88291968 9.34e7 7.90e7 B0111   774 3/15/2023~ 3/15/202~     199
# i 18 more variables: FEED_INTK <int>, ENTRY_WT <int>, EXIT_WT <int>,
#   FEEDER_NO <int>, START_DAY <chr>, OFFTEST_DAY <chr>, ENTRY_DATE <date>,
#   ENTRY <dttm>, EXIT_DATE <date>, EXIT <dttm>, Social_Group <chr>,
#   Follower_ID <int>, Follower_Time <dttm>, Follower_Social_Group <chr>,
#   line <int>, Hour_ENTRY <int>, time_between <dbl>, TIME_FEEDER <dbl>
data_PIC_pvalues240 <- data_PIC_pvalues_morethan_240 %>%
  mutate(L_time = log(TIME_FEEDER))
head(data_PIC_pvalues240)
# A tibble: 6 x 29
# Groups:   Social_Group [1]
        ID  LINE     SIRE    DAM LITTER PEN    FARM ENTRY_TIME EXIT_TIME STAY_IN
     <int> <int>    <int>  <int>  <int> <fct> <int> <chr>      <chr>       <int>
1 97900600    65 88153118 9.22e7 7.90e7 B0111   774 3/15/2023~ 3/15/202~     469
2 97887847    65 88291968 9.34e7 7.90e7 B0111   774 3/15/2023~ 3/15/202~       7
3 97887847    65 88291968 9.34e7 7.90e7 B0111   774 3/15/2023~ 3/15/202~      24
4 97900489    65 88291968 9.18e7 7.90e7 B0111   774 3/15/2023~ 3/15/202~     605
5 97900600    65 88153118 9.22e7 7.90e7 B0111   774 3/15/2023~ 3/15/202~     313
6 97887845    65 88291968 9.34e7 7.90e7 B0111   774 3/15/2023~ 3/15/202~     199
# i 19 more variables: FEED_INTK <int>, ENTRY_WT <int>, EXIT_WT <int>,
#   FEEDER_NO <int>, START_DAY <chr>, OFFTEST_DAY <chr>, ENTRY_DATE <date>,
#   ENTRY <dttm>, EXIT_DATE <date>, EXIT <dttm>, Social_Group <chr>,
#   Follower_ID <int>, Follower_Time <dttm>, Follower_Social_Group <chr>,
#   line <int>, Hour_ENTRY <int>, time_between <dbl>, TIME_FEEDER <dbl>,
#   L_time <dbl>
umbral <- 240

total_counts3 <- data_PIC_pvalues240 %>%
  mutate(time_between_group = case_when(
    time_between <= umbral ~ "immediate",
    time_between > umbral ~ "distant"
  )) %>% group_by(time_between_group) %>%
  summarise(total = n())  

print(total_counts3)
# A tibble: 1 x 2
  time_between_group total
  <chr>              <int>
1 distant            22683
reduced_model_Follower.lmer_240 <- lmer(
  L_time ~ as.factor(Hour_ENTRY) +  (1 | ID) +  (1 | Follower_ID) + (1 | Social_Group),
  data = data_PIC_pvalues240
)

summary(reduced_model_Follower.lmer_240)
Linear mixed model fit by REML. t-tests use Satterthwaite's method [
lmerModLmerTest]
Formula: L_time ~ as.factor(Hour_ENTRY) + (1 | ID) + (1 | Follower_ID) +  
    (1 | Social_Group)
   Data: data_PIC_pvalues240

REML criterion at convergence: 77149.3

Scaled residuals: 
    Min      1Q  Median      3Q     Max 
-4.2695 -0.2705  0.2424  0.6177  2.1801 

Random effects:
 Groups       Name        Variance Std.Dev.
 ID           (Intercept) 0.09029  0.3005  
 Follower_ID  (Intercept) 0.02547  0.1596  
 Social_Group (Intercept) 0.04051  0.2013  
 Residual                 1.68124  1.2966  
Number of obs: 22683, groups:  ID, 548; Follower_ID, 548; Social_Group, 36

Fixed effects:
                          Estimate Std. Error         df t value Pr(>|t|)    
(Intercept)              6.876e+00  5.146e-02  1.204e+02 133.611  < 2e-16 ***
as.factor(Hour_ENTRY)1   2.657e-02  5.016e-02  2.227e+04   0.530  0.59634    
as.factor(Hour_ENTRY)2   3.923e-02  5.101e-02  2.228e+04   0.769  0.44184    
as.factor(Hour_ENTRY)3   1.594e-02  5.130e-02  2.236e+04   0.311  0.75600    
as.factor(Hour_ENTRY)4   3.681e-02  5.308e-02  2.244e+04   0.694  0.48797    
as.factor(Hour_ENTRY)5  -1.682e-01  5.795e-02  2.250e+04  -2.902  0.00371 ** 
as.factor(Hour_ENTRY)6  -5.676e-01  6.109e-02  2.254e+04  -9.291  < 2e-16 ***
as.factor(Hour_ENTRY)7  -4.806e-01  6.277e-02  2.255e+04  -7.657 1.97e-14 ***
as.factor(Hour_ENTRY)8  -4.264e-01  6.369e-02  2.253e+04  -6.696 2.19e-11 ***
as.factor(Hour_ENTRY)9  -4.052e-01  6.583e-02  2.249e+04  -6.156 7.60e-10 ***
as.factor(Hour_ENTRY)10 -4.819e-01  6.714e-02  2.250e+04  -7.178 7.30e-13 ***
as.factor(Hour_ENTRY)11 -5.066e-01  6.986e-02  2.252e+04  -7.251 4.28e-13 ***
as.factor(Hour_ENTRY)12 -6.388e-01  6.752e-02  2.252e+04  -9.460  < 2e-16 ***
as.factor(Hour_ENTRY)13 -5.978e-01  6.774e-02  2.254e+04  -8.825  < 2e-16 ***
as.factor(Hour_ENTRY)14 -7.619e-01  6.509e-02  2.251e+04 -11.705  < 2e-16 ***
as.factor(Hour_ENTRY)15 -6.019e-01  6.583e-02  2.256e+04  -9.142  < 2e-16 ***
as.factor(Hour_ENTRY)16 -3.193e-01  6.220e-02  2.252e+04  -5.134 2.86e-07 ***
as.factor(Hour_ENTRY)17 -1.017e-01  5.586e-02  2.255e+04  -1.821  0.06860 .  
as.factor(Hour_ENTRY)18 -1.986e-02  5.389e-02  2.247e+04  -0.368  0.71252    
as.factor(Hour_ENTRY)19  4.592e-02  5.207e-02  2.242e+04   0.882  0.37788    
as.factor(Hour_ENTRY)20  1.557e-02  5.093e-02  2.240e+04   0.306  0.75984    
as.factor(Hour_ENTRY)21 -1.173e-02  4.996e-02  2.235e+04  -0.235  0.81431    
as.factor(Hour_ENTRY)22  1.611e-02  4.997e-02  2.230e+04   0.322  0.74720    
as.factor(Hour_ENTRY)23 -1.454e-02  5.040e-02  2.233e+04  -0.289  0.77292    
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

Correlation matrix not shown by default, as p = 24 > 12.
Use print(x, correlation=TRUE)  or
    vcov(x)        if you need it
print(VarCorr(reduced_model_Follower.lmer_240), comp = "Variance")
 Groups       Name        Variance
 ID           (Intercept) 0.090286
 Follower_ID  (Intercept) 0.025466
 Social_Group (Intercept) 0.040512
 Residual                 1.681239
hist(data_PIC$time_between)

hist(data_PIC$time_between[data_PIC$time_between<7200])

hist(data_PIC$time_between[data_PIC$time_between<3600])

table(data_PIC$time_between<=3600)

 FALSE   TRUE 
  2431 110625 
table(data_PIC$time_between > 240)

FALSE  TRUE 
90373 22683 

300 threshold

rm(list = ls())

setwd("C:/Users/anune/OneDrive/Desktop/PIC_DataAnalysis_files")

data_PIC <- read.csv("PIC_65_FIRE.AN.1.csv")

head(data_PIC$ENTRY_TIME)
[1] "10/27/2022 12:51" "10/27/2022 12:00" "10/27/2022 13:03" "10/27/2022 7:27" 
[5] "10/27/2022 8:04"  "10/27/2022 8:41" 
data_PIC <- mutate(data_PIC, 

                   ENTRY_DATE = as_date(mdy_hm(ENTRY_TIME, tz = "UTC")),

                   ENTRY = mdy_hm(ENTRY_TIME, tz = "UTC"),
                   
                   
                   EXIT_DATE = as_date(mdy_hm(EXIT_TIME, tz = "UTC")),

                   EXIT = mdy_hm(EXIT_TIME, tz = "UTC")

                   )

summary(data_PIC$ENTRY_DATE)
        Min.      1st Qu.       Median         Mean      3rd Qu.         Max. 
"2022-04-06" "2023-01-02" "2023-02-19" "2023-02-18" "2023-04-08" "2023-06-19" 
data_PIC$PEN <- as.factor(data_PIC$PEN)

data_PIC$Social_Group <- paste(data_PIC$PEN, data_PIC$START_DAY, data_PIC$OFFTEST_DAY, sep = "_")

head(data_PIC$Social_Group)
[1] "B0113_27-Oct-22_2-Jan-23" "B0113_27-Oct-22_2-Jan-23"
[3] "B0113_27-Oct-22_2-Jan-23" "B0113_27-Oct-22_2-Jan-23"
[5] "B0113_27-Oct-22_2-Jan-23" "B0113_27-Oct-22_2-Jan-23"
data_PIC <- group_by(data_PIC, Social_Group)


data_PIC.arrange <- arrange(data_PIC, Social_Group, ENTRY, by_group = TRUE)%>%
  mutate(line= row_number())


head(data_PIC.arrange)
# A tibble: 6 x 22
# Groups:   Social_Group [1]
        ID  LINE     SIRE    DAM LITTER PEN    FARM ENTRY_TIME EXIT_TIME STAY_IN
     <int> <int>    <int>  <int>  <int> <fct> <int> <chr>      <chr>       <int>
1 97900600    65 88153118 9.22e7 7.90e7 B0111   774 3/15/2023~ 3/15/202~     156
2 97900500    65 92013924 9.15e7 7.86e7 B0111   774 3/15/2023~ 3/15/202~     416
3 97900600    65 88153118 9.22e7 7.90e7 B0111   774 3/15/2023~ 3/15/202~     469
4 97887849    65 88291968 9.34e7 7.90e7 B0111   774 3/15/2023~ 3/15/202~      48
5 97900500    65 92013924 9.15e7 7.86e7 B0111   774 3/15/2023~ 3/15/202~     166
6 97900600    65 88153118 9.22e7 7.90e7 B0111   774 3/15/2023~ 3/15/202~     113
# i 12 more variables: FEED_INTK <int>, ENTRY_WT <int>, EXIT_WT <int>,
#   FEEDER_NO <int>, START_DAY <chr>, OFFTEST_DAY <chr>, ENTRY_DATE <date>,
#   ENTRY <dttm>, EXIT_DATE <date>, EXIT <dttm>, Social_Group <chr>, line <int>
data_PIC.arrange %>%
  dplyr::select(ID, ENTRY, Social_Group)
# A tibble: 114,263 x 3
# Groups:   Social_Group [36]
         ID ENTRY               Social_Group             
      <int> <dttm>              <chr>                    
 1 97900600 2023-03-15 08:06:00 B0111_16-Mar-23_15-May-23
 2 97900500 2023-03-15 08:12:00 B0111_16-Mar-23_15-May-23
 3 97900600 2023-03-15 08:19:00 B0111_16-Mar-23_15-May-23
 4 97887849 2023-03-15 08:34:00 B0111_16-Mar-23_15-May-23
 5 97900500 2023-03-15 08:36:00 B0111_16-Mar-23_15-May-23
 6 97900600 2023-03-15 08:39:00 B0111_16-Mar-23_15-May-23
 7 97887847 2023-03-15 08:44:00 B0111_16-Mar-23_15-May-23
 8 97900600 2023-03-15 08:49:00 B0111_16-Mar-23_15-May-23
 9 97887847 2023-03-15 08:52:00 B0111_16-Mar-23_15-May-23
10 97900231 2023-03-15 09:04:00 B0111_16-Mar-23_15-May-23
# i 114,253 more rows
data_PIC <- data_PIC %>%
  arrange(Social_Group, ENTRY) %>%
  group_by(Social_Group) %>%
  mutate(Follower_ID = lead(ID),
         Follower_Time = lead(ENTRY),
         Follower_Social_Group = lead(Social_Group),
         line= row_number(),
         Hour_ENTRY = hour(ENTRY),
         time_between= as.numeric(Follower_Time - EXIT, unit="secs"))%>%
  filter(time_between < 36000,time_between>=0)

data_PIC%>% mutate(time_between= as.numeric(Follower_Time - ENTRY, unit="secs"),
         lapse_Time = seconds(Follower_Time - ENTRY))%>%
  dplyr::select(time_between, lapse_Time)
Adding missing grouping variables: `Social_Group`
# A tibble: 113,056 x 3
# Groups:   Social_Group [36]
   Social_Group              time_between lapse_Time
   <chr>                            <dbl> <Period>  
 1 B0111_16-Mar-23_15-May-23          360 360S      
 2 B0111_16-Mar-23_15-May-23          420 420S      
 3 B0111_16-Mar-23_15-May-23          900 900S      
 4 B0111_16-Mar-23_15-May-23          120 120S      
 5 B0111_16-Mar-23_15-May-23          180 180S      
 6 B0111_16-Mar-23_15-May-23          300 300S      
 7 B0111_16-Mar-23_15-May-23          300 300S      
 8 B0111_16-Mar-23_15-May-23          180 180S      
 9 B0111_16-Mar-23_15-May-23          720 720S      
10 B0111_16-Mar-23_15-May-23         1920 1920S     
# i 113,046 more rows
class(data_PIC)
[1] "grouped_df" "tbl_df"     "tbl"        "data.frame"
data_PIC_pvalues_morethan_300  <- as.numeric(data_PIC$time_between)


data_PIC_pvalues_morethan_300 <- filter (data_PIC, time_between >  300) %>%
  mutate(TIME_FEEDER = as.numeric(STAY_IN))


dim(data_PIC_pvalues_morethan_300)
[1] 21180    28
summary(data_PIC_pvalues_morethan_300$TIME_FEEDER)
   Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
      5     606    1249    1374    1959    7200 
head(data_PIC_pvalues_morethan_300)
# A tibble: 6 x 28
# Groups:   Social_Group [1]
        ID  LINE     SIRE    DAM LITTER PEN    FARM ENTRY_TIME EXIT_TIME STAY_IN
     <int> <int>    <int>  <int>  <int> <fct> <int> <chr>      <chr>       <int>
1 97900600    65 88153118 9.22e7 7.90e7 B0111   774 3/15/2023~ 3/15/202~     469
2 97887847    65 88291968 9.34e7 7.90e7 B0111   774 3/15/2023~ 3/15/202~      24
3 97900600    65 88153118 9.22e7 7.90e7 B0111   774 3/15/2023~ 3/15/202~     313
4 97887845    65 88291968 9.34e7 7.90e7 B0111   774 3/15/2023~ 3/15/202~     199
5 97900231    65 88291968 9.37e7 7.90e7 B0111   774 3/15/2023~ 3/15/202~     870
6 97887841    65 88291968 9.34e7 7.90e7 B0111   774 3/15/2023~ 3/15/202~    1947
# i 18 more variables: FEED_INTK <int>, ENTRY_WT <int>, EXIT_WT <int>,
#   FEEDER_NO <int>, START_DAY <chr>, OFFTEST_DAY <chr>, ENTRY_DATE <date>,
#   ENTRY <dttm>, EXIT_DATE <date>, EXIT <dttm>, Social_Group <chr>,
#   Follower_ID <int>, Follower_Time <dttm>, Follower_Social_Group <chr>,
#   line <int>, Hour_ENTRY <int>, time_between <dbl>, TIME_FEEDER <dbl>
data_PIC_pvalues300 <- data_PIC_pvalues_morethan_300 %>%
  mutate(L_time = log(TIME_FEEDER))


umbral <- 300

head(data_PIC_pvalues300)
# A tibble: 6 x 29
# Groups:   Social_Group [1]
        ID  LINE     SIRE    DAM LITTER PEN    FARM ENTRY_TIME EXIT_TIME STAY_IN
     <int> <int>    <int>  <int>  <int> <fct> <int> <chr>      <chr>       <int>
1 97900600    65 88153118 9.22e7 7.90e7 B0111   774 3/15/2023~ 3/15/202~     469
2 97887847    65 88291968 9.34e7 7.90e7 B0111   774 3/15/2023~ 3/15/202~      24
3 97900600    65 88153118 9.22e7 7.90e7 B0111   774 3/15/2023~ 3/15/202~     313
4 97887845    65 88291968 9.34e7 7.90e7 B0111   774 3/15/2023~ 3/15/202~     199
5 97900231    65 88291968 9.37e7 7.90e7 B0111   774 3/15/2023~ 3/15/202~     870
6 97887841    65 88291968 9.34e7 7.90e7 B0111   774 3/15/2023~ 3/15/202~    1947
# i 19 more variables: FEED_INTK <int>, ENTRY_WT <int>, EXIT_WT <int>,
#   FEEDER_NO <int>, START_DAY <chr>, OFFTEST_DAY <chr>, ENTRY_DATE <date>,
#   ENTRY <dttm>, EXIT_DATE <date>, EXIT <dttm>, Social_Group <chr>,
#   Follower_ID <int>, Follower_Time <dttm>, Follower_Social_Group <chr>,
#   line <int>, Hour_ENTRY <int>, time_between <dbl>, TIME_FEEDER <dbl>,
#   L_time <dbl>
total_counts2 <- data_PIC_pvalues300 %>%
  mutate(time_between_group = case_when(
    time_between <= umbral ~ "immediate",
    time_between> umbral ~ "distant"
  ))%>% group_by(time_between_group) %>%
  summarise(total = n())  

print(total_counts2)
# A tibble: 1 x 2
  time_between_group total
  <chr>              <int>
1 distant            21180
reduced_model_Follower.lmer_300 <- lmer(
  L_time ~ as.factor(Hour_ENTRY) +  (1 | ID) +  (1 | Follower_ID) + (1 | Social_Group),
  data = data_PIC_pvalues300
)

summary(reduced_model_Follower.lmer_300)
Linear mixed model fit by REML. t-tests use Satterthwaite's method [
lmerModLmerTest]
Formula: L_time ~ as.factor(Hour_ENTRY) + (1 | ID) + (1 | Follower_ID) +  
    (1 | Social_Group)
   Data: data_PIC_pvalues300

REML criterion at convergence: 71777.4

Scaled residuals: 
    Min      1Q  Median      3Q     Max 
-4.3108 -0.2682  0.2430  0.6173  2.1375 

Random effects:
 Groups       Name        Variance Std.Dev.
 ID           (Intercept) 0.09051  0.3009  
 Follower_ID  (Intercept) 0.02247  0.1499  
 Social_Group (Intercept) 0.03608  0.1899  
 Residual                 1.66006  1.2884  
Number of obs: 21180, groups:  ID, 548; Follower_ID, 548; Social_Group, 36

Fixed effects:
                          Estimate Std. Error         df t value Pr(>|t|)    
(Intercept)              6.877e+00  5.085e-02  1.375e+02 135.249  < 2e-16 ***
as.factor(Hour_ENTRY)1   4.119e-02  5.140e-02  2.078e+04   0.801  0.42289    
as.factor(Hour_ENTRY)2   2.905e-02  5.233e-02  2.081e+04   0.555  0.57888    
as.factor(Hour_ENTRY)3   1.294e-02  5.242e-02  2.087e+04   0.247  0.80498    
as.factor(Hour_ENTRY)4   4.144e-02  5.462e-02  2.095e+04   0.759  0.44801    
as.factor(Hour_ENTRY)5  -1.720e-01  5.996e-02  2.100e+04  -2.868  0.00413 ** 
as.factor(Hour_ENTRY)6  -5.341e-01  6.325e-02  2.102e+04  -8.444  < 2e-16 ***
as.factor(Hour_ENTRY)7  -4.489e-01  6.512e-02  2.103e+04  -6.893 5.61e-12 ***
as.factor(Hour_ENTRY)8  -3.927e-01  6.569e-02  2.101e+04  -5.979 2.29e-09 ***
as.factor(Hour_ENTRY)9  -4.118e-01  6.780e-02  2.098e+04  -6.073 1.28e-09 ***
as.factor(Hour_ENTRY)10 -4.950e-01  6.960e-02  2.099e+04  -7.112 1.18e-12 ***
as.factor(Hour_ENTRY)11 -5.029e-01  7.180e-02  2.100e+04  -7.004 2.57e-12 ***
as.factor(Hour_ENTRY)12 -6.499e-01  6.958e-02  2.100e+04  -9.340  < 2e-16 ***
as.factor(Hour_ENTRY)13 -5.768e-01  7.004e-02  2.103e+04  -8.235  < 2e-16 ***
as.factor(Hour_ENTRY)14 -7.664e-01  6.648e-02  2.096e+04 -11.528  < 2e-16 ***
as.factor(Hour_ENTRY)15 -5.667e-01  6.749e-02  2.104e+04  -8.396  < 2e-16 ***
as.factor(Hour_ENTRY)16 -2.964e-01  6.377e-02  2.100e+04  -4.648 3.37e-06 ***
as.factor(Hour_ENTRY)17 -7.504e-02  5.747e-02  2.104e+04  -1.306  0.19167    
as.factor(Hour_ENTRY)18 -8.888e-03  5.535e-02  2.097e+04  -0.161  0.87242    
as.factor(Hour_ENTRY)19  6.364e-02  5.352e-02  2.093e+04   1.189  0.23442    
as.factor(Hour_ENTRY)20  1.748e-02  5.222e-02  2.091e+04   0.335  0.73783    
as.factor(Hour_ENTRY)21 -1.623e-02  5.127e-02  2.086e+04  -0.317  0.75151    
as.factor(Hour_ENTRY)22  2.918e-02  5.123e-02  2.081e+04   0.569  0.56903    
as.factor(Hour_ENTRY)23 -1.628e-02  5.142e-02  2.084e+04  -0.317  0.75162    
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

Correlation matrix not shown by default, as p = 24 > 12.
Use print(x, correlation=TRUE)  or
    vcov(x)        if you need it
print(VarCorr(reduced_model_Follower.lmer_300), comp = "Variance")
 Groups       Name        Variance
 ID           (Intercept) 0.090514
 Follower_ID  (Intercept) 0.022473
 Social_Group (Intercept) 0.036077
 Residual                 1.660063
hist(data_PIC$time_between)

hist(data_PIC$time_between[data_PIC$time_between<7200])

hist(data_PIC$time_between[data_PIC$time_between<3600])

table(data_PIC$time_between<=3600)

 FALSE   TRUE 
  2431 110625 
table(data_PIC$time_between > 300)

FALSE  TRUE 
91876 21180