View source: R/rank1_estimation.R
r1_glm_betas | R Documentation |
Jointly estimates activation coefficients (betas) and an HRF shape (in a given basis)
under a Rank-1 constraint. Allows optional nuisance regressors.
Can optionally apply box constraints if m=3
and sign-flip to ensure
positive correlation with a reference HRF.
r1_glm_betas(
X,
y,
Z = NULL,
hrf_basis,
hrf_ref,
maxit = 100,
flip_sign = FALSE,
use_box_constraints = FALSE
)
X |
A numeric matrix of size |
y |
A length-n numeric vector of fMRI data (single voxel). |
Z |
Optional numeric matrix of nuisance regressors, |
hrf_basis |
A |
hrf_ref |
A length-T numeric vector of some reference HRF shape, for an optional sign-flip check. |
maxit |
Max number of L-BFGS-B iterations. Default 100. |
flip_sign |
Logical. If |
use_box_constraints |
Logical. If |
A list with:
Numeric vector of length k (event amplitudes).
Numeric vector of length m (basis weights).
Numeric vector of length q for nuisance, or numeric(0) if none.
Logical, TRUE if the L-BFGS-B optimizer converged.
The final objective (residual sum of squares / 2).
# Minimal usage example
set.seed(42)
n <- 200; k <- 10; m <- 3
X <- matrix(rnorm(n*k*m), n, k*m)
y <- rnorm(n)
hrf_basis <- matrix(rnorm(32*m), 32, m)
hrf_ref <- dgamma(seq(0, 31, length.out=32), shape=6, rate=1)
fit <- r1_glm_betas(X, y, NULL, hrf_basis, hrf_ref, maxit=50)
str(fit)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.