pairwise_diff: Pairwise parameter differences

View source: R/contr.R

pairwise_diffR Documentation

Pairwise parameter differences

Description

Construct contrasts for pairwise differences between parameters, or apply these contrasts to an estimate object.

Usage

pairwise_diff(n, idx = NULL, reverse = FALSE)

Arguments

n

An integer giving the total number of parameters, or an estimate object from which the number of parameters is derived.

idx

An integer vector of parameter indices to compare. If NULL, all parameters are compared.

reverse

Logical; if TRUE, reverse the direction of each difference by multiplying the contrast matrix by -1.

Details

When n is an integer, the function returns a contrast matrix with n columns and one row for each pairwise comparison. If idx is supplied, only pairs of parameters selected by idx are compared.

When n is an estimate object, the number of parameters is obtained from length(coef(n)). The contrast matrix is applied to the object, returning an estimate object containing the pairwise differences and their propagated uncertainty.

Value

A numeric contrast matrix if n is an integer, or an estimate object if n is an estimate object.

Examples

pairwise_diff(4)
pairwise_diff(4, idx = c(1, 3, 4))
pairwise_diff(4, reverse = TRUE)

e <- estimate(coef = c(a = 1, b = 2, c = 4),
              vcov = diag(3))
pairwise_diff(e)

lava documentation built on Oct. 23, 2026, 1:09 a.m.