Skip to contents

Computes per-dimension parametric and non-parametric statistics for two groups of ENA unit points. Equivalent to group.stats() in rENA-api, moved to the C++ layer so all language bindings share a single implementation.

Usage

group_stats(g1, g2)

Arguments

g1

Numeric matrix (n1 x n_dims), unit points for group 1

g2

Numeric matrix (n2 x n_dims), unit points for group 2

Value

Named list with N, parametric, and nonparametric sub-lists, matching the structure of rENA-api's group.stats().

Details

Parametric (Welch two-sample t-test):

  • t - Welch t-statistics

  • parameter - Welch-Satterthwaite degrees of freedom

  • pvalue - two-tailed p-values

  • effect - Cohen's d (pooled SD: (mean1 - mean2) / pooled_sd)

  • mean - 2 x n_dims matrix, row 1 = group1, row 2 = group2

  • std.dev - 2 x n_dims matrix of sample standard deviations

Non-parametric (Wilcoxon rank-sum):

  • U - rank-sum U for group 1 (= R's wilcox.test W)

  • pvalue - two-tailed p-values (normal approx, tie + continuity correction)

  • effect - rank-biserial: 1 - 2 * U / (n1 * n2)

  • median - 2 x n_dims matrix of medians

Entries are NA when a statistic is undefined (e.g. n < 2 for parametric tests).

Examples

g1 <- matrix(c(1, 2, 3, 4, 10, 11, 12, 13), ncol = 2)
g2 <- matrix(c(2, 3, 5, 6, 9, 9, 10, 12), ncol = 2)
s <- group_stats(g1, g2)
s$N
#> [1] 4 4
s$parametric$t
#>           [,1]
#> [1,] -1.341641
#> [2,]  1.566699
s$nonparametric$U
#>      [,1]
#> [1,]    4
#> [2,]   13