Terms Option

The Terms option is used to define model structures, including main effects and interactions between variables.

Description

In the jamovi UI, the Terms option is typically paired with a ListBox and a TermLabel. It allows users to construct complex models (e.g., ANOVA, Linear Regression) by combining variables into interaction terms.

YAML Properties

PropertyTypeDescription
namestringThe unique name of the option.
typestringMust be Terms.
titlestringThe label displayed in the UI.
sourcesarrayA list of option names (of type Variable or Variables) that provide the components for these terms.

R Implementation

In R, a Terms option is represented as a list of character vectors. Each character vector in the list represents a single term (e.g., list("A", "B", c("A", "B")) for main effects A and B, and their interaction).

Examples

1. Define in YAML

- name: modelTerms
  type: Terms
  title: Model Terms
  sources:
    - factors
    - covariates

2. Implementation in R

Access the terms using self$options$name:

terms <- self$options$modelTerms

# Example: Constructing a formula string
formula_parts <- sapply(terms, function(term) {
    paste0(jmvcore::composeTerm(term))
})
full_formula <- paste0("dep ~ ", paste(formula_parts, collapse=" + "))