Skip to content

Instantly share code, notes, and snippets.

View nt-williams's full-sized avatar
:octocat:
Procrastinating

Nicholas Williams nt-williams

:octocat:
Procrastinating
View GitHub Profile
@nt-williams
nt-williams / rubins_rules.R
Created May 10, 2023 17:13
Rubins rules for lmtp
lmtp_type <- \(x) structure(x, class = class(x[[1]]))
rubins_rules <- \(x, ...) UseMethod("rubins_rules", lmtp_type(x))
rubins_rules.lmtp <- function(lmtps, label, alpha = 0.05) {
thetas <- purrr::map_dbl(lmtps, "theta")
vw <- mean(purrr::map_dbl(lmtps, \(x) x$standard_error^2))
vb <- var(thetas)
theta <- mean(thetas)
se <- pooled_se(vw, vb, length(thetas))