tests/testthat/helper-inputs.R

small_inputs <- function(s = 24L) {
  draws <- cbind(a = sin(seq_len(s) / 2), b = cos(seq_len(s) / 3))
  y <- c(-2, -1, 0.5, 2, 3, 4)
  x <- c(-1, 0, 1, -2, 1, 2)
  ll <- vapply(seq_along(y), function(i) {
    dnorm(y[i], draws[, "a"] + x[i] * draws[, "b"], log = TRUE)
  }, numeric(s))
  list(draws = draws, ll = ll, cluster = c("c", "a", "c", "b", "b", "a"))
}

load_brms_fixture <- function(name) {
  skip_if_not_installed("brms", minimum_version = "2.20.0")
  readRDS(test_path("fixtures", paste0(name, ".rds")))
}

load_brms_sampling_data <- function() {
  readRDS(test_path("fixtures", "sampling-data.rds"))
}

study_helpers <- function() {
  e <- new.env(parent = globalenv())
  sys.source(system.file("study", "study-functions.R", package = "IJSE"), e)
  e
}

upstream_se <- function(draws, ll, cluster = NULL) {
  if (!is.null(cluster)) {
    ll <- vapply(unique(cluster), function(id) {
      rowSums(ll[, which(cluster == id), drop = FALSE])
    }, numeric(nrow(ll)))
  }
  n <- ncol(ll)
  influence <- n * cov(draws, ll)
  sqrt(diag(cov(t(influence))) / n)
}

Try the IJSE package in your browser

Any scripts or data that you put into this service are public.

IJSE documentation built on Oct. 22, 2026, 5:18 p.m.