conditionalCI: Conditional confidence interval

View source: R/conditionalCI.R

conditionalCIR Documentation

Conditional confidence interval

Description

Conditional confidence intervals for normally distributed random variables.

Usage

conditionalCI(
  theta,
  threshold,
  sigma = 1,
  conf.level = 0.95,
  df = NULL,
  method = "shortest",
  distribution = "gaussian",
  trace = length(theta) > 1,
  ...
)

Arguments

theta

[numeric vector] the observed value(s) of the statistic.

threshold

[numeric, >0] the threshold.

sigma

[numeric vector] the standard error of the statistic(s).

conf.level

[numeric, 0-1] Conditional confidence level of the interval.

df

[interger, >0] Degree of freedom of the distribution of theta. Only relevant when distribution equals "student".

method

[character] the method used to compute the conditional confidence interval. So far only "shortest" is supported.

distribution

[character] Distribution of theta. Either "gaussian" or "student".

trace

[interger, 0-2] should a progress bar be displayed?

...

additional arguments to be passed to lavaSearch2:::.calcShortestCI to specify the optimization method.

Details

Compute the confidence interval of theta conditional on theta being greater (in absolute value) than the threshold. theta is assumed to be normally distributed with known variance sigma. The thresholding is applied after normalization (i.e. dividing theta by sigma). This corresponding to conditioning on a minimal significance level.

Examples

ci <- conditionalCI(theta = seq(3,7, by = 0.1),
                    threshold = 2.9999, distribution = "gaussian")

print(ci)
confint(ci)
autoplot(ci)

ci1 <- conditionalCI(theta = 4, sigma = 2, threshold = 2.9999, method = "shortest")
ci2 <- conditionalCI(theta = 4/2, sigma = 1, threshold = 2.9999/2, method = "shortest")
confint(ci1) - 2*confint(ci2)
ci3 <- conditionalCI(theta = 4, sigma = 2, threshold = 2.9999, method = "shortest2")
confint(ci1) - confint(ci3)

bozenne/butils documentation built on Oct. 14, 2023, 6:19 a.m.