1 # NOTE: discard top 2% of highest values
2 prms <- function(name, idx)
5 d <- nrow(mr[[1]][[1]])-2
8 p <- colMeans(do.call(rbind, lapply(mr[[idx]], function(m) m[1,])))
9 bVects <- lapply(mr[[idx]], function(m) m[2+d,])
10 q98 <- Inf #quantile(sapply(bVects, function(bv) sum(abs(bv))), 0.98)
11 bFiltered <- Filter(function(bv) sum(abs(bv)) < q98, bVects)
12 b <- colMeans(do.call(rbind, bFiltered))
13 betaMatrices <- lapply(mr[[idx]], function(m) m[2:(d+1),])
14 q98 <- Inf #quantile(sapply(betaMatrices, function(bm) sum(abs(bm))), 0.98)
15 bmFiltered <- Filter(function(bm) sum(abs(bm)) < q98, betaMatrices)
16 beta <- (1/length(bmFiltered)) * Reduce("+", bmFiltered)
17 list(p, beta, b, mr_params)
20 pprms <- function(link, prefix="./")
22 toprint <- matrix(nrow=0, ncol=13) #13=1+2+1 + 1+2+1 + 1+3+1
23 for (n in c("5000", "10000", "100000", "500000", "1000000"))
30 name <- paste0(prefix, "res_", n, "_", d, "_", link, ".RData")
31 params <- prms(name, method)
33 sum(abs(params[[1]] - params[[4]]$p)),
34 colSums(abs(params[[2]] - params[[4]]$beta)),
35 sum(abs(params[[3]] - params[[4]]$b)) )
37 toprint <- rbind(toprint, row)
40 print(formatC(toprint, format="e", digits=1)) #for reporting