Fcontrasts | R Documentation |
Create F-contrasts to test for overall effects of model terms. F-contrasts are used to:
Test for any effect of a categorical predictor
Compare multiple basis functions simultaneously
Test for nonlinear effects of continuous predictors
Evaluate overall significance of model terms
Fcontrasts(x, ...)
## S3 method for class 'convolved_term'
Fcontrasts(x, ...)
x |
The model term to generate contrasts for (typically an event_term or event_model) |
... |
Additional arguments passed to methods. Common arguments include:
|
A list of contrast specifications where each contains:
Matrix of contrast weights
The model term being tested
Descriptive name for the contrast
Degrees of freedom for the contrast
event_model()
, contrast_weights()
# 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)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.