Skip to content

Instantly share code, notes, and snippets.

View strengejacke's full-sized avatar
⁉️
Focusing

Daniel strengejacke

⁉️
Focusing
View GitHub Profile
# Second Generation P-value
p_delta <- function(lb, ub, delta_lb, delta_ub) {
# special case: infinite CI and H0 bounds in the same direction
if ((delta_lb == -Inf & lb == -Inf) | (delta_ub == Inf & ub == Inf)) {
return(1)
}
# usual case: non-point CI & non-point Ho
@strengejacke
strengejacke / table-performance.R
Created May 22, 2020 10:29
performance comparison of table functions in R
See https://twitter.com/malte_grosser/status/1262862749794795520?s=20
``` r
table2 <- function(x) {
x_u <- if (is.factor(x)) sort(x[!duplicated(x)]) else sort(unique(x))
x_f <- factor(x, levels = as.character((x_u)), exclude = NULL)
t_x_f <- tabulate(x_f)
names(t_x_f) <- as.character(x_u)
t_x_f
}
library(tidyverse)
library(parameters)
library(lme4)
library(see)
# data generation -----------------------
set.seed(123)
n <- 5
b <- seq(1, 1.5, length.out = 5)