event_model.formula: event_model.formula

View source: R/event_model.R

event_model.formulaR Documentation

event_model.formula

Description

Constructs an event model using a formula x, a dataset data, a block variable, and additional parameters (sampling frame, durations, precision, etc.). The right-hand side of the formula must consist of HRF terms (of class "hrfspec").

Usage

## S3 method for class 'formula'
event_model(
  x,
  data,
  block,
  sampling_frame,
  drop_empty = TRUE,
  durations = 0,
  precision = 0.3,
  ...
)

Arguments

x

A formula specifying the event model.

data

A data.frame containing the event information.

block

The block variable; either a formula or a vector of block values.

sampling_frame

The time series grid over which to sample the function.

drop_empty

Logical indicating whether to drop empty events. Default is TRUE.

durations

A numeric vector of event durations. Default is 0 for all events.

precision

Numeric value indicating the precision of the model. Default is 0.3.

...

Additional arguments.

Details

Construct an event model from a formula and data.

Value

An event model object.

Examples

# Example for event_model.formula:
df <- data.frame(onset = seq(1, 100, by = 10),
                 run = rep(1:2, each = 5),
                 x = rnorm(10),
                 y = rnorm(10))
# Create a sampling frame (assume sampling_frame() is defined)
sframe <- sampling_frame(blocklens = c(50, 50), TR = 2)
# Construct an event model using a formula.
# Here the left-hand side represents onsets and the right-hand side contains HRF terms.
ev_model <- event_model(x = onset ~ hrf(x) + hrf(y), data = df, 
            block = ~ run, sampling_frame = sframe)

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