## ----include = FALSE----------------------------------------------------------
knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>"
)

## ----setup--------------------------------------------------------------------
library(alphaN)

## -----------------------------------------------------------------------------
alpha <- alphaN(n = 1000, BF = 1)
alpha

## -----------------------------------------------------------------------------
JAB_plot(n = 1000, BF = 1)

## -----------------------------------------------------------------------------
seqN <- seq(50, 1000, 1)
plot(seqN, alphaN(seqN), type = "l",
     xlab = "n", ylab = "Alpha")

## -----------------------------------------------------------------------------
alphaN(1000, BF = 3, method = "balanced")

## -----------------------------------------------------------------------------
alphaN_plot(BF = 3)

## -----------------------------------------------------------------------------
# alpha needed at n = 1000 for moderate evidence (BF = 3), targeting a
# medium-sized effect (de = 0.5)
alphaN(1000, BF = 3, method = "ES", de = 0.5)
alphaN(1000, BF = 3, method = "moment", de = 0.5)

## -----------------------------------------------------------------------------
ns <- c(100, 1000, 10000)
round(rbind(JAB    = alphaN(ns, BF = 3),
            ES     = alphaN(ns, BF = 3, method = "ES"),
            moment = alphaN(ns, BF = 3, method = "moment")), 5)

## -----------------------------------------------------------------------------
klauerBF(n = 80, t = 2.24, de = 0.5)

## -----------------------------------------------------------------------------
# Alpha for the joint F test of q = 2 coefficients at n = 200, targeting a
# medium effect
alphaN(200, BF = 3, method = "ES", q = 2, p = 2, de = sqrt(0.15))

## -----------------------------------------------------------------------------
# Cluster-robust SE twice the classical one: n_e is four times smaller
n_effective(n = 237, se = 0.1, se_robust = 0.2)

