Skip to contents

Constructs an MVPA design object, defining the classification or regression problem for Multi-Variate Pattern Analysis (MVPA). It handles different configurations of input datasets, response variables, and optional parameters, such as blocking variables and group structures.

Usage

mvpa_design(
  train_design,
  y_train,
  test_design = NULL,
  y_test = NULL,
  block_var = NULL,
  split_by = NULL
)

Arguments

train_design

A data.frame containing the training variables.

y_train

A formula, character name, or factor specifying the response variable for training. Must have at least 2 levels with one or more training instances.

test_design

An optional data.frame containing the test variables. Must be provided if y_test is specified.

y_test

An optional formula, character name, or factor specifying the response variable for testing. Requires test_design to be provided.

block_var

An optional formula, character name, or integer vector specifying the blocking variable, used for repeated measures designs.

split_by

An optional formula indicating the grouping structure for evaluating test performance. Splitting condition must result in at least 3 observations per group.

Value

An object of class mvpa_design, containing the training and optional test design, response variables, blocking variable, and group structure.

Examples

df1 <- data.frame(y = rep(letters[1:4], 5), x1 = rnorm(20), x2 = rnorm(20), block = rep(1:4, each = 5))
des <- mvpa_design(df1, ~ y, block_var = ~ block)

## With a test set
testdes <- data.frame(y = sample(letters[1:4], 10))
#> Error in sample.int(length(x), size, replace, prob): cannot take a sample larger than the population when 'replace = FALSE'
des <- mvpa_design(df1, ~ y, block_var = ~ block, test_design = testdes, y_test = ~ y)
#> Error in eval(expr, envir, enclos): object 'testdes' not found