-
Notifications
You must be signed in to change notification settings - Fork 1
/
analyse_MMLE_Erlang.r
67 lines (49 loc) · 2.13 KB
/
analyse_MMLE_Erlang.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
library(tidyverse)
is_in <- function(x, l, u){
below <- x >= l
above <- x <= u
result <- as.logical(below * above)
return(result)
}
MM <- 1500
BB <- .1
J <- 50
simus <- read_csv(paste0("Mu=", MM, "_Beta=", BB, "_K=", J, ".csv"))
# load(
# paste0("Mu=", MM, "_Beta=", BB, "_K=", J, ".RData")
# )
# setdiff(1:500, unique(simus$replicate))
simus <- simus %>% mutate(squared_deviation = (point-true)^2,
.before = "time")
simus <- simus %>% mutate(covers = is_in(x = true,
l = lwr, u = upr),
.after = "squared_deviation")
simus <- simus %>% mutate(covers_exact = is_in(x = true,
l = lwr_exact, u = upr_exact),
.after = "covers")
simus <- simus %>% mutate(CI_width = upr-lwr,
.after = "covers_exact")
simus <- simus %>% mutate(CI_width_exact = upr_exact-lwr_exact,
.after = "CI_width")
##############
aggregate(time~implementation+method, simus, mean)
mus <- subset(simus, parameter == "mu")
betas <- subset(simus, parameter == "beta")
# in what follows, 'parameter' is supefluous, but kept for clarity
## Mu
aggregate(sqrt(squared_deviation)/true~implementation+method+parameter, mus, mean)
aggregate(squared_deviation~implementation+method+parameter, mus,
function(x) sqrt(mean(x)))
aggregate(covers~implementation+method+parameter, mus, mean)
aggregate(covers_exact~implementation+method+parameter, mus, mean)
aggregate(CI_width~implementation+method+parameter, mus, mean)
aggregate(CI_width_exact~implementation+method+parameter, mus, mean)
## Beta
aggregate(sqrt(squared_deviation)/true~implementation+method+parameter,
betas, mean)
aggregate(squared_deviation~implementation+method+parameter, betas,
function(x) sqrt(mean(x)))
aggregate(covers~implementation+method+parameter, betas, mean)
aggregate(covers_exact~implementation+method+parameter, betas, mean)
aggregate(CI_width~implementation+method+parameter, betas, mean)
aggregate(CI_width_exact~implementation+method+parameter, betas, mean)