X-Git-Url: https://git.auder.net/?p=morpheus.git;a=blobdiff_plain;f=reports%2FprintResults.R;h=b61084f4e19b93f8724535136c66cee6f97ec79c;hp=a6cac0549b7c9208d1a99d1d75f50a6e67641cfa;hb=07f2d0453144f5b639dcc28f1df40a141db7da79;hpb=38c65767eb0c8c5a7ad6025471f56dbaffc68e6e diff --git a/reports/printResults.R b/reports/printResults.R index a6cac05..b61084f 100644 --- a/reports/printResults.R +++ b/reports/printResults.R @@ -1,32 +1,42 @@ +# NOTE: discard top 2% of highest values prms <- function(name, idx) { load(name) d <- nrow(mr[[1]][[1]])-2 + if (idx > length(mr)) + mr[[idx]] = mr[[1]] p <- colMeans(do.call(rbind, lapply(mr[[idx]], function(m) m[1,]))) - b <- colMeans(do.call(rbind, lapply(mr[[idx]], function(m) m[2+d,]))) - L <- length(mr[[1]]) - beta <- (1/L) * Reduce("+", lapply(mr[[idx]], function(m) m[2:(d+1),])) + bVects <- lapply(mr[[idx]], function(m) m[2+d,]) + q98 <- quantile(sapply(bVects, function(bv) sum(abs(bv))), 0.98) + bFiltered <- Filter(function(bv) sum(abs(bv)) < q98, bVects) + b <- colMeans(do.call(rbind, bFiltered)) + betaMatrices <- lapply(mr[[idx]], function(m) m[2:(d+1),]) + q98 <- quantile(sapply(betaMatrices, function(bm) sum(abs(bm))), 0.98) + bmFiltered <- Filter(function(bm) sum(abs(bm)) < q98, betaMatrices) + beta <- (1/length(bmFiltered)) * Reduce("+", bmFiltered) list(p, beta, b, mr_params) } -pprms <- function(link) +pprms <- function(link, prefix="./") { - for (n in c("5000", "10000", "100000", "500000", "1000000")) + toprint <- matrix(nrow=0, ncol=13) #13=1+2+1 + 1+2+1 + 1+3+1 + for (n in c("5000", "10000", "100000", "500000", "1000000")) { for (method in 1:2) { - toprint <- c() + row <- c() for (d in c(2,5,10)) { - name <- paste0("res_", n, "_", d, "_", link, ".RData") + name <- paste0(prefix, "res_", n, "_", d, "_", link, ".RData") params <- prms(name, method) - toprint <- c(toprint, c( + row <- c( row, sum(abs(params[[1]] - params[[4]]$p)), colSums(abs(params[[2]] - params[[4]]$beta)), - sum(abs(params[[3]] - params[[4]]$b)) - )) + sum(abs(params[[3]] - params[[4]]$b)) ) } - print(toprint, digits=2) + toprint <- rbind(toprint, row) } } + print(formatC(toprint, format="e", digits=1)) #for reporting + return (toprint) }