Skip to contents

For each dimension computes a t-based CI: mean +/- t(alpha/2, n-1) * (SD / sqrt(n)) where alpha = 1 - conf_level.

Usage

mean_ci(points, conf_level = 0.95)

Arguments

points

Numeric matrix (units x dims), one row per unit in the group

conf_level

Confidence level (default 0.95)

Value

Numeric matrix (n_dims x 3): columns are [mean, ci_lower, ci_upper]. When nrow(points) == 1 the CI bounds are -Inf and Inf.

Examples

pts <- matrix(c(1, 2, 3, 4, 10, 12, 11, 13), ncol = 2)
mean_ci(pts)  # rows = dimensions; columns = mean, lower, upper
#>      [,1]      [,2]     [,3]
#> [1,]  2.5 0.4457397  4.55426
#> [2,] 11.5 9.4457397 13.55426
t.test(pts[, 1])$conf.int  # same bounds as row 1
#> [1] 0.4457397 4.5542603
#> attr(,"conf.level")
#> [1] 0.95