hypothesize: Now on CRAN

December 12, 2025

hypothesize is now on CRAN.

What It Does

hypothesize provides a consistent API for hypothesis testing in R. It defines generic methods that any hypothesis test can implement:

  • pval() - Extract the p-value
  • test_stat() - Get the test statistic
  • dof() - Retrieve degrees of freedom
  • is_significant_at() - Check significance at a given level

The package ships with two implementations:

  • Likelihood Ratio Test (LRT) for comparing nested models
  • Wald Test for testing parameter estimates

Why

When building statistical libraries, I kept implementing ad-hoc hypothesis test structures. Different packages, different interfaces, no composability. hypothesize standardizes this: any package can wrap its tests in a consistent interface, and statistical workflows can treat all tests uniformly.

It’s a small package. That’s the point.

Installation

install.packages("hypothesize")

Quick Example

library(hypothesize)

# Likelihood Ratio Test
result <- lrt(null_loglik = -100, alt_loglik = -96, dof = 3)
print(result)

# Check significance
is_significant_at(result, 0.05)

# Extract components
pval(result)
test_stat(result)

Documentation

Full documentation is at queelius.github.io/hypothesize.

What’s Next

I have several other R packages in the pipeline for CRAN submission, including packages for likelihood-based inference and reliability analysis.

hypothesize: A Consistent Interface for Statistical Tests

March 25, 2022

R’s hypothesis testing functions are inconsistent. t.test() returns a different structure than chisq.test(). Writing generic code that works across tests is painful. hypothesize fixes this with a unified API where every test returns the same interface.

The Problem

Different R tests return incompatible objects:

t.test(x, y)$p.value        # Works
chisq.test(x, y)$p.value    # Also works
my_custom_test(x, y)$???    # Who knows?

You cannot write generic code that works across tests without knowing the internals of each one.

The Fix

hypothesize defines a consistent interface:

test <- lrt(model_null, model_alt)  # Likelihood ratio test
pval(test)          # Extract p-value
test_stat(test)     # Extract test statistic
dof(test)           # Extract degrees of freedom
is_significant_at(test, 0.05)  # Boolean check

All tests, built-in or custom, implement the same generic functions. The interface is the same whether you are doing a likelihood ratio test, a Wald test, or a Z-test.

Integration with likelihood.model

The package works with likelihood.model, so likelihood ratio tests on any model are straightforward:

lrt(null_model, alternative_model)  # Automatic LRT

You specify the models. The package computes the test statistic, degrees of freedom, and p-value. Same interface as every other test.

The Point

Tests are objects you manipulate, not functions with incompatible return types. You can write test-agnostic pipelines. You can wrap your own custom tests in the same interface. This is generic programming applied to hypothesis testing: a consistent abstraction over heterogeneous implementations.

R package – Works with likelihood.modelDocumentationGitHub