event_term: Create an event model term from a named list of variables.

View source: R/event_vector.R

event_termR Documentation

Create an event model term from a named list of variables.

Description

Generates an event_term object which represents the combination of one or more event sequences (e.g., a factor crossed with a numeric modulator). It takes a list of variables (factors, numeric vectors, matrices, basis objects) along with shared onsets, block IDs, and durations. It uses the EV factory internally to create standardized event objects for each variable.

Usage

event_term(evlist, onsets, blockids, durations = 0, subset = NULL)

Arguments

evlist

A named list of variables (factors, numeric, matrices, ParametricBasis objects). The names are used as variable identifiers within the term.

onsets

Numeric vector of onset times (in seconds).

blockids

Numeric vector of block numbers (non-decreasing integers).

durations

Numeric vector of event durations (seconds, default is 0). Can be scalar (recycled) or vector matching length of onsets.

subset

Optional logical vector indicating which events to retain (applied before processing).

Value

A list object with class c("event_term", "event_seq"). Contains:

varname

Concatenated variable names from evlist.

events

A named list of the processed event objects.

subset

The subset vector used.

event_table

A tibble representing the combinations of descriptive levels/names for each event in the term, constructed using elements(..., values=FALSE).

onsets

Numeric vector of onsets (after processing/subsetting).

blockids

Numeric vector of block IDs (after processing/subsetting).

durations

Numeric vector of durations (after processing/subsetting).

Examples

x1 <- factor(rep(letters[1:3], 10))
x2 <- factor(rep(1:3, each = 10))
onsets <- seq(1, 100, length.out = 30)
blockids <- rep(1:3, each = 10)

eterm <- event_term(list(Condition = x1, Group = x2),
                    onsets = onsets,
                    blockids = blockids)
print(eterm)
head(event_table(eterm))
levels(eterm)
head(design_matrix(eterm))


bbuchsbaum/fmrireg documentation built on June 10, 2025, 8:18 p.m.