rsa_model | R Documentation |
This function creates an RSA model object by taking an MVPA (Multi-Variate Pattern Analysis) dataset and an RSA design.
rsa_model(
dataset,
design,
distmethod = "spearman",
regtype = "pearson",
check_collinearity = TRUE,
nneg = NULL,
semipartial = FALSE
)
dataset |
An instance of an |
design |
An instance of an |
distmethod |
A character string specifying the method used to compute distances between observations.
One of: |
regtype |
A character string specifying the analysis method.
One of: |
check_collinearity |
Logical indicating whether to check for collinearity in the design matrix.
Only applies when |
nneg |
A named list of variables (predictors) for which non-negative regression coefficients should be enforced
(only if |
semipartial |
Logical indicating whether to compute semi-partial correlations in the |
An object of class "rsa_model"
(and "list"
), containing:
dataset
: the input dataset
design
: the RSA design
distmethod
: the distance method used
regtype
: the regression type
nneg
: a named list of constrained variables, if any
semipartial
: whether to compute semi-partial correlations
# Create a random MVPA dataset
data <- matrix(rnorm(100 * 100), 100, 100)
labels <- factor(rep(1:2, each = 50))
mvpa_data <- mvpa_dataset(data, labels)
# Create an RSA design with two distance matrices
dismat1 <- dist(data)
dismat2 <- dist(matrix(rnorm(100*100), 100, 100))
rdes <- rsa_design(~ dismat1 + dismat2, list(dismat1=dismat1, dismat2=dismat2))
# Create an RSA model with standard 'lm' (returns t-values):
rsa_mod <- rsa_model(mvpa_data, rdes, regtype="lm")
# Create an RSA model enforcing non-negativity for dismat2 only:
# Requires the 'glmnet' package to be installed
# rsa_mod_nneg <- rsa_model(mvpa_data, rdes, regtype="lm",
# nneg = list(dismat2 = TRUE))
# Create an RSA model using 'lm' but returning semi-partial correlations:
rsa_mod_sp <- rsa_model(mvpa_data, rdes, regtype="lm",
semipartial = TRUE)
# Train the model
fit_params <- train_model(rsa_mod_sp, mvpa_data$train_data)
# 'fit_params' = named vector of semi-partial correlations for each predictor
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.