create_event_model: Create an event model directly from components.

View source: R/event_model.R

create_event_modelR Documentation

Create an event model directly from components.

Description

Constructs an event model from its components. Variables can be specified as character strings or expressions (captured using rlang::exprs). The function creates HRF specifications (hrfspec objects), builds a formula string, and then assembles the final event model.

Usage

create_event_model(
  event_terms,
  events,
  onsets,
  block,
  sampling_frame,
  durations = 0,
  drop_empty = TRUE,
  precision = 0.3
)

Arguments

event_terms

A list of event term specifications. Each term is a list with components: - variables: Character vector of variable names or expressions. - hrf: HRF specification for the term.

events

A data frame of event variables (all variables must be present).

onsets

A numeric vector of event onset times (in seconds).

block

A vector of block IDs (must be strictly increasing integers).

sampling_frame

The time series grid over which to sample the function.

durations

A numeric vector of event durations (default is 0 for all events).

drop_empty

Logical indicating whether to drop empty events (default is TRUE).

precision

Numeric value indicating the precision of HRF sampling (default is 0.3).

Value

An event_model object.

Examples


# Example with variables as character strings:
event_terms <- list(
  list(
    variables = c("x", "y"),
    hrf = "spmg1"
  )
)

# Example with variables as expressions:
event_terms <- list(
  list(
    variables = exprs(x, Poly(y, 2)),
    hrf = "spmg1"
  )
)


bbuchsbaum/fmrireg documentation built on March 1, 2025, 11:20 a.m.