From c181c2c3e6aedac53204f088a7f0702d03d4e513 Mon Sep 17 00:00:00 2001
From: Benjamin Auder <benjamin@auder>
Date: Mon, 16 Dec 2019 18:42:46 +0100
Subject: [PATCH] Add print results script for article

---
 reports/printResults.R | 33 +++++++++++++++++++++++++++++++++
 1 file changed, 33 insertions(+)
 create mode 100644 reports/printResults.R

diff --git a/reports/printResults.R b/reports/printResults.R
new file mode 100644
index 0000000..2c3dbee
--- /dev/null
+++ b/reports/printResults.R
@@ -0,0 +1,33 @@
+prms <- function(name, idx)
+{
+  load(name)
+  d <- nrow(mr[[1]][[1]])-2
+  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),]))
+  list(p, beta, b, mr_params)
+}
+
+pprms <- function(link)
+{
+  for (n in c("5000", "10000", "100000", "500000", "1000000"))
+  {
+    method  =1
+    #for (method in 1:2)
+    #{
+      toprint <- c()
+      for (d in c(2,5,10))
+      {
+        name <- paste0("res_", n, "_", d, "_", link, "_6,3,1.RData")
+        params <- prms(name, method)
+        toprint <- c(toprint, c(
+          sum(abs(params[[1]] - params[[4]]$p)),
+          colSums(abs(params[[2]] - params[[4]]$beta)),
+          sum(abs(params[[3]] - params[[4]]$b))
+        ))
+      }
+      print(toprint, digits=2)
+    #}
+  }
+}
-- 
2.44.0