DEV Community

Alex Towell
Alex Towell

Posted on • Originally published at metafunctor.com

hypothesize: My R Package for Hypothesis Testing is Now on CRAN

I'm pleased to announce that hypothesize is now available on CRAN, the official R package repository.

What is hypothesize?

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 includes implementations for two common tests:

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

Why a Consistent API?

When building statistical libraries, I found myself repeatedly implementing ad-hoc hypothesis test structures. hypothesize standardizes this: any package can wrap its tests in a consistent interface, making it easier to compose statistical workflows.

Installation

Now that it's on CRAN, installation is simple:

install.packages("hypothesize")
Enter fullscreen mode Exit fullscreen mode

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)
Enter fullscreen mode Exit fullscreen mode

What's Next

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

Links

Top comments (0)