Fcontrasts: Generate F-contrasts for a model term

View source: R/all_generic.R

FcontrastsR Documentation

Generate F-contrasts for a model term

Description

Create F-contrasts to test for overall effects of model terms. F-contrasts are used to:

categorical

Test for any effect of a categorical predictor

basis

Compare multiple basis functions simultaneously

nonlinear

Test for nonlinear effects of continuous predictors

overall

Evaluate overall significance of model terms

Usage

Fcontrasts(x, ...)

## S3 method for class 'convolved_term'
Fcontrasts(x, ...)

Arguments

x

The model term to generate contrasts for (typically an event_term or event_model)

...

Additional arguments passed to methods. Common arguments include:

basis

Character; type of basis functions used

nbasis

Integer; number of basis functions

exclude

Character vector of conditions to exclude

Value

A list of contrast specifications where each contains:

weights

Matrix of contrast weights

term

The model term being tested

name

Descriptive name for the contrast

df

Degrees of freedom for the contrast

See Also

event_model(), contrast_weights()

Examples

# Create event data with multiple conditions
event_data <- data.frame(
  condition = factor(c("A", "B", "C", "A", "B", "C")),
  rt = c(0.8, 1.2, 0.9, 1.1, 0.7, 1.3),
  onsets = c(1, 10, 20, 30, 40, 50),
  run = c(1, 1, 1, 1, 1, 1)
)

# Create sampling frame
sframe <- sampling_frame(blocklens = 60, TR = 2)

# Create event model with multiple terms
evmodel <- event_model(
  onsets ~ hrf(condition) + hrf(rt),
  data = event_data,
  block = ~run,
  sampling_frame = sframe
)

# Get F-contrast for main effect of condition
cond_contrast <- Fcontrasts(evmodel)

# Create model with multiple basis functions
evmodel2 <- event_model(
  onsets ~ hrf(condition, basis = "fourier", nbasis = 3),
  data = event_data,
  block = ~run,
  sampling_frame = sframe
)

# Get F-contrasts testing all basis functions
basis_contrasts <- Fcontrasts(evmodel2)

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