NormalCS {stcpR6} | R Documentation |
NormalCS class is used to compute always-valid confidence sequence for the standard normal process based on the STCP method.
new()
Create a new NormalCS object.
NormalCS$new( alternative = c("two.sided", "greater", "less"), alpha = 0.05, n_upper = 1000, n_lower = 1, weights = NULL, lambdas = NULL, skip_g_alpha = TRUE, k_max = 1000 )
alternative
Alternative / post-change mean space
two.sided: Two-sided test / change detection
greater: Alternative /post-change mean is greater than null / pre-change one
less: Alternative /post-change mean is less than null / pre-change one
alpha
Upper bound on the type 1 error of the confidence sequence.
n_upper
Upper bound of the target sample interval
n_lower
Lower bound of the target sample interval
weights
If not null, the input weights will be used to initialize the object
instead of n_upper
and n_lower
.
lambdas
If not null, the input lambdas will be used to initialize the object.
instead of n_upper
and n_lower
.
skip_g_alpha
If true, we do not compute g_alpha and use log(1/alpha) instead.
k_max
Positive integer to determine the maximum number of baselines.
A new NormalCS
object.
print()
Print summary of Stcp object.
NormalCS$print()
getAlpha()
Return the upper bound on the type 1 error
NormalCS$getAlpha()
getWeights()
Return weights of mixture of e-values / e-detectors.
NormalCS$getWeights()
getLambdas()
Return lambda parameters of mixture of e-values / e-detectors.
NormalCS$getLambdas()
computeWidth()
Compute the width of confidence interval at time n.
NormalCS$computeWidth(n)
n
Positive time.
computeInterval()
Compute a vector of two end points of confidence interval at time n
NormalCS$computeInterval(n, x_bar = 0)
n
Positive time.
x_bar
The center of the confidence interval.
# Initialize two-sided standard normal confidence sequence
# optimized for the interval [10, 100]
normal_cs <- NormalCS$new(
alternative = "two.sided",
alpha = 0.05,
n_upper = 100,
n_lower = 10
)
# Compute confidence interval at n = 20 when observed sample mean = 0.5
normal_cs$computeInterval(20, x_bar = 0.5)
# (Advanced) NormalCS supports general variance process.
# Both n_upper and n_lower can be general positive numbers.
normal_cs2 <- NormalCS$new(
alternative = "two.sided",
alpha = 0.05,
n_upper = 100.5,
n_lower = 10.5
)
# Confidence interval at n = 20.5
normal_cs$computeInterval(20.5, x_bar = 0.5)