This MATLAB code is designed for mediation analysis where the mediator is a matrix, and both the exposure and outcome are scalars.
The method requires installing the following toolboxes:
- SparseReg Toolbox: SparseReg Toolbox Documentation
- TensorReg Toolbox: TensorReg Toolbox Documentation
In addition, the files inside the mex files.zip
need to be extracted and added to the MATLAB path
Key stages in the code include:
-
Library and Path Setup: Adds essential toolboxes and directories to the MATLAB path for tensor and regression operations.
-
Data Loading and Simulation: Defines whether to use simulated or real data. For simulated data, it generates complex data; for real data, it loads predefined datasets.
-
Matrix and Parameter Initialization: Sets up matrices and parameters for the regression, including specifying bootstrap samples and confounders.
-
Regression Analysis: Calls
Regressions_CovConf
to estimate model parametersA
andB
, storing results as complex matrices. -
Bootstrapping: Optionally performs bootstrapping to generate multiple estimates of
A
andB
for statistical analysis. -
Probability and Statistical Testing: Calculates p-values for matrix elements of
A
,B
, and their element-wise productA * B
. Applies False Discovery Rate (FDR) thresholds to identify significant elements. -
Visualization: Creates figures showing absolute values and significance levels of matrices
A
,B
, andA * B
based on calculated p-values. -
Timing: Outputs the total processing time in minutes.
This code is designed for high-dimensional data processing, leveraging complex-valued matrices and bootstrapping to enhance the robustness of regression analysis in tensor-based data. It is applicable to fields such as neuroimaging and signal processing.
Reference: C. Lopez Naranjo et al., “EEG functional connectivity as a Riemannian mediator: An application to malnutrition and cognition,” Human Brain Mapping, vol. 45, no. 7, p. e26698, May 2024, doi: 10.1002/hbm.26698.