Set Alpha Based on Sample Size Using Bayes Factors
Overview
Sets the alpha level for coefficients in a regression model as a decreasing function of the sample size through the use of Jeffreys' Approximate Bayes factor. You tell alphaN() your sample size, and it tells you to which value you must lower alpha to avoid Lindley's Paradox. For details, see Wulff and Taylor (2024) doi:10.1177/14761270231214429. Alpha can also be calibrated to the effect-size and moment Bayes factors of Klauer, Meyer-Grant, and Kellen (2025) doi:10.3758/s13423-024-02612-2, which center the alternative hypothesis on an effect size of your choosing.
New features
- New function
alphaN_power()computes the power of the calibrated test against a standardized effect of sized: the design-time companion ofalphaN()(noncentral t for single coefficients, noncentral F for joint tests, at the residual degrees of freedom). For model-specific effect parameterizations (odds ratios, rate ratios), the calibrated alpha plugs directly into the calculators of the pwrss package via theiralphaargument; see?alphaN_power. - New function
alphaN_power_plot()draws power against sample size, one panel per effect size, with every calibration method evaluated at its own alpha(n) and a fixed reference level as a dashed curve. alphaN_report()gains apower_atargument: the settings report can now document the power of the calibrated test against the effect sizes the researcher cares about, alongside the alpha itself.
Show all changes in 0.3.0Hide the rest of the changes in 0.3.0
alphaN_report()now also states the scope of the"ES"and"moment"calibrations: exact for the normal linear model whenpis supplied (evaluated at the effective sample sizen - p), the conservative large-sample form otherwise, and asymptotic for other generalized linear models.- New function
alphaN_report()writes a preregistration-ready Markdown settings report: every input behind a calibrated alpha (sample size, evidence target, method, prior settings), the resulting alpha, the decision rule, and the references to cite. It mirrors the downloadable report of the companion Shiny application, can write straight to a file, and hard-wraps its lines (default 72 characters, seewidth) so the report reads well in consoles, files, and rendered documents. JAB()called without acovariatenow returns a named vector with the Bayes factor of every coefficient except the intercept (which remains available on explicit request).alphaN_plot()andJAB_plot()have been restyled: colorblind-safe Okabe-Ito palette, light grid lines, open axes, and horizontal axis labels.alphaN_plot()additionally gains alogargument ("x", "y", "xy") which helps when the fast-falling "moment" curve is drawn next to the others, and its tick labels always use plain notation ("0.0001" and "10,000", never "1e-04").- New function
klauerBF()exports the effect-size and moment Bayes factors of Klauer, Meyer-Grant & Kellen (2025) thatalphaN()inverts: from a t statistic (one-sample test or single regression coefficient) or from an F statistic for a joint test ofqcoefficients. alphaN()(methods"ES"and"moment") gains argumentsqandp. Withq > 1the alpha level is calibrated for the joint F test of q coefficients through the exact regression-case Bayes factors of Klauer et al. (2025, Table 4), implemented natively including their Gaussian hypergeometric term;psets the number of retained model parameters so that small-sample calibrations can use the effective sample sizen - p(residual degrees of freedom). The defaults (q = 1,p = 0) reproduce the previous behavior exactly. The moment-prior defaultnuis now5 + (q - 1)and the ES-prior scale recommendation generalizes tor = sqrt((nu - 2)/(nu * q)) * de, both following the paper (unchanged atq = 1).- New function
n_effective()computes the effective sample sizen * (se/se_robust)^2that Wulff & Taylor (2024) recommend as a sensitivity check when calibrating alpha with clustered (panel) data. alphaN_plot()gains amethodsargument and can now draw the"ES"and"moment"curves alongside the prior-fraction methods.- The regression-case implementation is validated against all printed Bayes factors in Table 8 of Klauer et al. (2025), in addition to the existing Table 7 anchors, and the q = 1 F form agrees with the validated t form to near machine precision.
- The quadrature and inversion machinery is additionally stress-tested against an independent oracle that integrates on the original effect scale over an infinite range with a plain density ratio (none of the package's substitution, windowing, or log-clamping choices); the normal-limit switch at
n - p= 50,000 is measured directly by running both branches at the same effective sample size, and monotonicity of alpha innandBF, and of the Bayes factors in the test statistic, is checked over grids that cross the switch, including joint tests and small residual degrees of freedom.
Documentation
- Klauer, Meyer-Grant & Kellen is now cited with its printed-issue details (2025, Psychonomic Bulletin & Review, 32, 1070-1094) throughout; it was previously cited by its online-first year, 2024.
?alphaNstates the model scope of the"ES"and"moment"methods: exact under the normal linear model, asymptotic (like the prior-fraction methods) for other generalized linear models.citation("alphaN")now also lists Klauer et al. (2025) for users of the"ES"and"moment"methods.
From NEWS.md in the release
Install
Health
- OK13 OK2026-08-05
- NOTE12 OK, 1 NOTE2026-08-01
- OK14 OK2026-03-10
Documentation
- Help pages
- 11
- Examples that run
- 100%11 run in a plain check (1 of them under a condition)
- Exported functions with examples
- 100%
- Documented parameters
- 100%
- Return-value docs
- 100%
- Help pages citing references
- 0%
- Intro to alphaN HTML
Downloads
Repository
Stars over time
Forks over time
Releases over time
Issues over time
Commits over time
8 development-tooling and community-health practices detected across 4 families in the upstream repository
Checks run against github.com/jespernwulff/alphan on 2026-10-21.
The R CMD check workflow runs on Linux, macOS and Windows, and on R-devel
GitHub Pages site last deployed 2026-07-27 · The repository has a site deploy workflow
pkgdown site last built 2026-07-27
This repository shows signs of AI coding tools.
- Claude Codefirst seen 2026-07-11Named in .Rbuildignore: .claude, CLAUDE.mdCommits: at least 22 crediting it in the message
- Claude Fable 522 commits · Jul 2026
Dependencies
Installing alphaN adds no packages beyond those that come with R.
Code & Tests
People & History
Pick two releases to compare their code metrics.
- 0.3.0Latest2026-07-27 · current release · diff ↗ ·
added 5 exports
alphaN_power, alphaN_power_plot, alphaN_report, klauerBF, n_effective - RR 4.6.0 released · 2026-04-24
- 0.2.02025-07-13 · diff ↗
- 0.1.22025-07-13 · diff ↗
- RR 4.5.0 released · 2025-04-11
- RR 4.4.0 released · 2024-04-24
- RR 4.3.0 released · 2023-04-21
- 0.1.02023-01-12
- RR 4.2.0 released · 2022-04-22
Package metadata
- First published
- 2023-01-12
- Total releases
- 4 / 3 yrs
- License
- MIT + file LICENSE OSI
- Minimum R
- ≥ 4.0
- Download size
- 116 KB
Cite
Cite this package
Run in R for the authors' entry:
citation("alphaN")The package provides a citation file, so citation() returns the authors' own entry.
It points to 10.1177/14761270231214429, 10.3758/s13423-024-02612-2.
Cite the R Observatory
For a number measured here: a download total, a coverage figure, an archival date.
From data release v2026-10-25, which the citation names so these numbers can be found later. More on citing and the projects behind them.