sbp_basis: Basis from a sequential binary partition

View source: R/basis.R

sbp_basisR Documentation

Basis from a sequential binary partition

Description

Construct a balance basis from a sequential binary partition (SBP) or from a more general collection of balances.

Usage

sbp_basis(sbp, data = NULL, fill = FALSE, silent = FALSE)

Arguments

sbp

A list of formulas or a matrix describing balances.

data

Optional compositional data set used to extract part names when 'sbp' is given as a list of formulas.

fill

Logical; if 'TRUE', complete the supplied balances to obtain a full basis.

silent

Logical; if 'FALSE', report whether the resulting balances form a basis, and whether they are orthogonal or orthonormal.

Details

The argument 'sbp' can be specified in two ways:

  • as a list of formulas, where each formula defines the numerator and the denominator groups of a balance,

  • as a matrix with one column per balance and one row per part. Positive entries indicate parts in the numerator, negative entries indicate parts in the denominator, and zeros indicate unused parts.

Value

A matrix whose columns are balances.

Examples

X <- data.frame(
  a = 1:2, b = 2:3, c = 4:5,
  d = 5:6, e = 10:11, f = 100:101, g = 1:2
)

# Sequential SBP construction
sbp_basis(list(
  b1 = a ~ b + c + d + e + f + g,
  b2 = b ~ c + d + e + f + g,
  b3 = c ~ d + e + f + g,
  b4 = d ~ e + f + g,
  b5 = e ~ f + g,
  b6 = f ~ g
), data = X)

# Chain construction
sbp_basis(list(
  b1 = a ~ b,
  b2 = b1 ~ c,
  b3 = b2 ~ d,
  b4 = b3 ~ e,
  b5 = b4 ~ f,
  b6 = b5 ~ g
), data = X)

# Non-orthogonal system of balances
sbp_basis(list(
  b1 = a + b + c ~ e + f + g,
  b2 = d ~ a + b + c,
  b3 = d ~ e + g,
  b4 = a ~ e + b,
  b5 = b ~ f,
  b6 = c ~ g
), data = X)

# Direct construction from a contrast matrix
sbp_basis(cbind(
  c( 1,  1, -1, -1),
  c( 1, -1,  1, -1),
  c( 1, -1, -1,  1)
))


coda.base documentation built on March 4, 2026, 9:06 a.m.