pair_contrast: Pair Contrast

View source: R/contrast.R

pair_contrastR Documentation

Pair Contrast

Description

Construct a sum-to-zero contrast between two logical expressions. This function is particularly useful for comparing specific conditions or combinations of conditions.

Usage

pair_contrast(A, B, name, where = NULL)

Arguments

A

A formula representing the first logical expression in the contrast.

B

A formula representing the second logical expression in the contrast.

name

A character string specifying the name of the contrast (mandatory).

where

An optional formula specifying the subset over which the contrast is computed.

Details

The contrast is constructed as (A - B), where A and B are logical expressions that evaluate to TRUE/FALSE for each observation. The resulting contrast weights sum to zero.

Value

A pair_contrast_spec object containing:

A

First logical expression

B

Second logical expression

where

Subsetting formula (if provided)

name

Contrast name

See Also

pairwise_contrasts for all pairwise comparisons, contrast_set for creating sets of contrasts

Examples

# Compare faces vs scenes
pair_contrast(~ category == "face", ~ category == "scene", name = "face_vs_scene")

# Compare with subsetting
pair_contrast(~ category == "face", ~ category == "scene",
             name = "face_vs_scene_block1",
             where = ~ block == 1)


bbuchsbaum/fmrireg documentation built on March 1, 2025, 11:20 a.m.