We tested five models with varying degrees of complexity to estimate the probabilities of each animal to win a tube-test encounter against any of their cage mates.
cages=c("C03","C04","C05","C06","C10","C11","C12","C13")
model_performance1 <- data.frame()
model_performance2 <- data.frame()
for(cage in cages){
#Filter table by cage
cage_data <- tube_test_data %>% filter(cage_id == cage)
#Model with temporal autocorrelation (NULL if the model does not converge)
M1 <- tryCatch({glmmTMB(win_loss_binomial~1+(1|mouse)+(1|treatment:mouse), data = cage_data, family = binomial)}, warning = function(w){NULL})
M2 <- tryCatch({glmmTMB(win_loss_binomial~1+ar1(time+0|mouse)+(1|treatment:mouse), data = cage_data, family = binomial)}, warning = function(w){NULL})
M3 <- tryCatch({glmmTMB(win_loss_binomial~1+ar1(time+0|mouse), data = cage_data, family = binomial)}, warning = function(w){NULL})
M4 <- tryCatch({glmmTMB(win_loss_binomial~1+(1|mouse), data = cage_data, family = binomial)}, warning = function(w){NULL})
M5 <- tryCatch({glmmTMB(win_loss_binomial~1, data = cage_data, family = binomial)}, warning = function(w){NULL})
aic <- c(M1=if(is.null(M1)){NA}else{AIC(M1)},
M2=if(is.null(M2)){NA}else{AIC(M2)},
M3=if(is.null(M3)){NA}else{AIC(M3)},
M4=if(is.null(M4)){NA}else{AIC(M4)},
M5=if(is.null(M5)){NA}else{AIC(M5)}) %>% sort()
rank <- names(aic)
# Append predictions to table
model_performance1 <- bind_rows(model_performance1,rank %>% as.data.frame() %>% t() %>% as.data.frame())
model_performance2 <- bind_rows(model_performance2,aic %>% as.data.frame() %>% t() %>% as.data.frame())
}
Model rank
colnames(model_performance1) <- c("1","2","3","4","5")
rownames(model_performance1) <- cages
model_performance1 %>%
rownames_to_column(var="Cage") %>%
tt() |>
style_tt(j = 1, color = "#6e0f0f", background = "#e39d9d") |>
style_tt(i = 0, color = "white", background = "#a52929")
tinytable_uuhxkutegmxo4j2s6z0m
Cage |
1 |
2 |
3 |
4 |
5 |
C03 |
M3 |
M1 |
M2 |
M4 |
M5 |
C04 |
M3 |
M2 |
M1 |
M4 |
M5 |
C05 |
M3 |
M2 |
M4 |
M1 |
M5 |
C06 |
M4 |
M3 |
M1 |
M2 |
M5 |
C10 |
M4 |
M3 |
M1 |
M2 |
M5 |
C11 |
M3 |
M2 |
M1 |
M4 |
M5 |
C12 |
M4 |
M1 |
M5 |
NA |
NA |
C13 |
M3 |
M4 |
M2 |
M1 |
M5 |