time_basisFun_formula: Construct a formula with basis functions over time

View source: R/time_basisFun_formula.R

time_basisFun_formulaR Documentation

Construct a formula with basis functions over time

Description

Adds basis functions, over the dimension of time, to a conventional [generalized] linear mixed-effects model formula.

Usage

time_basisFun_formula(
  formula_mem,
  ...,
  groupingVar,
  timeVar,
  basisDens,
  basis_calc_fun = "gaussian"
)

Arguments

formula_mem

Formula, specified as in brm or glmer

...
groupingVar

Character. Grouping variable for each timecourse (e.g., participant ID, or combination of participant and session)

timeVar

Numeric vector. Variable over which basis functions are to be constructed.

basisDens

Numeric scalar. Width between basis functions peaks (e.g., distance between first and second basis function highest-density points)

basis_calc_fun

Character. Function by which the basis functions are constructed. Currently only "gaussian" is implemented.

Details

Within a typical [G]LMEM, adding basis functions over the dimension of time can control for time-related variations, while also allowing for the recovery of those variations. This function takes in the formula of interest (e.g., y ~ x + (x|ID)) and its associated time data, and it returns an augmented formula (e.g., y ~ x + (x|ID) + (0 + basis_0 + basis_1 + basis_2 + basis_3 || ID)). The corresponding data (i.e., constructed bases) are included as an attribute of the returned formula (i.e., returnedFormula,'dfOut').

This function is designed to be compatible with lme4 and brms models.


akcochrane/TEfits documentation built on June 12, 2025, 11:10 a.m.