-
Notifications
You must be signed in to change notification settings - Fork 32
Categorical variable as predictor #35
Description
Hello,
I hope this message finds you well. First of all, thank you for sharing such an amazing toolbox! I have been willing to perform voxel-wise mediation analyses for a while, and your toolbox is exactly what I needed!
I have been trying to run a mediation analysis with a categorical variable. I defined my predictor X as categorical in matlab (with 3 conditions coded as 1, 2 and 3; for example, X = {1,1,1,2,3,1,2,3}, followed by X = categorical(X)). However, I got the following error message:
Error using mediation>setup_inputs
Expected input to be one of these types:
double, single, uint8, uint16, uint32, uint64, int8, int16, int32, int64
Instead its type was categorical.
Error in mediation (line 183)
setup_inputs(X, Y, M, varargin);
Error in mediation_search (line 143)
[paths, stat] = mediation(X, Y, M(:,region), varargin{:}, 'persistent', extra_args{:}, 'pvals_for_boot', pvals_for_boot, 'arorder', arorder);
Error in mediation_brain/process_slice (line 314)
slice_results = mediation_search('M', X, Y, M(:,whvox), varargin{:});
Error in mediation_brain (line 276)
process_slice();
If I don't define X as categorical, the command runs just fine, but I am concerned that the regression models consider X as a continuous variable and not a categorical one (in the latter case, I would expect the regression command to create dummy variables and then run the regression). Therefore, my question is: how should I define the categorical predictor before running the mediation analysis?
Thank you for your help!
Best,
Quentin