glm_ols | R Documentation |
A convenience wrapper around estimate_betas
for ordinary least squares (OLS) estimation.
This function provides a simplified interface for fitting GLMs using OLS on matrix datasets.
glm_ols(
dataset,
model_obj,
basis_obj,
basemod = NULL,
block = ~1,
progress = TRUE,
...
)
dataset |
A |
model_obj |
An |
basis_obj |
An HRF basis object (e.g., from |
basemod |
A |
block |
A formula specifying the block factor (default: ~ 1 for single block) |
progress |
Logical; show progress bar (default: TRUE) |
... |
Additional arguments passed to |
Use Cases:
Condition-level estimation: Estimates average responses for each experimental condition
General linear modeling: Standard GLM approach for group-level or condition-level effects
Multi-trial averaging: Combines trials of the same condition to estimate mean responses
For single-trial estimation where each trial gets its own beta estimate, use glm_lss()
instead.
A list of class "fmri_betas" containing the estimated coefficients
estimate_betas
for the underlying estimation function,
glm_lss
for single trial estimation
## Not run:
# Create event model and data
event_data <- data.frame(
onset = c(10, 30, 50, 70),
condition = factor(c("A", "B", "A", "B")),
run = rep(1, 4)
)
sframe <- fmrihrf::sampling_frame(blocklens = 100, TR = 2)
model_obj <- event_model(onset ~ hrf(condition),
data = event_data,
block = ~ run,
sampling_frame = sframe)
# Create data matrix (100 timepoints, 10 voxels)
Y <- matrix(rnorm(1000), 100, 10)
# Create matrix_dataset with event table
dset <- matrix_dataset(Y, TR = 2, run_length = 100, event_table = event_data)
# Fit with OLS - estimates average response for each condition
fit <- glm_ols(dset, model_obj, fmrihrf::HRF_SPMG1)
dim(fit$betas_ran) # 2 conditions x 10 voxels
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.