BayesGLM2: Group-level Bayesian GLM

View source: R/BayesGLM2.R

BayesGLM2R Documentation

Group-level Bayesian GLM

Description

Performs group-level Bayesian GLM estimation and inference using the joint approach described in Mejia et al. (2020).

Usage

BayesGLM2(
  results,
  contrasts = NULL,
  quantiles = NULL,
  excursion_type = NULL,
  contrast_names = NULL,
  gamma = 0,
  alpha = 0.05,
  nsamp_theta = 50,
  nsamp_beta = 100,
  num_cores = NULL,
  verbose = 1
)

Arguments

results

Either (1) a length N list of "BGLM" objects, or (2) a length N character vector of files storing "BGLM" objects saved with saveRDS. "fit_bglm" objects also are accepted.

contrasts

(Optional) A list of contrast vectors that specify the group-level summaries of interest. If NULL (DEFAULT), use contrasts that compute the average of each field (field HRF) across all subjects/sessions.

Each contrast vector is length KSN specifying a group-level summary of interest, where K is the number of fields in the first-level design matrices, S is the number of sessions, and N is the number of subjects. The vector is grouped by fields, then sessions, then subjects.

For a single session/subject, the contrast vector for the first field would be:

c0 <- c(1, rep(0, K-1)) #indexes the first field for a single session

so the full contrast vector for the group average over all sessions/subjects for the first field would be:

contrasts = rep(c0, S*N) /(S*N).

To obtain the group average for the first field, for just the first session, input zeros for the remaining sessions:

c2 <- c(c0, rep(0, K*(S-1))) contrasts = rep(c2, N) /N.

To obtain the group mean difference between two sessions (S=2) for the first field:

c3 <- c(c0, -c0) contrasts = rep(c3, N) / N.

To obtain the mean over sessions of the first field, just for the first subject:

c4 <- rep(c0, S) c(c4, rep(0, K*S*(N-1))) / S.

quantiles

(Optional) Vector of posterior quantiles to return in addition to the posterior mean.

excursion_type

(For inference only) The type of excursion function for the contrast (">", "<", "!="), or a vector thereof (each element corresponding to one contrast). If NULL, no inference performed.

contrast_names

(Optional) Names of contrasts.

gamma

(For inference only) Activation threshold for the excursion set, or a vector thereof (each element corresponding to one contrast). Default: 0.

alpha

(For inference only) Significance level for activation for the excursion set, or a vector thereof (each element corresponding to one contrast). Default: .05.

nsamp_theta

Number of theta values to sample from posterior. Default: 50.

nsamp_beta

Number of beta vectors to sample conditional on each theta value sampled. Default: 100.

num_cores

The number of cores to use for sampling betas in parallel. If NULL (default), do not run in parallel.

verbose

1 (default) to print occasional updates during model computation; 2 for occasional updates as well as running INLA in verbose mode (if Bayes), or 0 for no printed updates.

Value

A list containing the estimates, PPMs and areas of activation for each contrast.

INLA Requirement

This function requires the INLA package, which is not a CRAN package. See https://www.r-inla.org/download-install for easy installation instructions.


mandymejia/BayesfMRI documentation built on April 12, 2025, 3:44 p.m.