Skip to contents

Creates a design object for MVPA analysis that encapsulates training and testing designs, response variables, and optional blocking and splitting factors.

Usage

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

Arguments

train_design

A data frame containing the training design matrix

test_design

Optional data frame containing the test design matrix (default: NULL)

y_train

Formula or vector specifying the training response variable

y_test

Optional formula or vector specifying the test response variable (default: NULL)

block_var

Optional formula or vector specifying the blocking variable for cross-validation

split_by

Optional formula or vector for splitting analyses

...

Additional arguments (currently unused)

Value

An mvpa_design object (S3 class) containing:

train_design

Data frame of training design

test_design

Data frame of test design (if provided)

y_train

Training response variable

y_test

Test response variable (if provided)

block_var

Blocking variable for cross-validation (if provided)

split_by

Splitting factor (if provided)

Details

The y_train and y_test can be specified either as formulas (e.g., ~ condition) or as vectors. If formulas are used, they are evaluated within the respective design matrices.

The block_var and split_by can also be specified as formulas or vectors. If formulas, they are evaluated within the training design matrix.

See also

mvpa_dataset for creating the corresponding dataset object

Examples

# Basic design with only training data
train_df <- data.frame(condition = rep(c("A", "B"), each = 50),
                       block = rep(1:5, each = 20),
                       group = rep(c("Group1", "Group2"), 50))
design <- mvpa_design(train_df, y_train = ~ condition)
#> Error in tibble::as_tibble(train_design, .name_repair = .name_repair) %>%     mutate(.rownum = 1:n()): could not find function "%>%"

# Design with test data and blocking variable
test_df <- data.frame(condition = rep(c("A", "B"), each = 25))
design_with_test <- mvpa_design(
  train_df, 
  test_df, 
  y_train = ~ condition, 
  y_test = ~ condition,
  block_var = ~ block
)
#> Error in assert_that(!is.null(test_design)): could not find function "assert_that"

# Design with split_by factor
design_split <- mvpa_design(
  train_df, 
  y_train = ~ condition,
  split_by = ~ group
)
#> Error in tibble::as_tibble(train_design, .name_repair = .name_repair) %>%     mutate(.rownum = 1:n()): could not find function "%>%"