Add print results script for article
authorBenjamin Auder <benjamin@auder>
Mon, 16 Dec 2019 17:42:46 +0000 (18:42 +0100)
committerBenjamin Auder <benjamin@auder>
Mon, 16 Dec 2019 17:42:46 +0000 (18:42 +0100)
reports/printResults.R [new file with mode: 0644]

diff --git a/reports/printResults.R b/reports/printResults.R
new file mode 100644 (file)
index 0000000..2c3dbee
--- /dev/null
@@ -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)
+    #}
+  }
+}