knitr::opts_chunk$set(echo = TRUE) library(knitr) library(purrr) compare_power <- function(x, title, R = 1, cores = 1) { p <- x$p pow <- get_power(p, df = "satterth", R = cores, cores = cores) res <- summary(x) res <- res$summary$correct$FE[4, c("Power", "Power_bw", "Power_satt")] df <- data.frame("title" = title, "get_power_Satt" = pow$power, "sim_Satt"= res$Power_satt, "diff %" = (pow$power - res$Power_satt)*100, "sim_Wald" = res$Power, "sim_BW" = res$Power_bw, check.names = FALSE, stringsAsFactors = FALSE) df }
library(powerlmm) res <- readRDS("simres.rds")
cmp <- pmap_dfr(list(x = res, title = c("1. 4 clusters", "2. 4 clusters, PN", "3. 12 clusters", "4. 12 unequal clusters", "5. Random clusters"), R = c(1, 1, 1, 50, 100), cores = c(1, 1, 1, 30, 30)), compare_power) kable(cmp, digits = 3)
res[[1]]$p summary(res[[1]])
res[[2]]$p summary(res[[2]])
res[[3]]$p summary(res[[3]])
res[[4]]$p summary(res[[4]])
res[[5]]$p summary(res[[5]])
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.