-
Notifications
You must be signed in to change notification settings - Fork 0
/
13.estimate_ranks_daily_period.R
93 lines (75 loc) · 3.65 KB
/
13.estimate_ranks_daily_period.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
################################################################################
# Get ranks from empirical dataset - females #
# #
# #
# By Eli Strauss #
# #
# November 2018 #
################################################################################
rm(list = ls())
options(stringsAsFactors = FALSE)
library(DynaRankR)
library(dplyr)
library(EloRating)
setwd('~/Documents/Research/Longitudinal_Hierarchies/FinalSubmission/')
load('12.hyena_data_daily_period.RData')
set.seed(1989)
female_ranks <- informed_matreorder(contestants = female.contestants,
convention = 'mri',
n = 100,
shuffles = 10,
require.corroboration = TRUE,
initial.ranks = female.initial.ranks,
interactions = female.interactions)
plot_ranks(female_ranks)
female_ranks$method = 'informed_matreorder'
ds_ranks <- informed_ds(female.contestants, convention = 'none',
initial.ranks = female.initial.ranks,
interactions = female.interactions)
ds_ranks$method <- 'ds'
informed_ds_ranks <- informed_ds(female.contestants, convention = 'mri',
initial.ranks = female.initial.ranks,
interactions = female.interactions)
informed_ds_ranks$method <- 'informed_ds'
elo_ranks <- informed_elo(female.contestants, convention = 'none',
K = 200, lambda = 100,
interactions = female.interactions)
elo_ranks$method <- 'elo'
informed_elo_ranks <- informed_elo(contestants = female.contestants, convention = 'mri',
K = 200, lambda = 100,
initial.ranks = female.initial.ranks,
interactions = female.interactions)
informed_elo_ranks$method <- 'informed_elo'
# ##ISI From EloRating
# isi_ranks <- female.contestants
# isi_ranks$rank <- NA
# isi_ranks$id <- NA
# isi_ranks <-dplyr::select(isi_ranks, period, id, rank)
#
# for(current.period in unique(female.contestants$period)){
# ids <- filter(female.contestants, period == current.period)$id
# intx.mat <- filter(female.interactions, period == current.period,
# winner %in% ids, loser %in% ids) %>%
# dplyr::select(winner, loser) %>% edgelist_to_matrix(identities = ids)
# isi.mat <- EloRating::ISI(intx.mat, 10000, printmessages = FALSE)
# isi_ranks[isi_ranks$period == current.period,]$id <- rownames(isi.mat[[1]])
# isi_ranks[isi_ranks$period == current.period,]$rank <- 1:length(ids)
# }
#
# isi_ranks$old.order <- NA
#
# isi_ranks <- isi_ranks %>%
# group_by(period) %>%
# mutate(stan.rank = -2*(rank-1)/(max(rank)-1) + 1) %>%
# dplyr::select(period, id, rank, stan.rank, old.order) %>%
# as.data.frame()
#
# isi_ranks$method <- 'isi'
female.ranks <- rbind(female_ranks,
ds_ranks[,names(female_ranks)],
informed_ds_ranks[,names(female_ranks)],
elo_ranks[,names(female_ranks)],
informed_elo_ranks[,names(female_ranks)]#,
#isi_ranks[,names(female_ranks)]
)
save(female.ranks, file = '14.female_ranks_daily.RData')