Learn R Programming

stcpR6 (version 0.9.7)

NormalCS: NormalCS Class

Description

NormalCS class is used to compute always-valid confidence sequence for the standard normal process based on the STCP method.

Arguments

Methods


Method new()

Create a new NormalCS object.

Usage

NormalCS$new(
  alternative = c("two.sided", "greater", "less"),
  alpha = 0.05,
  n_upper = 1000,
  n_lower = 1,
  weights = NULL,
  lambdas = NULL,
  k_max = 1000
)

Arguments

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.

k_max

Positive integer to determine the maximum number of baselines.

Returns

A new NormalCS object.


Method print()

Print summary of Stcp object.

Usage

NormalCS$print()


Method getAlpha()

Return the upper bound on the type 1 error

Usage

NormalCS$getAlpha()


Method getWeights()

Return weights of mixture of e-values / e-detectors.

Usage

NormalCS$getWeights()


Method getLambdas()

Return lambda parameters of mixture of e-values / e-detectors.

Usage

NormalCS$getLambdas()


Method computeWidth()

Compute the width of confidence interval at time n.

Usage

NormalCS$computeWidth(n)

Arguments

n

Positive time.


Method computeInterval()

Compute a vector of two end points of confidence interval at time n

Usage

NormalCS$computeInterval(n, x_bar = 0)

Arguments

n

Positive time.

x_bar

The center of the confidence interval.

Examples

Run this code
# 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)

Run the code above in your browser using DataLab