correlation_map | R Documentation |
Generate a correlation heatmap showing the relationships between columns in a design matrix. This visualization helps identify potential collinearity between regressors in the model. For event models, it shows correlations between different conditions. For baseline models, it shows correlations between drift and nuisance terms.
correlation_map(x, ...)
x |
The model object (event_model, baseline_model, or fmri_model) |
... |
Additional arguments passed to methods. Common arguments include:
|
Create a correlation heatmap for an fMRI design matrix.
A ggplot2 object containing the correlation heatmap, where:
Rows and columns represent model terms
Colors indicate correlation strength (-1 to 1)
Darker colors indicate stronger correlations
event_model()
, baseline_model()
# Create event data
event_data <- data.frame(
condition = factor(c("face", "house", "face", "house")),
rt = c(0.8, 1.2, 0.9, 1.1),
onsets = c(1, 10, 20, 30),
run = c(1, 1, 1, 1)
)
# Create sampling frame
sframe <- sampling_frame(blocklens = 50, TR = 2)
# Create event model
evmodel <- event_model(
onsets ~ hrf(condition) + hrf(rt),
data = event_data,
block = ~run,
sampling_frame = sframe
)
# Plot correlation map for event model
correlation_map(evmodel)
# Create baseline model
bmodel <- baseline_model(
basis = "bs",
degree = 3,
sframe = sframe
)
# Plot correlation map for baseline model
correlation_map(bmodel)
# Create full model and plot combined correlations
fmodel <- fmri_model(evmodel, bmodel)
correlation_map(fmodel, method = "pearson", half_matrix = TRUE)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.