Title: Unified Tools for Classical and Bootstrap Confidence Intervals
Version: 0.1.0
Maintainer: Rayan Siffe <bydex859@gmail.com>
Description: Provides a unified and consistent interface for computing classical and bootstrap confidence intervals for means, variances, proportions, variance ratios, and regression coefficients. The package offers a standardized output structure, S3 classes, and user-friendly methods to facilitate statistical analysis and reproducibility.
License: MIT + file LICENSE
Encoding: UTF-8
Depends: R (≥ 3.5.0)
Imports: stats
Suggests: testthat (≥ 3.0.0), knitr, rmarkdown
Config/testthat/edition: 3
URL: https://github.com/RayanSiffeO/ictools
BugReports: https://github.com/RayanSiffeO/ictools/issues
RoxygenNote: 7.3.3
NeedsCompilation: no
Packaged: 2026-03-04 00:18:39 UTC; RAYANs
Author: Rayan Siffe [aut, cre]
Repository: CRAN
Date/Publication: 2026-03-08 10:10:02 UTC

Confidence Interval for the Mean

Description

Computes confidence intervals for a population mean.

Usage

ic_pmean(
  x,
  conf.level = 0.95,
  type = c("two.sided", "upper", "lower"),
  method = c("t", "z"),
  sigma = NULL,
  na.rm = TRUE
)

Arguments

x

Numeric vector, matrix, or data.frame.

conf.level

Confidence level (default 0.95).

type

Character. "two.sided", "upper", or "lower".

method

Character. "t" (default) or "z".

sigma

Known population standard deviation (required if method = "z").

na.rm

Logical. Whether to remove NA values.

Value

A list of class "ic_pmean" with mean estimate and confidence interval.

Examples

data <- c(5, 7, 8, 6, 9, 10)
ic_pmean(data)
ic_pmean(data, conf.level = 0.99)
mat <- matrix(data, nrow = 2)
ic_pmean(mat)


Confidence Interval for a Proportion

Description

Computes confidence intervals for a population proportion.

Usage

ic_prop(
  x,
  conf.level = 0.95,
  success = c(1, "yes", "true"),
  method = c("wilson", "wald", "clopper"),
  na.rm = TRUE
)

Arguments

x

Numeric vector (0/1) or matrix of 0/1.

conf.level

Confidence level (default 0.95).

success

Value considered a success (default 1, "yes", "true").

method

Character. "wilson", "wald", or "clopper".

na.rm

Logical. Whether to remove NA values.

Value

A list of class "ic_proportion" with proportion estimate and confidence interval.

Examples

data <- matrix(c(1, 0, 1, 1, 0, 1), nrow = 2)
ic_prop(data)
ic_prop(data, conf.level = 0.99)


Confidence Interval for the Ratio of Variances

Description

Computes confidence intervals for the ratio of two population variances.

Usage

ic_razon_var(
  x,
  y,
  conf.level = 0.95,
  method = c("f", "log", "bootstrap"),
  R = 2000,
  na.rm = TRUE
)

Arguments

x

Numeric vector or matrix (first sample).

y

Numeric vector or matrix (second sample).

conf.level

Confidence level (default 0.95).

method

Character. "f", "log", or "bootstrap".

R

Number of bootstrap replicates (default 2000).

na.rm

Logical. Whether to remove NA values.

Value

A list of class "ic_var_ratio" with ratio estimate and confidence interval.

Examples

data1 <- matrix(c(5, 7, 8, 6, 9, 10), nrow = 2)
data2 <- matrix(c(4, 6, 7, 5, 8, 9), nrow = 2)
ic_razon_var(data1, data2)
ic_razon_var(data1, data2, conf.level = 0.99)


Confidence Intervals for Regression Coefficients

Description

Computes confidence intervals for the coefficients of a linear model (lm).

Usage

ic_reg(
  model,
  conf.level = 0.95,
  method = c("classical", "bootstrap", "residual"),
  R = 2000
)

Arguments

model

An object of class lm.

conf.level

Confidence level (defaults to 0.95).

method

Método para calcular el intervalo: "classical", "bootstrap" o "residual".

R

Número de réplicas bootstrap (solo para métodos bootstrap/residual).

Value

An object of class ic_reg containing the estimate and the confidence interval.

Examples

# Create sample data
test_data <- data.frame(
  y = c(5, 6, 7, 8, 9, 10),
  x1 = c(1, 2, 3, 4, 5, 6),
  x2 = c(2, 1, 3, 2, 4, 5)
)

# Fit model and calculate CI
fit <- lm(y ~ x1 + x2, data = test_data)
ic_reg(fit)


Confidence Interval for the Variance

Description

Computes confidence intervals for a population variance.

Usage

ic_var(
  x,
  conf.level = 0.95,
  type = c("two.sided", "upper", "lower"),
  na.rm = TRUE
)

Arguments

x

Numeric vector or matrix.

conf.level

Confidence level (default 0.95).

type

Character. "two.sided", "upper", or "lower".

na.rm

Logical. Whether to remove NA values.

Value

A list of class "ic_var" with variance estimate and confidence interval.

Examples

data <- matrix(c(5, 7, 8, 6, 9, 10), nrow = 2)
ic_var(data)
ic_var(data, conf.level = 0.99)