elo_model3 | R Documentation |
This function calulates the log likelihood of the winning probability of winner, or generates an elo sequence.
Function taken from Foerster et al. 2016
elo_model3(par, IA_data, all_ids, return_likelihood = T)
par |
numeric vector of values. par[1] will be used as initial value of k. rest of vector will be used as starting elo values |
IA_data |
A data frame with sequencce of Winner/Loser interactions. |
all_ids |
A character vector os unique individual IDs |
return_likelihood |
If TRUE (default), returns a list with parameters estimated by maximum likelihood. If FALSE, returns a IA_data with updated elo scores given the k value and initial scores set with 'par'. |
A likelihood value or elo sequence
Foerster, S., Franz, M., Murray, C. M., Gilby, I. C., Feldblum, J. T., Walker, K. K., & Pusey, A. E. (2016). Chimpanzee females queue but males compete for social status. Scientific Reports, 6, 35404. https://doi.org/10.1038/srep35404
# Calculate maximum likelihood res_m_model3 <- optim(par=c(5, rep(0, length(ama_c))), elo.model3, all_ids = ama_c, IA_data = dom.ama2, return_likelihood=T, method='BFGS', control = list(maxit = 10000, reltol=1e-10)) # Get K k <- exp(res_m_model3$par[1]) # Get AIC AIC <- res_m_model3$value * 2 + 2 * (length(ama_c) + 1) # Get elo sequence given ML k and starting values ama_seq3.2 <- elo.model3(par = res_m_model3$par, IA_data = dom.ama2, all_ids = ama_c, return_likelihood = FALSE)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.